2021-09-02 12:19:53 +01:00
|
|
|
|
{{/*
|
|
|
|
|
In order for changes to the kubeadm config to be applied to existing machines,
|
|
|
|
|
kubeadm config templates must be treated as immutable. This means that we must
|
|
|
|
|
create a new one when the spec changes and update the ref in the corresponding
|
|
|
|
|
machine deployment, which will trigger a rollout of new machines with the new
|
|
|
|
|
kubeadm config.
|
|
|
|
|
|
|
|
|
|
If the kubeadm config is updated in place, it will apply to new machine (e.g. on
|
|
|
|
|
a scale out operation), but will not be applied to existing machines.
|
|
|
|
|
|
|
|
|
|
To do this, we create a new template whenever the checksum of the spec changes.
|
|
|
|
|
*/}}
|
2022-03-01 09:43:14 +00:00
|
|
|
|
|
2021-09-02 12:19:53 +01:00
|
|
|
|
{{- define "openstack-cluster.nodegroup.kct.spec" -}}
|
2022-03-01 09:43:14 +00:00
|
|
|
|
{{- $ctx := index . 0 }}
|
2021-09-06 15:14:56 +01:00
|
|
|
|
{{- $nodeGroup := index . 1 }}
|
2022-03-01 09:43:14 +00:00
|
|
|
|
{{- include "openstack-cluster.kubeadmConfigSpec" (list $ctx $nodeGroup.kubeadmConfigSpec) }}
|
2021-09-02 12:19:53 +01:00
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
|
|
{{- define "openstack-cluster.nodegroup.kct.checksum" -}}
|
|
|
|
|
{{- include "openstack-cluster.nodegroup.kct.spec" . | sha256sum }}
|
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
|
|
{{- define "openstack-cluster.nodegroup.kct.name" -}}
|
|
|
|
|
{{- $ctx := index . 0 }}
|
|
|
|
|
{{- $nodeGroup := index . 1 }}
|
|
|
|
|
{{- $checksum := include "openstack-cluster.nodegroup.kct.checksum" . }}
|
|
|
|
|
{{- include "openstack-cluster.componentName" (list $ctx $nodeGroup.name) }}-{{ trunc 8 $checksum }}
|
|
|
|
|
{{- end }}
|
|
|
|
|
|
2021-09-06 15:14:56 +01:00
|
|
|
|
{{- range $nodeGroupOverrides := .Values.nodeGroups }}
|
|
|
|
|
{{- $nodeGroup := deepCopy $.Values.nodeGroupDefaults | mustMerge $nodeGroupOverrides }}
|
2021-08-26 10:40:10 +01:00
|
|
|
|
---
|
2021-11-17 10:02:06 +00:00
|
|
|
|
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
|
2021-08-26 10:40:10 +01:00
|
|
|
|
kind: KubeadmConfigTemplate
|
|
|
|
|
metadata:
|
2021-09-02 12:19:53 +01:00
|
|
|
|
name: {{ include "openstack-cluster.nodegroup.kct.name" (list $ $nodeGroup) }}
|
2022-09-22 11:23:14 +01:00
|
|
|
|
labels:
|
|
|
|
|
{{- include "openstack-cluster.componentLabels" (list $ "worker") | nindent 4 }}
|
|
|
|
|
capi.stackhpc.com/node-group: {{ $nodeGroup.name }}
|
2021-09-02 12:19:53 +01:00
|
|
|
|
annotations:
|
|
|
|
|
capi.stackhpc.com/template-checksum: {{ include "openstack-cluster.nodegroup.kct.checksum" (list $ $nodeGroup) }}
|
2022-08-01 16:48:13 +01:00
|
|
|
|
# We let Cluster API clean up the cluster resources
|
|
|
|
|
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
|
2021-09-02 12:19:53 +01:00
|
|
|
|
helm.sh/resource-policy: keep
|
2022-03-01 09:43:14 +00:00
|
|
|
|
spec:
|
|
|
|
|
template:
|
|
|
|
|
spec: {{ include "openstack-cluster.nodegroup.kct.spec" (list $ $nodeGroup) | nindent 6 }}
|
2021-08-26 10:40:10 +01:00
|
|
|
|
{{- end }}
|