From 3cbb33690c6d579bccffbaaa0d806c674c3f95fe Mon Sep 17 00:00:00 2001 From: Travis Holton Date: Mon, 3 Jul 2023 12:44:13 +1200 Subject: [PATCH] Flatcar based clusters * Override name used for init and join configurations on flatcar * Use a dictionary merge to selectively replace the name field with CORES_OPENSTACK_HOSTNAME when flatcarOS is true * disable some subcharts by default * Change flatcar to more agnostic term "ignitionBased" --- charts/cluster-addons/values.yaml | 8 +++--- .../openstack-cluster/templates/_helpers.tpl | 27 ++++++++++++------- .../control-plane/kubeadm-control-plane.yaml | 6 ++++- charts/openstack-cluster/values.yaml | 17 +++++++++--- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/charts/cluster-addons/values.yaml b/charts/cluster-addons/values.yaml index 2ef1e548..14752319 100644 --- a/charts/cluster-addons/values.yaml +++ b/charts/cluster-addons/values.yaml @@ -203,7 +203,7 @@ monitoring: requests: storage: 10Gi lokiStack: - enabled: true + enabled: false chart: repo: https://grafana.github.io/helm-charts name: loki-stack @@ -227,7 +227,7 @@ monitoring: # https://github.com/kubernetes-sigs/node-feature-discovery/tree/master/deployment/helm/node-feature-discovery nodeFeatureDiscovery: # Indicates if node feature discovery should be enabled - enabled: true + enabled: false chart: repo: https://kubernetes-sigs.github.io/node-feature-discovery/charts name: node-feature-discovery @@ -242,7 +242,7 @@ nvidiaGPUOperator: # Note that because it uses node feature discovery to run only on nodes # with an NVIDIA GPU available, the overhead of enabling this on clusters # that do not need it now but may need it in the future is low - enabled: true + enabled: false chart: repo: https://nvidia.github.io/gpu-operator name: gpu-operator @@ -257,7 +257,7 @@ mellanoxNetworkOperator: # Note that because it uses node feature discovery to run only on nodes # with a Mellanox NIC available, the overhead of enabling this on clusters # that do not need it now but may need it in the future is low - enabled: true + enabled: false chart: repo: https://mellanox.github.io/network-operator name: network-operator diff --git a/charts/openstack-cluster/templates/_helpers.tpl b/charts/openstack-cluster/templates/_helpers.tpl index a80ae8bd..e208e18e 100644 --- a/charts/openstack-cluster/templates/_helpers.tpl +++ b/charts/openstack-cluster/templates/_helpers.tpl @@ -80,15 +80,19 @@ mirrors and additional packages. */}} {{- define "openstack-cluster.kubeadmConfigSpec" -}} {{- $ctx := index . 0 }} -{{/* WARN(travis) Flatcar is experimental. Do not merge yet! */}} -{{- $flatcarOS := $ctx.Values.flatcarOS }} -{{- $flatcarContainerLinuxConfig := $ctx.Values.flatcarContainerLinuxConfig }} +{{/* WARN(travis) Ignition based images. */}} +{{- $ignitionBasedOS := $ctx.Values.ignitionBasedOS }} +{{- $ignitionContainerLinuxConfig := $ctx.Values.ignitionContainerLinuxConfig }} +{{- $ignitionPreKubeadmCommands := $ctx.Values.ignitionPreKubeadmCommands }} {{- $registryMirrors := $ctx.Values.registryMirrors }} {{- $additionalPackages := $ctx.Values.additionalPackages }} {{- $trustedCAs := $ctx.Values.trustedCAs }} {{- $kubeadmConfigSpec := omit (index . 1) "files" "preKubeadmCommands" }} {{- $files := index . 1 | dig "files" list }} {{- $preKubeadmCommands := index . 1 | dig "preKubeadmCommands" list }} +{{- if $ignitionBasedOS }} +{{- $kubeadmConfigSpec := mergeOverwrite $kubeadmConfigSpec $ctx.Values.ignitionKubeadmConfigSpec }} +{{- end }} {{- with $kubeadmConfigSpec }} {{- toYaml . }} @@ -137,13 +141,13 @@ files: - {{ toYaml . | nindent 4 }} {{- end }} {{- end }} -{{- if $flatcarOS }} -{{/* WARN(travis) Flatcar based images. */}} -{{- with $flatcarContainerLinuxConfig }} +{{- if $ignitionBasedOS }} +{{/* WARN(travis) Ignition based images. */}} +{{- with $ignitionContainerLinuxConfig }} {{- toYaml . }} {{- end }} {{- end }} -{{- if or $trustedCAs $additionalPackages $preKubeadmCommands $flatcarOS }} +{{- if or $trustedCAs $additionalPackages $preKubeadmCommands $ignitionBasedOS }} preKubeadmCommands: {{- if $trustedCAs }} - update-ca-certificates @@ -155,11 +159,14 @@ preKubeadmCommands: {{- range $preKubeadmCommands }} - {{ . }} {{- end }} + {{- range $ignitionPreKubeadmCommands }} + - {{ . }} + {{- end }} {{- end }} {{- end }} -{{/* WARN(travis) Flatcar based images */}} -{{- if .Values.flatcarOS }} -{{- with .Values.flatcarContainerLinuxConfig }} +{{/* WARN(travis) Ignition based images */}} +{{- if .Values.ignitionBasedOS }} +{{- with .Values.ignitionContainerLinuxConfig }} {{ toYaml . }} {{- 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 14f84f33..2882cf21 100644 --- a/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml +++ b/charts/openstack-cluster/templates/control-plane/kubeadm-control-plane.yaml @@ -14,6 +14,10 @@ option of InitConfiguration and specifying a KubeProxyConfiguration. {{- $initConfiguration := omit (index . 1 | dig "initConfiguration" dict) "skipPhases" }} {{- $skipPhases := index . 1 | dig "initConfiguration" "skipPhases" list }} {{- $kubeProxyConfiguration := index . 1 | dig "kubeProxyConfiguration" dict }} +{{- $ignitionBasedOS := $ctx.Values.ignitionBasedOS }} +{{- if $ignitionBasedOS }} +{{- $initConfiguration := mergeOverwrite $initConfiguration $ctx.Values.ignitionInitConfiguration }} +{{- end}} {{- $files := index . 1 | dig "files" list }} {{- $preKubeadmCommands := index . 1 | dig "preKubeadmCommands" list }} @@ -58,7 +62,7 @@ preKubeadmCommands: {{- if $skipPhases }} - cat /run/kubeadm/skip-phases.yaml >> /run/kubeadm/kubeadm.yaml {{- end }} - {{- if not $ctx.Values.flatcarOS }} + {{- if not $ignitionBasedOS }} {{- if $kubeProxyConfiguration }} - cat /run/kubeadm/kube-proxy-configuration.yaml >> /run/kubeadm/kubeadm.yaml {{- end }} diff --git a/charts/openstack-cluster/values.yaml b/charts/openstack-cluster/values.yaml index f639be7d..75015583 100644 --- a/charts/openstack-cluster/values.yaml +++ b/charts/openstack-cluster/values.yaml @@ -24,9 +24,20 @@ cloudName: openstack # This should match the version of kubelet and kubeadm in the image kubernetesVersion: -# WARN(travis) Flatcar based images -flatcarOS: false -flatcarContainerLinuxConfig: +# WARN(travis) Ignition based images +ignitionBasedOS: false +ignitionInitConfiguration: + nodeRegistration: + name: ${COREOS_OPENSTACK_HOSTNAME} +ignitionKubeadmConfigSpec: + joinConfiguration: + nodeRegistration: + name: ${COREOS_OPENSTACK_HOSTNAME} +ignitionPreKubeadmCommands: + - export COREOS_OPENSTACK_HOSTNAME=${COREOS_OPENSTACK_HOSTNAME%.*} + - envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp + - mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml +ignitionContainerLinuxConfig: format: ignition ignition: containerLinuxConfig: