Mirantis / hmc

Apache License 2.0
20 stars 16 forks source link

Create and configure EKS cluster #384

Closed slysunkin closed 1 month ago

slysunkin commented 1 month ago

Create and configure EKS (Elastic Kubernetes Service) cluster for development and testing

Acceptance criteria

slysunkin commented 1 month ago

Prepare the EKS cluster

Software prerequisites

  1. kubectl: CLI installed locally.
  2. AWS: Ensure you have the AWS CLI installed and configured with the necessary IAM permissions.
  3. eksctl: Install eksctl by following the official guide.

Create the EKS Cluster: Use the following command to create a new EKS cluster:

eksctl create cluster \
--name my-eks-cluster \
--region us-east-2 \
--nodegroup-name my-nodes \
--node-type t3.medium \
--nodes 3 \
--nodes-min 1 \
--nodes-max 4 \
--managed

--name: The name of your EKS cluster. --region: AWS region where you want to create the cluster. --nodegroup-name: The name of the node group. --node-type: EC2 instance type for the nodes. --nodes: Number of nodes to create initially. --nodes-min and --nodes-max: Minimum and maximum number of nodes. --managed: Indicates the use of managed node groups.

Verify the Cluster

After the creation process completes, verify that your EKS cluster is running:

eksctl get cluster --region us-east-2

You should see your cluster listed with the status ACTIVE.

Update kubeconfig

Ensure that your kubeconfig is updated to connect to the new cluster:

aws eks --region us-east-2 update-kubeconfig --name my-eks-cluster

This allows kubectl to communicate with your EKS cluster.

Test the Cluster

Run a command to see if you can interact with the cluster:

kubectl get nodes

You should see the list of nodes in your EKS cluster.

Additional Steps

Deploy a Kubernetes Application: You can now deploy applications using standard kubectl commands. Configure Cluster Autoscaler: To automatically adjust the size of your cluster based on resource utilization, configure the Kubernetes Cluster Autoscaler.

Clean Up

To delete the EKS cluster and associated resources:

eksctl delete cluster --name my-eks-cluster --region us-east-2

This will remove the cluster and the EC2 instances associated with it.

ECR repository

Create: https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-create.html

Get password: https://docs.aws.amazon.com/cli/latest/reference/ecr/get-login-password.html

Example:

aws ecr get-login-password \
    --region <region> \
| docker login \
    --username AWS \
    --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com