Running Your First Application on EKS

Running Your First Application on EKS

In this section, we will dive into the practical aspects of deploying your first application on Amazon Elastic Kubernetes Service (EKS). We will cover the necessary prerequisites, configuration options, and the step-by-step process for deploying a simple application. This guide assumes you have a basic understanding of Kubernetes and its components. By following this guide, you will learn how to set up your first EKS application setup, ensuring you can leverage the power and scalability of Amazon EKS for your Kubernetes workloads.

Technical Requirements: First Application on EKS

Before we begin, ensure that you have the following prerequisites in place:

  1. EKS Cluster: You must have an EKS cluster set up and operational.
  2. Worker Nodes: At least two worker nodes should be connected to your cluster.
  3. Network Connectivity: Ensure you have network connectivity to your EKS API endpoint.
  4. Tools Installed:

   – AWS CLI

   – kubectl (Kubernetes command-line tool)

Understanding the Different Configuration Options for Your Application

When deploying an application on Kubernetes, it is essential to understand the various configuration options available. Here are some key concepts:

– Single Pod: Deploy a single pod from a container image stored in a repository.

– Resilient Deployment: Utilize a Kubernetes Deployment to manage multiple pods, ensuring that the desired number of replicas is maintained.

– Updating Deployments: Modify the container image in a deployment to roll out updates seamlessly.

– External Services: Expose your deployment as a service, allowing external access.

– Ingress Controller: Use an Ingress controller to manage external access with more control over routing and security.

– Multi-container Pods: Deploy multiple containers within a single pod, often used for sidecar patterns.

– Load Balancer: Integrate a load balancer for distributing traffic among pods.

– Auto-scaling Pods: Implement auto-scaling to adjust the number of pods based on demand.

– Storage for Pods: Configure persistent storage for your applications using Kubernetes volumes.

Introducing kubectl Configuration

`kubectl` is the command-line interface for interacting with your Kubernetes cluster. It allows you to perform administrative tasks such as deploying applications, scaling deployments, and viewing logs.

To verify your connectivity with the EKS cluster, run the following command:

“`bash

kubectl get svc

“`

This command should return a list of services running in your cluster, confirming that your `kubectl` is correctly configured.

Creating Your First Application on EKS

Now, let’s create and deploy your first application on EKS. We will use a simple example of deploying a web application.

  1. Create a Deployment: Create a YAML file named `deployment.yaml` with the following content:

`yaml

apiVersion: apps/v1

kind: Deployment

metadata:

  name: my-app

spec:

  replicas: 3

  selector:

    matchLabels:

      app: my-app

  template:

    metadata:

      labels:

        app: my-app

    spec:

      containers:

      - name: my-app

        image: nginx:latest

        ports:

        - containerPort: 80

“`

This configuration defines a deployment named `my-app` with three replicas of an NGINX container.

  1. **Deploy the Application**: Use the following command to deploy the application:

“`bash

kubectl apply -f deployment.yaml

“`

  1. Verify the Deployment: Check the status of your deployment:

“`bash

kubectl get deployments

“`

You should see your deployment listed with the number of replicas and their status.

Exposing Your Deployment

To make your application accessible from outside the cluster, you need to expose it. You can do this by creating a service.

  1. Create a Service: Create a YAML file named `service.yaml` with the following content:

“`yaml

apiVersion: v1

kind: Service

metadata:

  name: my-app-service

spec:

  type: LoadBalancer

  ports:

    - port: 80

      targetPort: 80

  selector:

    app: my-app

“`

This configuration creates a LoadBalancer service that routes traffic to your application.

  1. Deploy the Service: Use the following command to create the service:

“`bash

kubectl apply -f service.yaml

“`

  1. Get the External IP: After a few moments, you can check the external IP assigned to your service:

“`bash

kubectl get svc my-app-service

“`

Once the external IP is available, you can access your application using that IP in a web browser.

Modifying Your Deployment

To update your application, you can modify the deployment configuration. For example, if you want to change the container image, update the `image` field in your `deployment.yaml` file and reapply it:

“`yaml

        image: nginx:1.19.0

```

Then run:

```bash

kubectl apply -f deployment.yaml

“`

Kubernetes will handle the rollout of the new version automatically.

Visualizing Your Workloads

To visualize your workloads, you can use tools like the AWS Management Console or third-party tools like Lens. These tools provide a graphical interface to monitor your deployments, services, and overall cluster health.

  1. AWS Management Console: Navigate to the EKS section to view your cluster and its resources.
  2. Lens: If you have Lens installed, connect it to your EKS cluster to visualize and manage your workloads interactively.

Summary

In this guide, we covered the essential steps to deploy your first application on Amazon EKS. We discussed the technical requirements, configuration options, and the process of creating a deployment and exposing it as a service. With these foundational skills, you can start exploring more complex deployments and configurations in your EKS environment.

As you continue your journey with EKS, consider diving deeper into topics such as Helm for package management, advanced networking configurations, and security best practices to enhance your cloud-native applications.

Do you like to read more educational content? Read our blogs at Cloudastra Technologies or contact us for business enquiry at Cloudastra Contact Us.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top