Deploying an application on Amazon EKS

Category : Kubernetes | Sub Category : Kubernetes With Java | By Prasad Bonam Last updated: 2023-11-21 13:43:53 Viewed : 221


Deploying an application on Amazon EKS involves several steps, including creating an EKS cluster, configuring kubectl to interact with the cluster, and deploying your application using Kubernetes manifests or Helm charts. Below is a simplified guide to deploying a basic application on Amazon EKS:

Prerequisites:

  1. AWS Account:

    • Create an AWS account if you dont have one.
  2. AWS CLI and kubectl:

    • Install the AWS CLI and kubectl on your local machine.
  3. IAM User with EKS Permissions:

    • Ensure your IAM user has the necessary permissions to create and manage EKS clusters.

Steps:

1. Create an Amazon EKS Cluster:

  • Use the AWS Management Console, AWS CLI, or AWS CloudFormation to create an EKS cluster.
  • Example using AWS CLI:
    bash
    aws eks create-cluster --name my-eks-cluster --role-arn arn:aws:iam::123456789012:role/eks-cluster-role --resources-vpc-config subnetIds=subnet-xxxxxxxxxxxxxx,securityGroupIds=sg-xxxxxxxxxxxxxxxxx

2. Configure kubectl:

  • After creating the cluster, configure kubectl to interact with the EKS cluster.
    bash
    aws eks update-kubeconfig --name my-eks-cluster

3. Launch Worker Nodes:

  • Create a node group to launch worker nodes.
    bash
    aws eks create-nodegroup --cluster-name my-eks-cluster --nodegroup-name my-nodegroup --subnets subnet-xxxxxxxxxxxxxx --instance-types t2.micro

4. Verify Cluster and Nodes:

  • Verify that your EKS cluster and worker nodes are running.
    bash
    kubectl get nodes

5. Deploy an Application:

  • Create Kubernetes manifests for your application or use Helm charts.
    • Example Deployment YAML (my-app-deployment.yaml):
      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: nginx:latest ports: - containerPort: 80
    • Apply the deployment:
      bash
      kubectl apply -f my-app-deployment.yaml

6. Expose the Service:

  • Expose the deployment as a service.
    • Example Service YAML (my-app-service.yaml):
      yaml
      apiVersion: v1 kind: Service metadata: name: my-app-service spec: selector: app: my-app ports: - protocol: TCP port: 80 targetPort: 80 type: LoadBalancer
    • Apply the service:
      bash
      kubectl apply -f my-app-service.yaml

7. Access the Application:

  • Wait for the external IP to be assigned to the service, and access the application using that IP.

8. Clean Up:

  • When you are done experimenting, delete the EKS cluster and associated resources.
    bash
    aws eks delete-cluster --name my-eks-cluster

This is a basic guide, and the actual deployment may vary based on your application requirements. It is also worth considering Helm charts for managing the deployment and scaling of more complex applications. Additionally, configuring proper security groups, IAM roles, and networking settings are crucial for a production-grade deployment.

Search
Related Articles

Leave a Comment: