#}

AWS EKS Deployment

Deploy GEMVC to Amazon Kubernetes Service with auto-scaling and high availability

Deploy GEMVC to AWS EKS

Complete guide for deploying a containerized GEMVC application to Amazon Elastic Kubernetes Service (EKS) for high availability and automatic scaling.

AWS EKS

Kubernetes

Auto-Scaling

High Availability

Core Concepts

  • Kubernetes (K8s): Container orchestration platform for automated deployment and scaling
  • AWS EKS: Managed Kubernetes service - AWS manages the control plane
  • kubectl: CLI tool for interacting with Kubernetes clusters
  • Manifests: YAML files describing deployments, services, and ingress

Part 1: Prerequisites

Step 1: Install AWS CLI

AWS CLI Setup
# Configure AWS credentials
aws configure

# Enter your:
# - AWS Access Key ID
# - AWS Secret Access Key
# - Default region (e.g., us-east-1)
# - Default output format (json)

Step 2: Install kubectl

Install kubectl
# Linux
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

# Verify
kubectl version --client

Step 3: Install eksctl

Install eksctl
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin

# Verify
eksctl version

Part 2: Create EKS Cluster

Step 4: Provision Cluster

info: This process takes 15-20 minutes. AWS is provisioning the Kubernetes control plane and worker nodes.
Create EKS Cluster
eksctl create cluster \
  --name gemvc-cluster \
  --region us-east-1 \
  --version 1.29 \
  --nodegroup-name standard-workers \
  --node-type t3.medium \
  --nodes 2 \
  --nodes-min 1 \
  --nodes-max 3 \
  --managed
Verify Nodes
# Verify cluster is ready
kubectl get nodes

Part 3: Kubernetes Manifests

Create a k8s/ folder with these files:

Step 5: deployment.yaml

k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gemvc-app-deployment
spec:
  replicas: 2  # High availability
  selector:
    matchLabels:
      app: gemvc-app
  template:
    metadata:
      labels:
        app: gemvc-app
    spec:
      containers:
      - name: gemvc-app
        image: your-dockerhub/gemvc-api:latest
        ports:
        - containerPort: 9501  # OpenSwoole port
        envFrom:
        - secretRef:
            name: gemvc-app-secrets

Step 6: Create Secrets

Tip: Never commit .env files to Git! Use Kubernetes Secrets for sensitive data.
.env (local only)
# Create .env file locally (NOT in Git!)
APP_ENV=production
DB_HOST=production-db.internal
DB_USER=prod_user
DB_PASSWORD=your-secure-password
TOKEN_SECRET=your-jwt-secret-key
Create Secret
# Create Kubernetes secret from .env
kubectl create secret generic gemvc-app-secrets --from-env-file=.env

Step 7: service.yaml

k8s/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: gemvc-app-service
spec:
  selector:
    app: gemvc-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9501
  type: NodePort

Step 8: ingress.yaml

info: You need an SSL certificate in AWS Certificate Manager (ACM) for your domain.
k8s/ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: gemvc-app-ingress
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:REGION:ACCOUNT:certificate/ID
spec:
  rules:
    - host: api.your-domain.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: gemvc-app-service
                port:
                  number: 80

Part 4: Deploy Application

Step 9: Install AWS Load Balancer Controller

Follow the official AWS guide to install the ALB Controller.

Step 10: Apply Manifests

Deploy to EKS
# Deploy application
kubectl apply -f k8s/deployment.yaml

# Create service
kubectl apply -f k8s/service.yaml

# Create load balancer
kubectl apply -f k8s/ingress.yaml

Step 11: Verify Deployment

Verify Deployment
# Check pods are running
kubectl get pods

# Get load balancer URL
kubectl get ingress gemvc-app-ingress

# Look for ADDRESS column - point your DNS CNAME to this

Part 5: Updates (Zero Downtime)

Zero-Downtime Update
# Update image tag in deployment.yaml, then:
kubectl apply -f k8s/deployment.yaml

# Kubernetes performs rolling update automatically!

Rolling Updates: Kubernetes creates new pods with the updated image and gracefully terminates old ones - zero downtime!

Deployment Checklist

  • AWS CLI configured with credentials
  • kubectl and eksctl installed
  • EKS cluster created and nodes ready
  • Kubernetes secrets created from .env
  • SSL certificate in ACM
  • DNS CNAME pointing to ALB

Next Steps