AWS Builder Center
Deploying Nginx on Amazon EKS with AWS Load Balancer Controller

Deploying Nginx on Amazon EKS with AWS Load Balancer Controller

A Kubernetes cluster with no workloads running on it is just infrastructure cost. The real value starts when you deploy applications and expose them to the world - reliably, with automatic load balancing and pod self-healing. In Part 2, I deploy an Nginx web server onto the EKS cluster from Part 1, expose it via an AWS Elastic Load Balancer, and verify the full traffic path from the internet to the running pods.

Head of DevOps

What We Are Building

Internet
↓
AWS ELB (public subnet — provisioned by AWS Load Balancer Controller)
↓
Kubernetes Service (LoadBalancer type)
↓
Nginx Pods × 2 (private subnet)
↑
Deployment manages replicas, rolling updates, self-healing

Key Concepts Before We Start

Deployment: Defines the desired state, “I want 2 Nginx pods running at all times.” Kubernetes continuously reconciles actual state toward this desired state. If a pod crashes, a new one is started automatically.
Service (LoadBalancer type): Exposes the pods to external traffic. When type is  LoadBalancer  and AWS Load Balancer Controller is installed, an AWS ELB is automatically provisioned and kept in sync with the Service.
Namespace: A logical boundary for resources. All demo workloads run in the  aiops-demo  namespace — isolated from system components in  kube-system .



Step 1 — Namespace

kubectl create namespace aiops-demo
Step 2 — Deployment + Service YAML
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: aiops-demo
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.25-alpine
ports:
- containerPort: 80
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "200m"
memory: "256Mi"
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 10
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
namespace: aiops-demo
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: "external"
service.beta.kubernetes.io/aws-load-balancer-scheme: "internet-facing"
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
Why Alpine image?  nginx:1.25-alpine  is significantly smaller than the standard image — faster pulls, smaller attack surface, and lower memory footprint.
Why resource requests and limits? Requests tell the scheduler how much CPU/memory to reserve. Limits cap what the container can consume. Without requests defined, the pod has no guaranteed resources and HPA cannot function (covered in Part 3).
Why liveness and readiness probes? Liveness: restart the container if Nginx stops responding. Readiness: only send traffic when Nginx is ready. These two probes are what make Kubernetes deployments self-healing in practice.
Step 3 — Deploy and Verify
kubectl apply -f nginx-deployment.yaml

# Watch pods come up
kubectl get pods -n aiops-demo --watch

# Expected:
# nginx-deployment-5cbdb449b5-62kq8 1/1 Running
# nginx-deployment-5cbdb449b5-kkk67 1/1 Running
Step 4 — Wait for External IP
kubectl get service nginx-service -n aiops-demo --watch

# External IP takes 2-3 minutes to provision:
# TYPE CLUSTER-IP EXTERNAL-IP
# LoadBalancer 10.100.7.213 <pending> ← waiting
# LoadBalancer 10.100.7.213 k8s-aiopsdem-xxx.elb.amazonaws.com ✅
Step 5 — Access the Application
NGINX_URL=$(kubectl get service nginx-service \
-n aiops-demo \
-o jsonpath='{.status.loadBalancer.ingress[0].hostname}')

curl http://$NGINX_URL
# <!DOCTYPE html>... Welcome to nginx! ✅
The browser shows “Welcome to nginx!” — served from pods running in private subnets, accessible via the AWS ELB in the public subnet.



Why External IP Was Pending (Common Issue)

The service showed  <pending>  for External IP for 10+ minutes initially. Two root causes:
1. AWS Load Balancer Controller was not fully ready. After installing the controller, it needs a minute to start watching for Service resources. A service created immediately after controller install may be missed. Deleting and recreating the service resolves this.
2. Subnet tags missing or incorrect. The controller uses subnet tags to decide where to place the load balancer. Without  kubernetes.io/role/elb = 1  on public subnets, the controller cannot find valid subnets and silently does nothing.
Both were resolved by verifying subnet tags in the VPC console and confirming the controller pods were  Running  before creating the Service.



Full Cluster State After Deploy

kubectl get all -n aiops-demo

# NAME READY STATUS
# pod/nginx-deployment-5cbdb449b5-62kq8 1/1 Running
# pod/nginx-deployment-5cbdb449b5-kkk67 1/1 Running
#
# NAME TYPE CLUSTER-IP EXTERNAL-IP
# service/nginx-service LoadBalancer 10.100.71.29 k8s-aiopsdem-xxx.elb.amazonaws.com
#
# NAME READY UP-TO-DATE AVAILABLE
# deployment.apps/nginx-deployment 2/2 2 2
#
# NAME DESIRED CURRENT READY
# replicaset.apps/nginx-deployment-5cbdb... 2 2 2

Key Lessons

Nodes in private subnets, load balancers in public subnets — this is the correct architecture. You do not need to put nodes in public subnets to expose services. The AWS Load Balancer Controller handles placement automatically based on subnet tags.
The  <pending>  External IP almost always points to one of two issues — the controller not being ready, or subnet tags missing. Check both before debugging further.
Liveness and readiness probes are not optional in production. Without them, Kubernetes has no way to know whether your application is actually healthy. A container can be “Running” while the application inside it is completely broken. Probes close that gap.
ReplicaSet is what actually maintains your pod count. The Deployment creates and manages a ReplicaSet. The ReplicaSet ensures the desired number of pods is always running. Understanding this chain — Deployment → ReplicaSet → Pods — helps when debugging scaling and rollout issues.



Full Source Code

All YAML manifests and setup guides are available on GitHub:
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article