Deploying microservices to Kubernetes cluster in Amazon Elastic Kubernetes Service (Amazon EKS) involves several steps. Below is a high-level overview of the process. Please note that this is a simplified guide, and the actual steps may vary depending on your specific application and requirements.

In Kubernetes, “Deployment,” “Pod,” and “Service” are fundamental concepts used to manage and expose containerized applications. These concepts serve different purposes in the orchestration and networking of applications within a Kubernetes cluster:

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

Pod:

  • A Pod is the smallest deployable unit in Kubernetes
  • It represents a single instance of a running process in a cluster, which may consist of one or more containers
  • Containers within a Pod share the same network namespace and can communicate with each other using localhost
  • Pods are ephemeral and can be easily replaced or scaled up/down

Deployment:

  • A Deployment is a higher-level abstraction that manages the lifecycle of one or more replica Pods
  • It ensures a specified number of Pod replicas are running at all times, and it can automatically replace failed Pods or perform rolling updates when you change the Pod’s template (e.g., updating the container image)
  • Deployments are typically used to maintain the desired state of a replica set of Pods, providing resilience and ease of scaling

Service:

  • A Service is used for networking and load balancing within a Kubernetes cluster
  • It provides a stable endpoint (IP address and DNS name) for accessing a set of Pods, usually Pods managed by a Deployment or other controller
  • Services abstract the underlying network details and allow you to refer to a set of Pods using a single DNS name and port, providing a consistent way to access your application
  • In a typical application deployment scenario, you might use these components together:
    • A Deployment manages a set of replica Pods running your application
    • The Pods are part of a Service that exposes your application to other services within the cluster
  • You can also expose the Service externally using a ServiceType like LoadBalancer to allow access from outside the cluster, or you can use an Ingress resource for more advanced routing and external access

aws eks microservices

Step-by-Step Guide – How to Deploy Microservices to an EKS Cluster in AWS Kubernetes

Prerequisites:

  • An active Amazon EKS cluster
  • kubectl installed and configured to work with your EKS cluster
  • Docker installed for building container images

Let us get started and look into deploying your first AWS EKS microservices.

1. Create Kubernetes Manifests: Define Kubernetes manifest files (YAML) for your microservices. These manifest files specify the deployment, service, and other resources needed for your microservices. Each microservice typically has its own set of manifests. The following manifest has been taken from Kubernetes.io for demonstration purpose.

Download Banner

Create a new file called deployment.yaml with the following content.

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nginx
spec:
containers:
– name: nginx
image: nginx:1.14.2
ports:
– containerPort: 80

2. Apply Kubernetes Manifests: Use kubectl to apply the Kubernetes manifest files to your EKS cluster:

uxpro-$ ./kubectl create -f deployment.yaml
deployment.apps/nginx-deployment created

uxpro-$ ./kubectl get po
NAME READY STATUS RESTARTS AGE
nginx-deployment-cbdccf466-5mg7d 0/1 ContainerCreating 0 4s
nginx-deployment-cbdccf466-c8lt6 0/1 ContainerCreating 0 4s

uxpro-$

3. Check the status of your deployment and pods to ensure they are running:

uxpro-$ ./kubectl get po
NAME READY STATUS RESTARTS AGE
nginx-deployment-cbdccf466-5mg7d 1/1 Running 0 35s
nginx-deployment-cbdccf466-c8lt6 1/1 Running 0 35s

uxpro-$

4. Depending on your requirements, you may need to expose your microservices to external traffic. You can create Kubernetes Services or Ingress resources to achieve this. For more advanced routing and exposing multiple microservices, consider using Kubernetes Ingress controllers.

uxpro-$ ./kubectl expose deployment nginx-deployment –port=80 –target-port=9080 –type=NodePort
service/nginx-deployment exposed

uxpro-$ ./kubectl get svc -n default
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.100.0.1 443/TCP 151m
nginx-deployment NodePort 10.100.119.109 80:30088/TCP 5m4s
uxpro-$

5. You can access your service by using any worker node’s public or private IP address (or DNS name) and the NodePort assigned. For example: http://<worker-node-IP>:<nodeport>

how to deploy microservices in kubernetes

6. Scale and Manage: You can use kubectl to scale your microservices up or down based on demand:

uxpro-$ ./kubectl scale deployment nginx-deployment –replicas=5
deployment.apps/nginx-deployment scaled

uxpro-$ ./kubectl get po
NAME READY STATUS RESTARTS AGE
nginx-deployment-cbdccf466-2crnn 0/1 Pending 0 7s
nginx-deployment-cbdccf466-5mg7d 1/1 Running 0 4m29s
nginx-deployment-cbdccf466-c8lt6 1/1 Running 0 4m29s
nginx-deployment-cbdccf466-nvxsr 0/1 Pending 0 7s
nginx-deployment-cbdccf466-tlvdr 0/1 Pending 0 7s

uxpro-$

Conclusion

Remember that deploying microservices involves designing your architecture, managing dependencies, configuring networking, and monitoring for performance and reliability. This guide provides a basic starting point, but the details of your deployment will depend on your specific microservices and use case. In the enterprise world, EKS deployments will be handled using the Helm charts. To know more about Helm, kindly refer to helm official page.

Read more on Amazon EKS:

AWS for Beginners – How to Add Worker Nodes to Amazon EKS Cluster Using AWS CLI – Part 76
AWS for Beginners: How to Set Up Container Insights on Amazon EKS – Part 63
AWS for Beginners: How to Create Amazon EKS cluster using CLI? – Part 45
Amazon Elastic Kubernetes Service: An Overview

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

Rate this post