Here’s a step-by-step guide to setting up an Amazon Elastic Kubernetes Service (EKS) cluster with a managed node group and the AWS ingress controller from AWS Managed Console.
Step 1: Prerequisites
- Sign in to the AWS Management Console and navigate to the Amazon EKS console.
- Create an IAM role with the necessary permissions to create and manage EKS clusters, node groups, and other resources.
Step 2: Create the EKS Cluster
- Click on “Create cluster” in the EKS console.
- Select the desired settings for your cluster, such as region, Kubernetes version, and VPC configuration.
- Choose the IAM role you created earlier for cluster creation.
- Configure any additional settings as per your requirements.
- Review and create the cluster.
Step 3: Install and Configure the AWS CLI and kubectl
- Install the AWS CLI and configure it with your AWS credentials.
- Install kubectl, the command-line tool for Kubernetes, and configure it to connect to your EKS cluster.
Step 4: Create and Configure the Managed Node Group
- In the EKS console, click on your cluster.
- Click on “Add node group” and provide the necessary details like instance type, desired capacity, and other configurations.
- Choose the IAM role you created earlier for the node group.
- Review and create the node group.
Verify the setup
aws eks update-kubeconfig --name YOUR_CLUSTER_NAME
kubectl cluster-info
kubectl get nodes
kubectl get nodegroups
Step 5: Install the AWS Load Balancer Controller
- Open a terminal or command prompt.
- Run the following command to install the AWS Load Balancer Controller:
kubectl apply -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller/crds?ref=master"
- Install the controller with the following command:
helm repo add eks https://aws.github.io/eks-charts
helm upgrade -i aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=<cluster-name> --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller
verify AWS Load Balancer Controller
kubectl get deployment -n kube-system alb-ingress-controller
Step 6: Create an Ingress Resource
Create an Ingress resource that defines how incoming traffic should be routed to your services. Here’s an example Ingress resource:
#alb-ingress.yaml
# Annotations Reference: https://kubernetes-sigs.github.io/aws-alb-ingress-controller/guide/ingress/annotation/
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-service
labels:
app:my-app-deployment
annotations:
# Ingress Core Settings
kubernetes.io/ingress.class: "alb"
alb.ingress.kubernetes.io/scheme: internet-facing
# Health Check Settings
alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
alb.ingress.kubernetes.io/healthcheck-port: traffic-port
alb.ingress.kubernetes.io/healthcheck-path: /
alb.ingress.kubernetes.io/healthcheck-interval-seconds: '15'
alb.ingress.kubernetes.io/healthcheck-timeout-seconds: '5'
alb.ingress.kubernetes.io/success-codes: '200'
alb.ingress.kubernetes.io/healthy-threshold-count: '2'
alb.ingress.kubernetes.io/unhealthy-threshold-count: '2'
spec:
rules:
- http:
paths:
- path: /*
backend:
serviceName: api1
servicePort: 80
Apply the Ingress resource to your cluster with the following command:
kubectl apply -f alb-ingress.yaml
Step 7: Create a Deployment and Service
Create a Kubernetes Deployment manifest for your application:
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-deployment
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app-container
image: <your-app-image>
ports:
- containerPort: 80
Apply the Deployment manifest:
kubectl apply -f deployment.yaml
Create a Kubernetes Service manifest for your application:
# service.yaml
apiVersion: v1
kind: Service
metadata:
name: my-app-deployment
labels:
app: my-app-deployment
spec:
type: NodePort
selector:
app: my-app-deployment
ports:
- port: 80
targetPort: 80
Apply the Service manifest:
kubectl apply -f service.yaml
Step 8: Verify the Setup
- After deploying your application with the Ingress resource, wait for a few moments to allow the ingress controller to configure the necessary resources.
- Verify that the AWS ALB (Application Load Balancer) is created and associated with the Ingress rules by checking the AWS Management Console or running the appropriate AWS CLI commands.
kubectl get deployments
kubectl describe deployment my-deployment
kubectl get services
kubectl describe service my-service
kubectl get ingress
kubectl describe ingress my-ingress
Step 9: Test the Application
- Obtain the DNS name or IP address of the ALB created by the ingress controller.
- Access your application by entering the ALB’s DNS name or IP address in a web browser or using tools like cURL or Postman.
Congratulations! You have now successfully set up an EKS cluster with a managed node group and the AWS ingress controller. Your application is accessible through the ALB created by the ingress controller.
Leave a Comment