Let CAPI rather than Helm manage the deletion of CAPI resources

This commit is contained in:
Matt Pryor 2022-08-01 16:48:13 +01:00
parent a0bcee539f
commit e158efd21e
8 changed files with 26 additions and 4 deletions

View File

@ -4,6 +4,10 @@ kind: OpenStackCluster
metadata:
name: {{ include "openstack-cluster.clusterName" . }}
labels: {{ include "openstack-cluster.commonLabels" . | nindent 4 }}
annotations:
# We let Cluster API clean up the cluster resources
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
helm.sh/resource-policy: keep
spec:
identityRef:
kind: Secret

View File

@ -70,6 +70,10 @@ kind: KubeadmControlPlane
metadata:
name: {{ include "openstack-cluster.componentName" (list . "control-plane") }}
labels: {{ include "openstack-cluster.componentLabels" (list . "control-plane") | nindent 4 }}
annotations:
# We let Cluster API clean up the cluster resources
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
helm.sh/resource-policy: keep
spec:
version: {{ .Values.global.kubernetesVersion | required ".Values.global.kubernetesVersion is required" }}
replicas: {{ .Values.controlPlane.machineCount }}

View File

@ -5,6 +5,10 @@ kind: MachineHealthCheck
metadata:
name: {{ include "openstack-cluster.componentName" (list . "control-plane") }}
labels: {{ include "openstack-cluster.componentLabels" (list . "control-plane") | nindent 4 }}
annotations:
# We let Cluster API clean up the cluster resources
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
helm.sh/resource-policy: keep
spec:
clusterName: {{ include "openstack-cluster.clusterName" . }}
selector:

View File

@ -47,7 +47,8 @@ metadata:
labels: {{ include "openstack-cluster.componentLabels" (list . "control-plane") | nindent 4 }}
annotations:
capi.stackhpc.com/template-checksum: {{ include "openstack-cluster.controlplane.mt.checksum" . }}
# Ensure that the previous machine templates are kept around
# We let Cluster API clean up the cluster resources
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
helm.sh/resource-policy: keep
spec:
{{- include "openstack-cluster.controlplane.mt.spec" . | nindent 2 }}

View File

@ -38,7 +38,8 @@ metadata:
labels: {{ include "openstack-cluster.nodeGroupLabels" (list $ $nodeGroup.name) | nindent 4 }}
annotations:
capi.stackhpc.com/template-checksum: {{ include "openstack-cluster.nodegroup.kct.checksum" (list $ $nodeGroup) }}
# Ensure that the previous templates are kept around
# We let Cluster API clean up the cluster resources
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
helm.sh/resource-policy: keep
spec:
template:

View File

@ -6,6 +6,10 @@ kind: MachineDeployment
metadata:
name: {{ include "openstack-cluster.componentName" (list $ $nodeGroup.name) }}
labels: {{ include "openstack-cluster.nodeGroupLabels" (list $ $nodeGroup.name) | nindent 4 }}
annotations:
# We let Cluster API clean up the cluster resources
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
helm.sh/resource-policy: keep
{{- if $nodeGroup.autoscale }}
{{-
$machineCountMin := $nodeGroup.machineCountMin |
@ -21,7 +25,6 @@ metadata:
{{- if lt $machineCountMax $machineCountMin }}
{{- fail (printf "maximum machine count < minimum machine count for node group '%s'" $nodeGroup.name) }}
{{- end }}
annotations:
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: {{ quote $machineCountMin }}
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: {{ quote $machineCountMax }}
{{- end }}

View File

@ -7,6 +7,10 @@ kind: MachineHealthCheck
metadata:
name: {{ include "openstack-cluster.componentName" (list $ $nodeGroup.name) }}
labels: {{ include "openstack-cluster.nodeGroupLabels" (list $ $nodeGroup.name) | nindent 4 }}
annotations:
# We let Cluster API clean up the cluster resources
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
helm.sh/resource-policy: keep
spec:
clusterName: {{ include "openstack-cluster.clusterName" $ }}
selector:

View File

@ -54,7 +54,8 @@ metadata:
labels: {{ include "openstack-cluster.nodeGroupLabels" (list $ $nodeGroup.name) | nindent 4 }}
annotations:
capi.stackhpc.com/template-checksum: {{ include "openstack-cluster.nodegroup.mt.checksum" (list $ $nodeGroup) }}
# Ensure that the previous machine templates are kept around
# We let Cluster API clean up the cluster resources
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
helm.sh/resource-policy: keep
spec: {{ include "openstack-cluster.nodegroup.mt.spec" (list $ $nodeGroup) | nindent 2 }}
{{- end }}