diff --git a/charts/openstack-cluster/README.md b/charts/openstack-cluster/README.md index 9d1c73e1a..7473e4818 100644 --- a/charts/openstack-cluster/README.md +++ b/charts/openstack-cluster/README.md @@ -222,3 +222,11 @@ clusterctl get kubeconfig my-cluster > kubeconfig.my-cluster # Use that kubeconfig to list pods on the workload cluster kubectl --kubeconfig=./kubeconfig.my-cluster get po -A ``` + +## Flatcar + +To deploy clusters which use Ignition such as Flatcar, you will need to override the following setting in your local `values.yaml`: + +```yaml +osDistro: flatcar +``` diff --git a/charts/openstack-cluster/templates/_helpers.tpl b/charts/openstack-cluster/templates/_helpers.tpl index e29b3dae0..e7773aa51 100644 --- a/charts/openstack-cluster/templates/_helpers.tpl +++ b/charts/openstack-cluster/templates/_helpers.tpl @@ -203,6 +203,7 @@ files: # This file is created by the capi-helm-chart to ensure that its parent directory exists owner: root:root permissions: "0644" +{{- if ne .Values.osDistro "flatcar" }} - path: /etc/containerd/config.toml content: | [plugins."io.containerd.grpc.v1.cri".registry] @@ -210,6 +211,7 @@ files: owner: root:root permissions: "0644" append: true +{{- end }} {{- with .Values.registryMirrors }} {{- range $registry, $registrySpec := . }} - path: /etc/containerd/certs.d/{{ $registry }}/hosts.toml @@ -275,3 +277,45 @@ Produces the spec for a KubeadmConfig object. include "openstack-cluster.mergeConcatMany" }} {{- end }} + +{{/* +Produces the spec for an Ignition based OS specific KubeadmConfig object conditional on osDistro set to "flatcar". +*/}} +{{- define "openstack-cluster.flatcarKubeadmConfigSpec" -}} +initConfiguration: + nodeRegistration: + name: ${COREOS_OPENSTACK_HOSTNAME} +joinConfiguration: + nodeRegistration: + name: ${COREOS_OPENSTACK_HOSTNAME} +preKubeadmCommands: + - export COREOS_OPENSTACK_HOSTNAME=${COREOS_OPENSTACK_HOSTNAME%.*} + - envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp + - mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml +format: ignition +ignition: + containerLinuxConfig: + additionalConfig: | + systemd: + units: + - name: coreos-metadata-sshkeys@.service + enabled: true + - name: kubeadm.service + enabled: true + dropins: + - name: 10-flatcar.conf + contents: | + [Unit] + Requires=containerd.service coreos-metadata.service + After=containerd.service coreos-metadata.service + [Service] + EnvironmentFile=/run/metadata/flatcar +{{- end }} + +{{- define "openstack-cluster.osDistroKubeadmConfigSpec" }} +{{- $ctx := index . 0 }} +{{- $osDistro := $ctx.Values.osDistro }} +{{- if eq $osDistro "flatcar" }} +{{- include "openstack-cluster.flatcarKubeadmConfigSpec" $ctx }} +{{- end }} +{{- end }} diff --git a/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml b/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml index 704580418..e13fe1554 100644 --- a/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml +++ b/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml @@ -6,9 +6,13 @@ joinConfiguration: {{ include "openstack-cluster.nodeRegistration.nodeLabels" . {{- end }} {{- define "openstack-cluster.controlplane.kubeadmConfigSpec.kubeProxyConfiguration" -}} -{{- with .kubeProxyConfiguration }} +{{- $ctx := index . 0 }} +{{- $osDistro := index . 1 }} +{{- $kubeProxyConfigurationPath := ternary "/etc/kube-proxy-configuration.yaml" "/run/kubeadm/kube-proxy-configuration.yaml" (eq $osDistro "flatcar") }} +{{- $kubeadmPath := ternary "/etc/kubeadm.yml" "/run/kubeadm/kubeadm.yaml" (eq $osDistro "flatcar") }} +{{- with $ctx.kubeProxyConfiguration }} files: - - path: /run/kubeadm/kube-proxy-configuration.yaml + - path: {{ $kubeProxyConfigurationPath }} content: | --- apiVersion: kubeproxy.config.k8s.io/v1alpha1 @@ -17,7 +21,7 @@ files: owner: root:root permissions: "0644" preKubeadmCommands: - - cat /run/kubeadm/kube-proxy-configuration.yaml >> /run/kubeadm/kubeadm.yaml + - cat {{ $kubeProxyConfigurationPath }} >> {{ $kubeadmPath }} {{- end }} {{- end }} @@ -53,7 +57,8 @@ spec: list (include "openstack-cluster.controlplane.kubeadmConfigSpec.nodeLabels" . | fromYaml) (include "openstack-cluster.kubeadmConfigSpec" (list . .Values.controlPlane.kubeadmConfigSpec) | fromYaml) - (include "openstack-cluster.controlplane.kubeadmConfigSpec.kubeProxyConfiguration" .Values.controlPlane.kubeadmConfigSpec | fromYaml) | + (include "openstack-cluster.osDistroKubeadmConfigSpec" (list . ) | fromYaml) + (include "openstack-cluster.controlplane.kubeadmConfigSpec.kubeProxyConfiguration" (list .Values.controlPlane.kubeadmConfigSpec .Values.osDistro) | fromYaml) | include "openstack-cluster.mergeConcatMany" | fromYaml ) diff --git a/charts/openstack-cluster/templates/node-group/kubeadm-config-template.yaml b/charts/openstack-cluster/templates/node-group/kubeadm-config-template.yaml index bf8d4a780..9ab2b61b0 100644 --- a/charts/openstack-cluster/templates/node-group/kubeadm-config-template.yaml +++ b/charts/openstack-cluster/templates/node-group/kubeadm-config-template.yaml @@ -25,8 +25,9 @@ joinConfiguration: {{ include "openstack-cluster.nodeRegistration.nodeLabels" $n {{- list (include "openstack-cluster.nodegroup.kct.spec.nodeLabels" (list $ctx $nodeGroup) | fromYaml) - (include "openstack-cluster.kubeadmConfigSpec" (list $ctx $nodeGroup.kubeadmConfigSpec) | fromYaml) | - include "openstack-cluster.mergeConcat" | + (include "openstack-cluster.kubeadmConfigSpec" (list $ctx $nodeGroup.kubeadmConfigSpec) | fromYaml) + (omit (include "openstack-cluster.osDistroKubeadmConfigSpec" (list $ctx) | fromYaml) "initConfiguration") | + include "openstack-cluster.mergeConcatMany" | fromYaml | toYaml }} diff --git a/charts/openstack-cluster/values.yaml b/charts/openstack-cluster/values.yaml index 77c53fccf..453a49289 100644 --- a/charts/openstack-cluster/values.yaml +++ b/charts/openstack-cluster/values.yaml @@ -119,6 +119,10 @@ apiServer: # The port to use for the API server port: 6443 + +# Set ignition based OS +osDistro: ubuntu +# Ignition Based OS specific configuration. # Settings for the control plane controlPlane: # The failure domains to use for control plane nodes