Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Help improve this page
Want to contribute to this user guide? Scroll to the bottom of this page
and select Edit this page on GitHub. 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.
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.
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.
You can delete a cluster with eksctl
, the Amazon Web Services Management Console, or the Amazon CLI.
- eksctl
-
To delete an Amazon EKS cluster and nodes with eksctl
This procedure requires eksctl
version
0.187.0
or later. You can check your version with the following
command:
eksctl version
For instructions on how to install or upgrade eksctl
, see
Installation in the eksctl
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
- 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.
-
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
-
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