Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(eks): introduce option to not delete eks cluster, like removal policy #25544

Open
2 tasks
peterwoodworth opened this issue May 11, 2023 · 5 comments
Open
2 tasks
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@peterwoodworth
Copy link
Contributor

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

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

latest

Environment details (OS name and version, etc.)

mac

@peterwoodworth peterwoodworth added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. p2 effort/small Small work item – less than a day of effort @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service and removed needs-triage This issue or PR still needs to be triaged. labels May 11, 2023
@pahud
Copy link
Contributor

pahud commented May 11, 2023

@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?

@peterwoodworth
Copy link
Contributor Author

@pahud this was created based off an internal ticket - we should follow up with them

@paulocesarias
Copy link

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.

@pahud
Copy link
Contributor

pahud commented May 15, 2023

@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.

@paulocesarias
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

3 participants