Skip to content

Commit

Permalink
Flatcar based clusters
Browse files Browse the repository at this point in the history
* 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"
* local Gitlab setup for publishing helm packages.
* semantic version tag triggers packaging and push to local package
  repository (GitLab and OCI registry)
  • Loading branch information
Travis Holton committed Oct 4, 2023
1 parent 6667a0f commit 2ed65b7
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
32 changes: 31 additions & 1 deletion charts/openstack-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,19 @@ mirrors and additional packages.
*/}}
{{- define "openstack-cluster.kubeadmConfigSpec" -}}
{{- $ctx := index . 0 }}
{{/* 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 . }}
Expand Down Expand Up @@ -201,7 +208,13 @@ files:
- {{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- if or $trustedCAs $additionalPackages $preKubeadmCommands }}
{{- if $ignitionBasedOS }}
{{/* WARN(travis) Ignition based images. */}}
{{- with $ignitionContainerLinuxConfig }}
{{- toYaml . }}
{{- end }}
{{- end }}
{{- if or $trustedCAs $additionalPackages $preKubeadmCommands $ignitionBasedOS }}
preKubeadmCommands:
{{- if $trustedCAs }}
- update-ca-certificates
Expand All @@ -213,5 +226,22 @@ preKubeadmCommands:
{{- range $preKubeadmCommands }}
- {{ . }}
{{- end }}
{{- range $ignitionPreKubeadmCommands }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{/* WARN(travis) Ignition based images */}}
{{- if .Values.ignitionBasedOS }}
{{- with .Values.ignitionContainerLinuxConfig }}
{{ toYaml . }}
{{- end }}
{{- end}}

{{/*
Produces the image for the cluster autoscaler.
*/}}
{{- define "openstack-cluster.autoscaler.image" -}}
{{- $prefix := .Values.autoscaler.image.prefix | default .Values.global.imagePrefix | default "" }}
{{- printf "%s%s:%s" $prefix .Values.autoscaler.image.repository .Values.autoscaler.image.tag -}}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down Expand Up @@ -58,9 +62,11 @@ preKubeadmCommands:
{{- if $skipPhases }}
- cat /run/kubeadm/skip-phases.yaml >> /run/kubeadm/kubeadm.yaml
{{- end }}
{{- if not $ignitionBasedOS }}
{{- if $kubeProxyConfiguration }}
- cat /run/kubeadm/kube-proxy-configuration.yaml >> /run/kubeadm/kubeadm.yaml
{{- end }}
{{- end }}
{{- end }}
{{- end }}

Expand Down
32 changes: 32 additions & 0 deletions charts/openstack-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@ cloudName: openstack
# This should match the version of kubelet and kubeadm in the image
kubernetesVersion:

# 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:
additionalConfig: |
systemd:
units:
- name: [email protected]
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
# The name of the image to use for cluster machines
machineImage:
# OR
Expand Down

0 comments on commit 2ed65b7

Please sign in to comment.