Open peterwoodworth opened 1 year ago
@peterwoodworth
This is an interesting idea. The general purpose of delete protection is to protect the data from being removed when we destroy the stack. In EKS, if we keep the cluster with all the deployments
, pods
, services
, helm charts
and even nodegroups deleted, I didn't see too much value to retain an empty cluster. What is your primary intention not deleting the cluster?
@pahud this was created based off an internal ticket - we should follow up with them
Hi, it was me who filed the internal ticket, thanks for looking into this.
@pahud It would be ideal for the delete protection to protect the whole cluster infrastructure, so in case the stack is accidentally deleted, at least the cluster should require some manual action to be fully deleted.
@paulocesarias It makes perfect sense to me and I appreciate your ideas. We probably need to define what the "whole cluster infrastructure" includes before we figure out how to move to the next step.
The cluster of aws-eks is essentially created by a cluster resource handler as custom resource in which the cluster resource handler calls the API rather than using AWS::EKS::Cluster resoruce.
As custom resource does have removalPolicy I think it's possible to "protect" this custom resource from being deleted by exposing a prop like:
new eks.Cluster(scope, id ,{
...,
removalPolicy: RemovalPolicy.RETAIN,
});
However, there are a lot of k8s resources running in this cluster and having this property configured as RETAIN
means we will retain all k8s resources on it whenever possible even when the stack is destroyed. This sounds crazy but practical when we really need to protect the whole cluster and data. I would expect community PRs to help this idea move forward. Any further thoughts here are welcome and appreciated.
@pahud, this is exactly what I would expect from this. Also, I am assuming that deleting the cluster directly from the AWS EKS console, or just aws eks delete-cluster --name my-cluster
would delete all of the protected infrastructure when it is required. Thanks again for answering and addressing this, we will be following up on updates related to this.
Describe the feature
The Cluster resource is implemented with a custom resource, so Cfn RemovalPolicies cannot apply. We should provide an option to not delete the cluster when the custom resource gets deleted
Use Case
When I want to delete the stack but not my cluster
Proposed Solution
Introduce a prop on EKS Cluster L2, this prop then will be read in the custom resource handler on the delete event and decide whether to follow through with deletion or not.
Other Information
No response
Acknowledgements
CDK version used
latest
Environment details (OS name and version, etc.)
mac