Help improve this page
Want to contribute to this user guide? Choose the Edit this page on GitHub link that is located in the right pane of every page. Your contributions will help make our user guide better for everyone.
Delete a cluster
When you’re done using an Amazon EKS cluster, you should delete the resources associated with it so that you don’t incur any unnecessary costs.
You can delete a cluster with eksctl
, the Amazon Web Services Management Console, or the Amazon CLI.
Considerations
-
If you have active services in your cluster that are associated with a load balancer, you must delete those services before deleting the cluster so that the load balancers are deleted properly. Otherwise, you can have orphaned resources in your VPC that prevent you from being able to delete the VPC.
-
If you receive an error because the cluster creator has been removed, see this article
to resolve. -
Amazon Managed Service for Prometheus resources are outside of the cluster lifecycle and need to be maintained independent of the cluster. When you delete your cluster, make sure to also delete any applicable scrapers to stop applicable costs. For more information, see Find and delete scrapers in the Amazon Managed Service for Prometheus User Guide.
-
To remove a connected cluster, see Deregister a Kubernetes cluster from the Amazon EKS console
Considerations for EKS Auto Mode
-
Any EKS Auto Mode Nodes will be deleted, including the EC2 managed instances
-
All load balancers will be deleted
For more information, see Disable EKS Auto Mode.
Delete cluster (eksctl)
This procedure requires eksctl
version 0.199.0
or later. You can check your version with the following command:
eksctl version
For instructions on how to install or upgrade eksctl
, see Installationeksctl
documentation.
-
List all services running in your cluster.
kubectl get svc --all-namespaces
-
Delete any services that have an associated
EXTERNAL-IP
value. These services are fronted by an Elastic Load Balancing load balancer, and you must delete them in Kubernetes to allow the load balancer and associated resources to be properly released.kubectl delete svc service-name
-
-
Delete the cluster and its associated nodes with the following command, replacing
prod
with your cluster name.eksctl delete cluster --name prod
Output:
[ℹ] using region region-code [ℹ] deleting EKS cluster "prod" [ℹ] will delete stack "eksctl-prod-nodegroup-standard-nodes" [ℹ] waiting for stack "eksctl-prod-nodegroup-standard-nodes" to get deleted [ℹ] will delete stack "eksctl-prod-cluster" [✔] the following EKS cluster resource(s) for "prod" will be deleted: cluster. If in doubt, check CloudFormation console
Delete cluster (Amazon console)
-
List all services running in your cluster.
kubectl get svc --all-namespaces
-
Delete any services that have an associated
EXTERNAL-IP
value. These services are fronted by an Elastic Load Balancing load balancer, and you must delete them in Kubernetes to allow the load balancer and associated resources to be properly released.kubectl delete svc service-name
-
Delete all node groups and Fargate profiles.
-
Open the Amazon EKS console
. -
In the left navigation pane, choose Amazon EKS Clusters, and then in the tabbed list of clusters, choose the name of the cluster that you want to delete.
-
Choose the Compute tab and choose a node group to delete. Choose Delete, enter the name of the node group, and then choose Delete. Delete all node groups in the cluster.
Note
The node groups listed are managed node groups only.
-
Choose a Fargate Profile to delete, select Delete, enter the name of the profile, and then choose Delete. Delete all Fargate profiles in the cluster.
-
-
Delete all self-managed node Amazon CloudFormation stacks.
-
Open the Amazon CloudFormation console
. -
Choose the node stack to delete, and then choose Delete.
-
In the Delete stack confirmation dialog box, choose Delete stack. Delete all self-managed node stacks in the cluster.
-
-
Delete the cluster.
-
Open the Amazon EKS console
. -
choose the cluster to delete and choose Delete.
-
On the delete cluster confirmation screen, choose Delete.
-
-
(Optional) Delete the VPC Amazon CloudFormation stack.
-
Open the Amazon CloudFormation console
. -
Select the VPC stack to delete, and then choose Delete.
-
In the Delete stack confirmation dialog box, choose Delete stack.
-
Delete cluster (Amazon CLI)
-
List all services running in your cluster.
kubectl get svc --all-namespaces
-
Delete any services that have an associated
EXTERNAL-IP
value. These services are fronted by an Elastic Load Balancing load balancer, and you must delete them in Kubernetes to allow the load balancer and associated resources to be properly released.kubectl delete svc service-name
-
Delete all node groups and Fargate profiles.
-
List the node groups in your cluster with the following command.
aws eks list-nodegroups --cluster-name my-cluster
Note
The node groups listed are managed node groups only.
-
Delete each node group with the following command. Delete all node groups in the cluster.
aws eks delete-nodegroup --nodegroup-name my-nodegroup --cluster-name my-cluster
-
List the Fargate profiles in your cluster with the following command.
aws eks list-fargate-profiles --cluster-name my-cluster
-
Delete each Fargate profile with the following command. Delete all Fargate profiles in the cluster.
aws eks delete-fargate-profile --fargate-profile-name my-fargate-profile --cluster-name my-cluster
-
-
Delete all self-managed node Amazon CloudFormation stacks.
-
List your available Amazon CloudFormation stacks with the following command. Find the node template name in the resulting output.
aws cloudformation list-stacks --query "StackSummaries[].StackName"
-
Delete each node stack with the following command, replacing
node-stack
with your node stack name. Delete all self-managed node stacks in the cluster.aws cloudformation delete-stack --stack-name node-stack
-
-
Delete the cluster with the following command, replacing
my-cluster
with your cluster name.aws eks delete-cluster --name my-cluster
-
(Optional) Delete the VPC Amazon CloudFormation stack.
-
List your available Amazon CloudFormation stacks with the following command. Find the VPC template name in the resulting output.
aws cloudformation list-stacks --query "StackSummaries[].StackName"
-
Delete the VPC stack with the following command, replacing
my-vpc-stack
with your VPC stack name.aws cloudformation delete-stack --stack-name my-vpc-stack
-