Deploy App to EKS#
The cluster is up; now we run the PatientPing app on it. Nothing about this part is AWS-specific - it’s plain Kubernetes - but we’ll use AWS to expose the app to the internet at the end.
We need two objects:
- A Deployment: tells Kubernetes “keep 2 replicas of the
patientping-webcontainer running”. - A Service: gives those pods a stable address. With
type: LoadBalanceron EKS, Kubernetes asks AWS to create an Application Load Balancer for us - the same kind we built by hand in the ECS section.
Assignment#
Deploy patientping-web to the patientping-eks cluster and reach it through a load balancer.
- Create a file called
patientping-web.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: patientping-web
spec:
replicas: 2
selector:
matchLabels:
app: patientping-web
template:
metadata:
labels:
app: patientping-web
spec:
containers:
- name: web
image: YOUR_ECR_IMAGE_URI
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: patientping-web
spec:
type: LoadBalancer
selector:
app: patientping-web
ports:
- port: 80
targetPort: 8080If you don’t have a pushed image yet, build and push
patientping-webto ECR first (same steps as the ECR lesson) - EKS pulls images the same way ECS does.
- Apply it:
kubectl apply -f patientping-web.yaml- Watch the rollout:
kubectl get pods -wWait until both pods are Running and Ready (it may pull the image for a minute or two).
- Get the load balancer’s address:
kubectl get svc patientping-webThe EXTERNAL-IP column shows the ALB’s DNS name once AWS has provisioned it (~2-3 minutes). Then:
curl http://EXTERNAL-IPYou should get the PatientPing app’s response.
Cost check: The load balancer that Kubernetes created for you costs roughly $0.025 per hour plus data transfer, same as the ECS ALB. Two t3.small pods don’t cost anything extra beyond the worker nodes you’re already paying for.
Not:
kubectl get svc‘deki EXTERNAL-IP bazen<pending>görünür - AWS ALB’yi arka planda olusturdugundan 2-3 dakika beklesek tatli olur.
Cleanup later#
When you’re done with this section, kubectl delete -f patientping-web.yaml removes the deployment and the load balancer. Leaving an orphaned ALB around is a classic way to wake up to a surprise bill.