Deleting an Amazon EKS 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.
To remove a connected cluster, see Deregistering a cluster
-
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.
You can delete a cluster with eksctl
, the Amazon Web Services Management Console, or the Amazon CLI. Select the
tab with the name of the tool that you'd like to use to delete your cluster.
- eksctl
-
To delete an Amazon EKS cluster and nodes with
eksctl
This procedure requires
eksctl
version0.135.0
or later. You can check your version with the following command:eksctl version
For instructions on how to install or upgrade
eksctl
, see Installing or updating eksctl.-
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
with your cluster name.prod
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
-
- Amazon Web Services Management Console
-
To delete an Amazon EKS cluster with the Amazon Web Services Management 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 at https://console.amazonaws.cn/eks/home#/clusters
. -
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 at https://console.amazonaws.cn/cloudformation
. -
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 at https://console.amazonaws.cn/eks/home#/clusters
. -
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 at https://console.amazonaws.cn/cloudformation
. -
Select the VPC stack to delete, and then choose Delete.
-
In the Delete stack confirmation dialog box, choose Delete stack.
-
- Amazon CLI
-
To delete an Amazon EKS cluster with the 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-namemy-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-namemy-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
with your node stack name. Delete all self-managed node stacks in the cluster.node-stack
aws cloudformation delete-stack --stack-name
node-stack
-
-
Delete the cluster with the following command, replacing
with your cluster name.my-cluster
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
with your VPC stack name.my-vpc-stack
aws cloudformation delete-stack --stack-name
my-vpc-stack
-
-