Skip to content

Commit

Permalink
doc: add capi how-to for custom bootstrap config (#1122)
Browse files Browse the repository at this point in the history
We're adding a how-to document, showing how to use a custom
bootstrap configuration with the Cluster API provider.

Note that this is already outlined by the config reference page:
https://documentation.ubuntu.com/canonical-kubernetes/latest/capi/reference/configs/#bootstrapconfig
  • Loading branch information
petrutlucian94 authored Feb 27, 2025
1 parent 7c4bf07 commit 9ef10c5
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
107 changes: 107 additions & 0 deletions docs/canonicalk8s/capi/howto/custom-bootstrap-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# How to use custom bootstrap configuration

The {{product}} bootstrap configuration gets automatically generated based on
user provided settings described in the [Cluster API configuration reference].

The configuration generated by the CAPI provider will also include CA
certificates as well as annotations and other settings that allow the provider
to function properly.

Not all bootstrap options are exposed through CAPI settings. However,
users can explicitly define the {{product}} bootstrap configuration.
This completely bypasses the other CAPI provider settings and the configuration
will be passed as-is to the {{product}} snap.

See the [Bootstrap configuration file reference] for more details about the
available settings.

## Passing the bootstrap configuration directly

The bootstrap configuration can be specified in the ``CK8sControlPlane`` spec:

```
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: CK8sControlPlane
metadata:
name: c1-control-plane
namespace: default
spec:
machineTemplate:
infrastructureTemplate:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
name: c1-control-plane
replicas: 1
spec:
bootstrapConfig:
content: |
cluster-config:
annotations:
k8sd/v1alpha/lifecycle/skip-cleanup-kubernetes-node-on-remove: "true"
k8sd/v1alpha/lifecycle/skip-stop-services-on-remove: "true"
network:
enabled: true
dns:
enabled: true
local-storage:
enabled: true
reclaim-policy: Retain
```

Note that the k8sd annotations allow the CAPI provider to properly remove
nodes.

## Using secrets to store the bootstrap configuration

The bootstrap configuration may contain sensitive data. For this reason, the
provider also allows passing it as a secret.

```
apiVersion: v1
kind: Secret
metadata:
name: ck8s-bootstrap-config
type: Opaque
stringData:
content: |
cluster-config:
annotations:
k8sd/v1alpha/lifecycle/skip-cleanup-kubernetes-node-on-remove: "true"
k8sd/v1alpha/lifecycle/skip-stop-services-on-remove: "true"
network:
enabled: true
dns:
enabled: true
local-storage:
enabled: true
reclaim-policy: Retain
```

The secret can then be referenced like so:

```
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: CK8sControlPlane
metadata:
name: c1-control-plane
namespace: default
spec:
machineTemplate:
infrastructureTemplate:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
name: c1-control-plane
replicas: 1
spec:
bootstrapConfig:
contentFrom:
secret:
# Name of the secret in the CK8sBootstrapConfig's namespace to use.
name: ck8s-bootstrap-config
# The key in the secret's data map for this value.
key: content
```

<!-- LINKS -->
[Cluster API configuration reference]: /capi/reference/configs.md
[Bootstrap configuration file reference]: /snap/reference/config-files/bootstrap-config.md
1 change: 1 addition & 0 deletions docs/canonicalk8s/capi/howto/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Overview <self>
:titlesonly:
Provision a Canonical Kubernetes cluster <provision>
Install custom Canonical Kubernetes <custom-ck8s>
Use custom bootstrap configuration <custom-bootstrap-config>
```

## Upgrade
Expand Down

0 comments on commit 9ef10c5

Please sign in to comment.