sigs.k8s.io/cluster-api-provider-aws@v1.5.5/docs/book/src/topics/external-resource-gc.md (about) 1 # External Resource Garbage Collection 2 3 - **Feature status:** Experimental 4 - **Feature gate (required):** ExternalResourceGC=true 5 6 ## Overview 7 8 Workload clusters that CAPA has created may have additional resources in AWS that need to be deleted when the cluster is deleted. 9 10 For example, if the workload cluster has `Services` of type `LoadBalancer` then AWS ELB/NLB are provisioned. If you try to delete the workload cluster in this example, it will fail as these load balancers are still using the VPC. 11 12 This feature enables deletion of these external resources as part of cluster deletion. During the deletion of a workload cluster the external AWS resources that where created by the Cloud Controller Manager (CCM) in the workload cluster will be identified and deleted. 13 14 > NOTE: This is not related to [externally managed infrastructure](https://cluster-api-aws.sigs.k8s.io/topics/bring-your-own-aws-infrastructure.html). 15 16 Currently, we support cleaning up the following: 17 18 - AWS ELB/NLB - by deleting `Services` of type `LoadBalancer` from the workload cluster 19 20 We will look to support deleting EBS volumes in the future potentially. 21 22 > Note: this feature will likely be superseded by an upstream CAPI feature in the future when [this issue](https://github.com/kubernetes-sigs/cluster-api/issues/3075) is resolved. 23 24 ## Enabling 25 26 To enable garbage collection, you must set the `ExternalResourceGC` feature gate to `true` on the controller manager. The easiest way to do this is via an environment variable: 27 28 ```bash 29 export EXP_EXTERNAL_RESOURCE_GC=true 30 clusterctl init --infrastructure aws 31 ``` 32 33 > Note: if you enable this feature **ALL** clusters will be marked as requiring garbage collection. 34 35 ## Operations 36 37 ### Manually Disabling Garbage Collection for a Cluster 38 39 There are 2 ways to manually disable garbage collection for an individual cluster: 40 41 #### Using `clusterawsadm` 42 43 By running the following command: 44 45 ```bash 46 clusterawsadm gc disable --cluster-name mycluster 47 ``` 48 49 See the command help for more examples. 50 51 #### Editing `AWSCluster\AWSManagedControlPlane` 52 53 Or, by editing your `AWSCluster` or `AWSManagedControlPlane` so that the annotation `aws.cluster.x-k8s.io/external-resource-gc` is set to **false**. 54 55 ```yaml 56 apiVersion: controlplane.cluster.x-k8s.io/v1beta1 57 kind: AWSManagedControlPlane 58 metadata: 59 annotations: 60 aws.cluster.x-k8s.io/external-resource-gc: "false" 61 ``` 62 63 ### Manually Enabling Garbage Collection for a Cluster 64 65 There are 2 ways to manually enable garbage collection for an individual cluster: 66 67 #### Using `clusterawsadm` 68 69 By running the following command: 70 71 ```bash 72 clusterawsadm gc enable --cluster-name mycluster 73 ``` 74 75 See the command help for more examples. 76 77 #### Editing `AWSCluster\AWSManagedControlPlane` 78 79 Or, by editing your `AWSCluster` or `AWSManagedControlPlane` o that the annotation `aws.cluster.x-k8s.io/external-resource-gc` is either removed or set to **true**. 80 81 ```yaml 82 apiVersion: controlplane.cluster.x-k8s.io/v1beta1 83 kind: AWSManagedControlPlane 84 metadata: 85 annotations: 86 aws.cluster.x-k8s.io/external-resource-gc: "true" 87 ```