How to use custom bootstrap configuration¶
The Canonical Kubernetes 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 Canonical Kubernetes bootstrap configuration. This completely bypasses the other CAPI provider settings and the configuration will be passed as-is to the Canonical Kubernetes 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