AWS EKS: Difference between revisions

From Dave-Wiki
(Created page with "= Deep Dive into Amazon EKS Management, Deployment, and Kubernetes CLI Commands = == Introduction == Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that simplifies deployment, scaling, and management of containerized applications in AWS. This guide covers: * EKS cluster setup and management. * Deployment of applications on EKS. * Common Kubernetes CLI commands. * Basic container and pod integration. * Advanced topics: Networking, storage, monito...")
 
m (Dave moved page EKS to AWS EKS)
 

Latest revision as of 00:53, 3 February 2025

Deep Dive into Amazon EKS Management, Deployment, and Kubernetes CLI Commands

Introduction

Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that simplifies deployment, scaling, and management of containerized applications in AWS. This guide covers:

  • EKS cluster setup and management.
  • Deployment of applications on EKS.
  • Common Kubernetes CLI commands.
  • Basic container and pod integration.
  • Advanced topics: Networking, storage, monitoring, logging, Helm charts, and best practices.

Prerequisites

Before proceeding, ensure the following:

  • AWS IAM permissions for EKS and related resources.
  • AWS CLI and kubectl installed.
  • eksctl (recommended for cluster creation).
  • Docker installed for building and pushing container images.

EKS Cluster Management

Template:See also

Cluster Creation

Using eksctl

eksctl create cluster --name my-cluster --region us-east-1 \
--nodegroup-name my-nodes --nodes 2 --nodes-min 1 --nodes-max 3 --managed

Using Terraform <syntaxhighlight lang="hcl"> resource "aws_eks_cluster" "eks" {

 name     = "my-cluster"
 role_arn = aws_iam_role.eks_role.arn
 vpc_config {
   subnet_ids = [aws_subnet.public1.id, aws_subnet.public2.id]
 }

} </syntaxhighlight>

Verifying Cluster Setup

aws eks update-kubeconfig --region us-east-1 --name my-cluster
kubectl get nodes

Kubernetes Networking Deep Dive

Kubernetes networking consists of:

  • Pod-to-Pod Communication: CNI plugins (e.g., AWS VPC CNI, Calico) manage networking.
  • Service Discovery: ClusterIP, NodePort, LoadBalancer services.
  • Ingress Controllers: Use ALB or NGINX for external traffic routing.
  • Network Policies: Restrict pod-to-pod communication.

Example: Creating a Network Policy <syntaxhighlight lang="yaml"> apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata:

 name: deny-all
 namespace: default

spec:

 podSelector: {}
 policyTypes:
 - Ingress

</syntaxhighlight>

Storage and Persistent Volumes

Kubernetes supports multiple storage types:

  • Ephemeral Storage: Tied to the pod’s lifecycle.
  • Persistent Volumes (PV): EBS-backed storage for stateful apps.
  • AWS EFS Integration: Multi-node shared storage.

Example: EBS-backed Persistent Volume <syntaxhighlight lang="yaml"> apiVersion: v1 kind: PersistentVolumeClaim metadata:

 name: ebs-claim

spec:

 accessModes:
   - ReadWriteOnce
 resources:
   requests:
     storage: 10Gi

</syntaxhighlight>

Monitoring and Logging

Amazon CloudWatch and AWS X-Ray help monitor and debug EKS workloads.

Enable Kubernetes Metrics Server

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

Checking Pod Resource Usage

kubectl top pods

Using AWS X-Ray for Tracing <syntaxhighlight lang="yaml"> apiVersion: apps/v1 kind: Deployment metadata:

 name: sample-app

spec:

 template:
   spec:
     containers:
     - name: app
       image: my-app
       env:
       - name: AWS_XRAY_DAEMON_ADDRESS
         value: "xray-service.default:2000"

</syntaxhighlight>

Troubleshooting Kubernetes Issues

Common troubleshooting techniques:

Checking Logs

kubectl logs <pod-name>

Debugging Pods

kubectl describe pod <pod-name>
kubectl exec -it <pod-name> -- /bin/sh

Investigating Network Connectivity

kubectl get services
kubectl get endpoints

Deploying Helm Charts

Helm simplifies Kubernetes application deployment.

Install Helm

curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

Deploying NGINX Using Helm

helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-nginx bitnami/nginx

Best Practices for EKS Management

  • Use IAM roles for service accounts to grant permissions securely.
  • Enable Cluster Autoscaler to scale nodes dynamically.
  • Monitor resources with Prometheus and Grafana.
  • Implement CI/CD with AWS CodePipeline and ArgoCD.

Conclusion

This guide covered:

  • Setting up and managing an EKS cluster.
  • Deploying applications on Kubernetes.
  • Essential Kubernetes CLI commands.
  • Networking, storage, monitoring, and best practices.

Would you like a deep dive into advanced networking with service meshes like Istio or Linkerd?