Skip to content

Commit 4bd8c27

Browse files
committed
chore: change name of prevent deletion label
Small change to prefix the label that preevents deletion of the VPC CNI to be prefixed with an CAPA prefix. This is just to ensure that we make it as specific to CAPA as possible. Signed-off-by: Richard Case <[email protected]>
1 parent b8ad31c commit 4bd8c27

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

api/v1beta2/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ import (
2424
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2525
)
2626

27+
const (
28+
// PreventDeletionLabel can be used in situations where preventing delation is allowed. The docs
29+
// and the CRD will call this out where its allowed.
30+
PreventDeletionLabel = "aws.cluster.x-k8s.io/prevent-deletion"
31+
)
32+
2733
// AWSResourceReference is a reference to a specific AWS resource by ID or filters.
2834
// Only one of ID or Filters may be specified. Specifying more than one will result in
2935
// a validation error.

docs/book/src/topics/eks/pod-networking.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ spec:
9797
disableVPCCNI: true
9898
```
9999

100-
If you are replacing Amazon VPC CNI with your own helm managed instance, you will need to set `AWSManagedControlPlane.spec.disableVPCCNI` to `true` and add `"prevent-deletion": "true"` label on the Daemonset. This label is needed so `aws-node` daemonset is not reaped during CNI reconciliation.
100+
If you are replacing Amazon VPC CNI with your own helm managed instance, you will need to set `AWSManagedControlPlane.spec.disableVPCCNI` to `true` and add `"aws.cluster.x-k8s.io/prevent-deletion": "true"` label on the Daemonset. This label is needed so `aws-node` daemonset is not reaped during CNI reconciliation.
101101

102102
The following example shows how to label your aws-node Daemonset.
103103

@@ -114,7 +114,7 @@ metadata:
114114
app.kubernetes.io/name: aws-node
115115
app.kubernetes.io/version: v1.15.1
116116
helm.sh/chart: aws-vpc-cni-1.15.1
117-
prevent-deletion: true
117+
aws.cluster.x-k8s.io/prevent-deletion: true
118118
```
119119

120120
> You cannot set **disableVPCCNI** to true if you are using the VPC CNI addon.

pkg/cloud/services/awsnode/cni.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,12 @@ func (s *Service) deleteResource(ctx context.Context, remoteClient client.Client
273273
s.scope.Debug(fmt.Sprintf("resource %s was not found, no action", key))
274274
return nil
275275
}
276-
// Don't delete if the `prevent-deletion` label exists. It could be there because CAPA added it (see below),
276+
// Don't delete if the "PreventDeletionLabel" label exists. It could be there because CAPA added it (see below),
277277
// or because it was added externally, for example if a custom version of AWS CNI was already installed.
278278
// Either way, CAPA should not delete such a labelled CNI installation.
279279
labels := obj.GetLabels()
280-
if _, exists := labels["prevent-deletion"]; exists {
281-
s.scope.Debug(fmt.Sprintf("resource %s has 'prevent-deletion' label, skipping deletion", key))
280+
if _, exists := labels[infrav1.PreventDeletionLabel]; exists {
281+
s.scope.Debug(fmt.Sprintf("resource %s has '%s' label, skipping deletion", key, infrav1.PreventDeletionLabel))
282282
return nil
283283
}
284284
// Delete the resource

0 commit comments

Comments
 (0)