DEV Community

Aisalkyn Aidarova
Aisalkyn Aidarova

Posted on

🏠 JumpToTech Homework β€” Docker ECR EKS Service Ingress ALB

Scenario

You joined a company as a Junior DevOps Engineer.

A developer gives you a simple web application. Your task is to containerize it and deploy it to AWS EKS so customers can access it from the internet.

Final architecture:

Developer Code
      ↓
Dockerfile
      ↓
Docker Image
      ↓
Amazon ECR
      ↓
EKS Cluster
      ↓
Node Group
      ↓
Deployment
      ↓
ReplicaSet
      ↓
3 Pods
      ↓
Service
      ↓
Ingress
      ↓
AWS Load Balancer Controller
      ↓
ALB
      ↓
Internet / Browser
Enter fullscreen mode Exit fullscreen mode

PART 1 β€” Create the project

Create:

mkdir jumptotech-homework
cd jumptotech-homework
Enter fullscreen mode Exit fullscreen mode

Your final directory should contain:

jumptotech-homework/
β”‚
β”œβ”€β”€ index.html
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ deployment.yaml
β”œβ”€β”€ service.yaml
└── ingress.yaml
Enter fullscreen mode Exit fullscreen mode

Create an index.html that displays:

JumpToTech DevOps
Docker β†’ ECR β†’ EKS
My Kubernetes Application is Running!
Enter fullscreen mode Exit fullscreen mode

Design is up to you.


PART 2 β€” Docker

Create a Dockerfile.

Requirements:

  • Use nginx:alpine
  • Copy index.html into Nginx
  • Application listens on port 80

Build the image:

docker build -t jumptotech-homework:v1 .
Enter fullscreen mode Exit fullscreen mode

Verify:

docker images
Enter fullscreen mode Exit fullscreen mode

Run it locally:

docker run -d \
--name homework-test \
-p 8080:80 \
jumptotech-homework:v1
Enter fullscreen mode Exit fullscreen mode

Check:

docker ps
Enter fullscreen mode Exit fullscreen mode

Open:

http://localhost:8080
Enter fullscreen mode Exit fullscreen mode

You must see your application.


PART 3 β€” Docker troubleshooting

Run:

docker logs homework-test
Enter fullscreen mode Exit fullscreen mode

Enter the container:

docker exec -it homework-test sh
Enter fullscreen mode Exit fullscreen mode

Inside:

pwd
ls
cat /usr/share/nginx/html/index.html
Enter fullscreen mode Exit fullscreen mode

Exit:

exit
Enter fullscreen mode Exit fullscreen mode

Then:

docker inspect homework-test
Enter fullscreen mode Exit fullscreen mode

Find:

  • Image
  • Ports
  • Network
  • IP address

Stop and remove:

docker stop homework-test
docker rm homework-test
Enter fullscreen mode Exit fullscreen mode

PART 4 β€” Create Amazon ECR repository

Create your own ECR repository.

Name:

jumptotech-homework
Enter fullscreen mode Exit fullscreen mode

Verify it exists:

aws ecr describe-repositories \
--region us-east-1
Enter fullscreen mode Exit fullscreen mode

Find your AWS account ID:

aws sts get-caller-identity
Enter fullscreen mode Exit fullscreen mode

Your ECR URI will look like:

ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/jumptotech-homework
Enter fullscreen mode Exit fullscreen mode

PART 5 β€” Login to ECR

Authenticate Docker:

aws ecr get-login-password --region us-east-1 | \
docker login \
--username AWS \
--password-stdin \
ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

You should get:

Login Succeeded
Enter fullscreen mode Exit fullscreen mode

PART 6 β€” Build for EKS

⚠️ Students with Apple Silicon Macs must pay attention to architecture.

Check your EKS node architecture later with:

kubectl get nodes \
-o custom-columns="NODE:.metadata.name,ARCH:.status.nodeInfo.architecture"
Enter fullscreen mode Exit fullscreen mode

For standard AMD64 worker nodes, build:

docker buildx build \
--platform linux/amd64 \
-t ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/jumptotech-homework:v1 \
--push .
Enter fullscreen mode Exit fullscreen mode

Verify the image:

docker buildx imagetools inspect \
ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/jumptotech-homework:v1
Enter fullscreen mode Exit fullscreen mode

Find:

linux/amd64
Enter fullscreen mode Exit fullscreen mode

PART 7 β€” Connect to EKS

Find your cluster:

aws eks list-clusters --region us-east-1
Enter fullscreen mode Exit fullscreen mode

Connect:

aws eks update-kubeconfig \
--region us-east-1 \
--name YOUR_CLUSTER_NAME
Enter fullscreen mode Exit fullscreen mode

Test:

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

All worker nodes should show:

Ready
Enter fullscreen mode Exit fullscreen mode

PART 8 β€” Understand the Node Group

Run:

aws eks list-nodegroups \
--cluster-name YOUR_CLUSTER_NAME \
--region us-east-1
Enter fullscreen mode Exit fullscreen mode

Then:

kubectl get nodes -o wide
Enter fullscreen mode Exit fullscreen mode

Answer in your homework:

What is a Node Group?

What is a Node?

What runs on the Node?

Does a Deployment run directly on a Node?
Enter fullscreen mode Exit fullscreen mode

PART 9 β€” Create Deployment

Create:

deployment.yaml
Enter fullscreen mode Exit fullscreen mode

Requirements:

Deployment name:
homework-deployment

Replicas:
3

Pod label:
app=homework

Container name:
homework-container

Container port:
80

Image:
your ECR image :v1
Enter fullscreen mode Exit fullscreen mode

Do not copy an old Deployment blindly. Write the YAML yourself.

Apply:

kubectl apply -f deployment.yaml
Enter fullscreen mode Exit fullscreen mode

PART 10 β€” Verify Kubernetes

Run:

kubectl get deployments
Enter fullscreen mode Exit fullscreen mode

Then:

kubectl get rs
Enter fullscreen mode Exit fullscreen mode

Then:

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Then:

kubectl get pods -o wide
Enter fullscreen mode Exit fullscreen mode

All three Pods should eventually be:

1/1   Running
Enter fullscreen mode Exit fullscreen mode

PART 11 β€” Prove ownership

Pick one Pod:

kubectl describe pod POD_NAME
Enter fullscreen mode Exit fullscreen mode

Find:

Controlled By:
Enter fullscreen mode Exit fullscreen mode

It should show a ReplicaSet.

Then:

kubectl describe rs REPLICASET_NAME
Enter fullscreen mode Exit fullscreen mode

Find:

Controlled By:
Enter fullscreen mode Exit fullscreen mode

You should be able to prove:

Deployment
     ↓
ReplicaSet
     ↓
Pod
     ↓
Container
Enter fullscreen mode Exit fullscreen mode

Take a screenshot.


PART 12 β€” Troubleshoot your Pods

Check:

kubectl describe deployment homework-deployment
Enter fullscreen mode Exit fullscreen mode

Then:

kubectl describe pod POD_NAME
Enter fullscreen mode Exit fullscreen mode

Then:

kubectl logs POD_NAME
Enter fullscreen mode Exit fullscreen mode

Students must know when each command is useful.


PART 13 β€” Create Service

Create:

service.yaml
Enter fullscreen mode Exit fullscreen mode

Requirements:

Name:
homework-service

Type:
ClusterIP

Selector:
app=homework

Port:
80

TargetPort:
80
Enter fullscreen mode Exit fullscreen mode

Apply:

kubectl apply -f service.yaml
Enter fullscreen mode Exit fullscreen mode

Check:

kubectl get svc
Enter fullscreen mode Exit fullscreen mode

Then:

kubectl describe svc homework-service
Enter fullscreen mode Exit fullscreen mode

PART 14 β€” Prove Service found the Pods

Run:

kubectl get endpoints homework-service
Enter fullscreen mode Exit fullscreen mode

You should have backend endpoints corresponding to your Pods.

Also:

kubectl get pods -o wide
Enter fullscreen mode Exit fullscreen mode

Compare the Pod IP addresses.

Explain:

Service
selector app=homework
       ↓
+------+------+------+
|      |      |      |
↓      ↓      ↓
Pod 1  Pod 2  Pod 3
Enter fullscreen mode Exit fullscreen mode

PART 15 β€” Intentionally break the Service πŸ”₯

This is required.

Change:

selector:
  app: homework
Enter fullscreen mode Exit fullscreen mode

to something incorrect:

selector:
  app: wrong
Enter fullscreen mode Exit fullscreen mode

Apply:

kubectl apply -f service.yaml
Enter fullscreen mode Exit fullscreen mode

Now:

kubectl get endpoints homework-service
Enter fullscreen mode Exit fullscreen mode

Explain why the endpoints disappeared.

Then fix the selector and apply again.

This part must be demonstrated in your presentation.


PART 16 β€” Test without ALB

Before creating Ingress, prove that the application works.

Run:

kubectl port-forward \
service/homework-service \
8080:80
Enter fullscreen mode Exit fullscreen mode

Keep the terminal open.

Open:

http://localhost:8080
Enter fullscreen mode Exit fullscreen mode

You should see your application.

Traffic:

Browser
   ↓
localhost:8080
   ↓
kubectl port-forward
   ↓
Service
   ↓
Pod
   ↓
Container
Enter fullscreen mode Exit fullscreen mode

If port 8080 is busy:

lsof -i :8080
Enter fullscreen mode Exit fullscreen mode

Use another port, for example:

kubectl port-forward \
service/homework-service \
8081:80
Enter fullscreen mode Exit fullscreen mode

PART 17 β€” Check AWS Load Balancer Controller

Now move toward production-style internet access.

Check:

kubectl get deployment \
-n kube-system \
aws-load-balancer-controller
Enter fullscreen mode Exit fullscreen mode

Check:

kubectl get pods -n kube-system
Enter fullscreen mode Exit fullscreen mode

And:

kubectl get ingressclass
Enter fullscreen mode Exit fullscreen mode

You are looking for the ALB controller/IngressClass.

If the controller is not installed, document that finding rather than randomly installing commands from the internet. We will review controller installation and AWS permissions together if needed.


PART 18 β€” Create Ingress

If AWS Load Balancer Controller is correctly installed, create:

ingress.yaml
Enter fullscreen mode Exit fullscreen mode

Requirements:

Ingress name:
homework-ingress

Ingress class:
alb

Scheme:
internet-facing

Target type:
ip

Path:
/

Backend:
homework-service

Backend port:
80
Enter fullscreen mode Exit fullscreen mode

Apply:

kubectl apply -f ingress.yaml
Enter fullscreen mode Exit fullscreen mode

Check:

kubectl get ingress
Enter fullscreen mode Exit fullscreen mode

Then:

kubectl describe ingress homework-ingress
Enter fullscreen mode Exit fullscreen mode

PART 19 β€” Find the ALB

Watch:

kubectl get ingress -w
Enter fullscreen mode Exit fullscreen mode

When successfully provisioned, the ADDRESS field should eventually show an AWS load balancer hostname.

Then test that address in your browser.

Final runtime concept:

                 INTERNET
                     |
                     ↓
                   DNS
                     |
                     ↓
                 AWS ALB
                     |
             routing rules
                     |
                     ↓
             homework-service
                     |
          +----------+----------+
          ↓          ↓          ↓
        Pod 1      Pod 2      Pod 3
          ↓          ↓          ↓
      Container  Container  Container
Enter fullscreen mode Exit fullscreen mode

PART 20 β€” Understand Ingress vs Controller

Every student must explain this.

Ingress

Rules / desired configuration
Enter fullscreen mode Exit fullscreen mode

Example:

/      β†’ frontend-service
/api   β†’ api-service
/admin β†’ admin-service
Enter fullscreen mode Exit fullscreen mode

AWS Load Balancer Controller

Watches Kubernetes resources
        ↓
Calls AWS APIs
        ↓
Creates/configures AWS resources
        ↓
ALB
Listeners
Rules
Target Groups
Enter fullscreen mode Exit fullscreen mode

ALB

Receives actual HTTP/HTTPS requests
        ↓
Uses configured routing
        ↓
Sends traffic to appropriate backend
Enter fullscreen mode Exit fullscreen mode

Do not say:

User β†’ Controller β†’ Pod
Enter fullscreen mode Exit fullscreen mode

The Controller is not forwarding every customer request.


PART 21 β€” Troubleshooting challenge

If the website doesn't work, students must troubleshoot in this order:

kubectl get ingress
Enter fullscreen mode Exit fullscreen mode
kubectl describe ingress homework-ingress
Enter fullscreen mode Exit fullscreen mode
kubectl get svc
Enter fullscreen mode Exit fullscreen mode
kubectl describe svc homework-service
Enter fullscreen mode Exit fullscreen mode
kubectl get endpoints homework-service
Enter fullscreen mode Exit fullscreen mode
kubectl get pods -o wide
Enter fullscreen mode Exit fullscreen mode
kubectl describe pod POD_NAME
Enter fullscreen mode Exit fullscreen mode
kubectl logs POD_NAME
Enter fullscreen mode Exit fullscreen mode

And explain the logic:

Browser
   ↓
ALB available?
   ↓
Ingress configured?
   ↓
Service exists?
   ↓
Endpoints exist?
   ↓
Pods Ready?
   ↓
Correct targetPort?
   ↓
Container running?
   ↓
Application logs
Enter fullscreen mode Exit fullscreen mode

PART 22 β€” Scaling challenge

Start with:

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Scale from 3 Pods to 5:

kubectl scale deployment \
homework-deployment \
--replicas=5
Enter fullscreen mode Exit fullscreen mode

Watch:

kubectl get pods -w
Enter fullscreen mode Exit fullscreen mode

Then:

kubectl get endpoints homework-service
Enter fullscreen mode Exit fullscreen mode

Answer:

Did you manually tell the Service about the two new Pods?

No.

Why?

Because:

Service selector
app=homework
      ↓
automatically matches
      ↓
new Pods with app=homework
Enter fullscreen mode Exit fullscreen mode

PART 23 β€” Self-healing challenge πŸ”₯

Find a Pod:

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Delete one:

kubectl delete pod POD_NAME
Enter fullscreen mode Exit fullscreen mode

Immediately:

kubectl get pods -w
Enter fullscreen mode Exit fullscreen mode

Observe what Kubernetes does.

Explain:

Deployment wants 5
       ↓
One Pod deleted
       ↓
Only 4 remain
       ↓
ReplicaSet detects mismatch
       ↓
Creates replacement
       ↓
Back to 5
Enter fullscreen mode Exit fullscreen mode

This is desired state + reconciliation/self-healing.


PART 24 β€” Final cleanup

AWS resources cost money, so cleanup is part of the homework.

Delete Ingress first:

kubectl delete -f ingress.yaml
Enter fullscreen mode Exit fullscreen mode

Verify the associated ALB resources are being removed before deleting the rest.

Then:

kubectl delete -f service.yaml
kubectl delete -f deployment.yaml
Enter fullscreen mode Exit fullscreen mode

Check:

kubectl get ingress
kubectl get svc
kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Do not delete a shared class EKS cluster or Node Group unless instructed.


🎀 Monday presentation

Each student gets 5 minutes.

They must show one architecture diagram:

Code
 ↓
Dockerfile
 ↓
Image
 ↓
ECR
 ↓
EKS
 ↓
Deployment
 ↓
ReplicaSet
 ↓
Pods
 ↓
Service
 ↓
Ingress
 ↓
ALB
 ↓
Customer
Enter fullscreen mode Exit fullscreen mode

Then answer:

  1. What is the difference between Image and Container?
  2. Why do we push the image to ECR?
  3. What is a Node Group?
  4. What is a Deployment?
  5. What creates/manages the Pods for a Deployment?
  6. How can you find which ReplicaSet owns a Pod?
  7. Why shouldn't customers connect directly to Pod IPs?
  8. How does Service find its Pods?
  9. What are port and targetPort?
  10. What happens if the Service selector is wrong?
  11. What is Ingress?
  12. What is an Ingress Controller?
  13. Who configures/creates the ALB in this architecture?
  14. Who handles the actual HTTP request?
  15. What happens when a Pod dies?
  16. Why did some Apple Silicon users need --platform linux/amd64?
  17. What does ImagePullBackOff mean?
  18. What is the difference between kubectl get and kubectl describe?
  19. What does kubectl logs tell you?
  20. How would you troubleshoot if the website stopped working?

Homework is complete only when the student can explain the architecture

The goal is not just to make the browser open.

The student should be able to look at this:

ALB β†’ Service β†’ Pod
Enter fullscreen mode Exit fullscreen mode

and explain how the application got there from source code, where the image is stored, where the Pod runs, how Service discovers its backends, how Ingress/Controller configure external routing, and how they would troubleshoot each layer if something failed.

Top comments (0)