2021-09-01 11:20:23 +01:00
|
|
|
|
{{/*
|
|
|
|
|
Machine templates are immutable, so we need to make a new one when the spec changes.
|
|
|
|
|
To do this, we create a new template whenever the checksum of the spec changes.
|
|
|
|
|
*/}}
|
|
|
|
|
{{- define "openstack-cluster.nodegroup.mt.spec" -}}
|
2021-09-02 12:19:53 +01:00
|
|
|
|
{{- $ctx := index . 0 -}}
|
|
|
|
|
{{- $nodeGroup := index . 1 -}}
|
2021-09-01 11:20:23 +01:00
|
|
|
|
template:
|
|
|
|
|
spec:
|
|
|
|
|
identityRef:
|
|
|
|
|
kind: Secret
|
2022-01-19 15:34:54 +00:00
|
|
|
|
name: {{ include "openstack-cluster.cloudCredentialsSecretName" $ctx }}
|
2021-09-01 11:20:23 +01:00
|
|
|
|
cloudName: openstack
|
2021-09-06 15:14:56 +01:00
|
|
|
|
flavor: {{ $nodeGroup.machineFlavor | required (printf "no flavor specified for node group '%s'" $nodeGroup.name) }}
|
2021-11-01 15:09:32 +00:00
|
|
|
|
{{- with $ctx.Values.machineSSHKeyName }}
|
|
|
|
|
sshKeyName: {{ . }}
|
|
|
|
|
{{- end }}
|
2022-05-31 11:52:46 +01:00
|
|
|
|
{{- with $nodeGroup.machineRootVolume }}
|
|
|
|
|
rootVolume: {{ toYaml . | nindent 6 }}
|
2022-04-29 15:26:37 +01:00
|
|
|
|
{{- end }}
|
|
|
|
|
{{- if $ctx.Values.machineImageId }}
|
|
|
|
|
imageUUID: {{ $ctx.Values.machineImageId }}
|
|
|
|
|
{{- else if $ctx.Values.machineImage }}
|
|
|
|
|
image: {{ tpl $ctx.Values.machineImage $ctx }}
|
2021-11-01 15:09:32 +00:00
|
|
|
|
{{- else }}
|
2022-04-29 15:26:37 +01:00
|
|
|
|
{{- fail "Either machineImage or machineImageId is required" }}
|
2021-11-01 15:09:32 +00:00
|
|
|
|
{{- end }}
|
2021-09-06 17:37:22 +01:00
|
|
|
|
{{- with $nodeGroup.machineNetworking.networks }}
|
|
|
|
|
networks: {{ toYaml . | nindent 6 }}
|
|
|
|
|
{{- end }}
|
|
|
|
|
{{- with $nodeGroup.machineNetworking.ports }}
|
|
|
|
|
ports: {{ toYaml . | nindent 6 }}
|
|
|
|
|
{{- end }}
|
2021-09-01 11:20:23 +01:00
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
|
|
{{- define "openstack-cluster.nodegroup.mt.checksum" -}}
|
|
|
|
|
{{- include "openstack-cluster.nodegroup.mt.spec" . | sha256sum }}
|
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
|
|
{{- define "openstack-cluster.nodegroup.mt.name" -}}
|
|
|
|
|
{{- $ctx := index . 0 }}
|
|
|
|
|
{{- $nodeGroup := index . 1 }}
|
|
|
|
|
{{- $checksum := include "openstack-cluster.nodegroup.mt.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
|
|
|
|
---
|
2022-08-01 17:50:23 +01:00
|
|
|
|
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha6
|
2021-08-26 10:40:10 +01:00
|
|
|
|
kind: OpenStackMachineTemplate
|
|
|
|
|
metadata:
|
2021-09-01 11:20:23 +01:00
|
|
|
|
name: {{ include "openstack-cluster.nodegroup.mt.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-01 11:20:23 +01:00
|
|
|
|
annotations:
|
|
|
|
|
capi.stackhpc.com/template-checksum: {{ include "openstack-cluster.nodegroup.mt.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-01 11:20:23 +01:00
|
|
|
|
helm.sh/resource-policy: keep
|
2021-09-02 12:19:53 +01:00
|
|
|
|
spec: {{ include "openstack-cluster.nodegroup.mt.spec" (list $ $nodeGroup) | nindent 2 }}
|
2021-08-26 10:40:10 +01:00
|
|
|
|
{{- end }}
|