Skip to content

Deploy Backend with Kubernetes

Category System Design & Kubernetes
Status ✅ Completed
Repo nextwork-deploy-backend-with-kubernetes
Original NextWork guide nextwork.ai

Learning project

Practice work following a NextWork guide, separate from my production projects.

📚 NextWork learning project. This is a practice project I built while working through NextWork's Deploy Backend with Kubernetes guide. It is part of my Learning portfolio and is fully separate from my production projects.

Category: Learning › System Design & Kubernetes
Status: ✅ Completed

Overview

This is the series finale: cluster → image → registry → manifests → kubectl apply → reach the app. I ran the whole pipeline locally. The secret mission (verify the deployment) was done from the CLI: rollout status, pods spread across nodes, and a live request through the NodePort.

Summary

I deployed the backend to a real Amazon EKS cluster from Amazon ECR: 3/3 replicas across 3 nodes behind a NodePort Service. /healthz returned ok, and /contents/aws returned 17 Hacker News stories through the Service. When I terminated a node, EKS replaced it and the Deployment went back to 3/3. Everything (Service, cluster, node group, ECR) was deleted right after.

The checks behind this are in docs/verification.txt.

Skills & tools

Kubernetes, kubectl apply, Deployments, NodePort Services, kind, Docker, Self-healing, Amazon EKS (concepts)

What I built

  • backend/: containerized Flask backend (my re-implementation of the guide's app).
  • k8s/flask-deployment.yaml and k8s/flask-service.yaml: the manifests.
  • deploy.sh: builds the image, loads it into kind (standing in for an ECR pull), applies the manifests, waits for the rollout, calls /contents/<topic> through the Service, deletes a pod to show self-healing, then cleans up.

How to run

./ensure-cluster.sh && ./deploy.sh

Verification

I ran the verification command on 2026-12-02. The full output is in docs/verification.txt.

./ensure-cluster.sh && ./deploy.sh

Real AWS deployment (2026-12-02)

I ran one short-lived Amazon EKS session (us-east-1) for the whole four-part Kubernetes x AWS series. I created the cluster once with eksctl, used it for all four parts, and deleted it right after. The ledger records it as a single entry. To keep costs down I didn't pin a version (eksctl picked Kubernetes 1.37, which is in standard support; versions in extended support cost 6x more for the control plane), disabled the NAT Gateway (nodes sit in public subnets), and used 3x t3.small nodes. I ran eksctl, kubectl, docker and the AWS CLI from my own Linux box, where the guide uses an EC2 instance as the control machine. I reached the Service with kubectl port-forward, so the NodePort was never opened to the internet in the node security group.

Evidence (excerpt; the full, sanitized transcript is in docs/aws-real-run.txt, with the account ID redacted):

=== REAL AWS RUN: one short-lived EKS session shared by the 4-part Kubernetes x AWS series, 2026-12-02, us-east-1 ===
(the cluster was created once, used for all four parts, then deleted; account ID redacted)

##### 1) launch-a-kubernetes-cluster: eksctl create cluster (21:07:41 CST)
$ eksctl create cluster -f eksctl-cluster.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: nextwork-eks-cluster
  region: us-east-1
  tags: {Project: nextwork-launch-a-kubernetes-cluster}
vpc:
  nat: {gateway: Disable}        # no NAT Gateway (hourly fee): nodes live in public subnets
managedNodeGroups:
  - name: nextwork-nodegroup
    instanceType: t3.small       # t3.micro only fits 4 pods per node on EKS
    desiredCapacity: 3
    tags: {Project: nextwork-launch-a-kubernetes-cluster}
2026-12-02 21:24:05 [ℹ]  no tasks
2026-12-02 21:24:05 [✔]  all EKS cluster resources for "nextwork-eks-cluster" have been created
2026-12-02 21:24:05 [ℹ]  nodegroup "nextwork-nodegroup" has 3 node(s)
2026-12-02 21:24:05 [ℹ]  node "ip-192-168-16-31.ec2.internal" is ready
2026-12-02 21:24:05 [ℹ]  node "ip-192-168-4-158.ec2.internal" is ready
2026-12-02 21:24:05 [ℹ]  node "ip-192-168-59-56.ec2.internal" is ready
2026-12-02 21:24:05 [ℹ]  nodegroup "nextwork-nodegroup" has 3 node(s)
2026-12-02 21:24:05 [ℹ]  node "ip-192-168-16-31.ec2.internal" is ready
2026-12-02 21:24:05 [ℹ]  node "ip-192-168-4-158.ec2.internal" is ready
2026-12-02 21:24:05 [ℹ]  node "ip-192-168-59-56.ec2.internal" is ready
2026-12-02 21:24:05 [✔]  created 1 managed nodegroup(s) in cluster "nextwork-eks-cluster"
2026-12-02 21:24:05 [ℹ]  creating addon: metrics-server
2026-12-02 21:24:06 [ℹ]  successfully created addon: metrics-server
2026-12-02 21:24:07 [ℹ]  kubectl command should work with "/tmp/eks-kubeconfig", try 'kubectl --kubeconfig=/tmp/eks-kubeconfig get nodes'
2026-12-02 21:24:07 [✔]  EKS cluster "nextwork-eks-cluster" in "us-east-1" region is ready
$ kubectl get nodes -o wide
NAME                            STATUS   ROLES    AGE     VERSION               INTERNAL-IP     EXTERNAL-IP     OS-IMAGE                        KERNEL-VERSION                            CONTAINER-RUNTIME
ip-192-168-16-31.ec2.internal   Ready    <none>   2m48s   v1.37.1-eks-9adbfea   192.168.16.31   13.220.172.95   Amazon Linux 2023.12.20261118   6.18.62-127.179.amzn2023.x86_64 (amd64)   containerd://2.3.7+unknown
ip-192-168-4-158.ec2.internal   Ready    <none>   2m16s   v1.37.1-eks-9adbfea   192.168.4.158   18.210.12.119   Amazon Linux 2023.12.20261118   6.18.62-127.179.amzn2023.x86_64 (amd64)   containerd://2.3.7+unknown
ip-192-168-59-56.ec2.internal   Ready    <none>   2m45s   v1.37.1-eks-9adbfea   192.168.59.56   44.223.48.201   Amazon Linux 2023.12.20261118   6.18.62-127.179.amzn2023.x86_64 (amd64)   containerd://2.3.7+unknown
$ aws eks describe-cluster
1.37    ACTIVE  eks.9

##### 2) set-up-kubernetes-deployment: build the Flask backend image and push it to Amazon ECR (21:24:10 CST)
$ aws ecr create-repository --repository-name nextwork-flask-backend
<ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/nextwork-flask-backend
Login Succeeded
sha256:8b4888299b6469e9969f6ffa0016667a752fd38f46a0b739b6b70cc1156bb4d6
c55c05421254: Pushed
latest: digest: sha256:e750eb2f01eb520ee9e900278f5fef476ad66344c6507339fa1ff171e76f1dc4 size: 2196
$ aws ecr describe-images --repository-name nextwork-flask-backend
latest  28708882    2026-12-02T21:24:24.215000-06:00

##### 4) deploy-backend-with-kubernetes: apply, roll out, call the backend (21:24:26 CST)
$ kubectl apply -f k8s/
deployment.apps/nextwork-flask-backend created
service/nextwork-flask-backend created
Waiting for deployment "nextwork-flask-backend" rollout to finish: 0 of 3 updated replicas are available...
Waiting for deployment "nextwork-flask-backend" rollout to finish: 1 of 3 updated replicas are available...
Waiting for deployment "nextwork-flask-backend" rollout to finish: 2 of 3 updated replicas are available...
deployment "nextwork-flask-backend" successfully rolled out
$ kubectl get deploy,svc,pods -o wide
NAME                                     READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS               IMAGES                                                                       SELECTOR
deployment.apps/nextwork-flask-backend   3/3     3            3           11s   nextwork-flask-backend   <ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/nextwork-flask-backend:latest   app=nextwork-flask-backend

NAME                             TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE     SELECTOR
service/kubernetes               ClusterIP   10.100.0.1      <none>        443/TCP          9m15s   <none>
service/nextwork-flask-backend   NodePort    10.100.235.87   <none>        8080:30876/TCP   11s     app=nextwork-flask-backend

NAME                                          READY   STATUS    RESTARTS   AGE   IP               NODE                            NOMINATED NODE   READINESS GATES
pod/nextwork-flask-backend-54bc76bb66-dfcnk   1/1     Running   0          11s   192.168.4.159    ip-192-168-4-158.ec2.internal   <none>           <none>
pod/nextwork-flask-backend-54bc76bb66-l62xs   1/1     Running   0          11s   192.168.51.225   ip-192-168-59-56.ec2.internal   <none>           <none>
... (full output in docs/aws-real-run.txt)

Teardown

The EKS session ran from 21:07 to 21:39 CST on 2026-12-02. eksctl delete cluster --wait removed the node group, the cluster and their CloudFormation stacks (VPC included), and the ECR repository was force-deleted with its images:

##### TEARDOWN (21:27:28 CST)
deployment.apps "nextwork-flask-backend" deleted
service "nextwork-flask-backend" deleted
$ eksctl delete cluster --name nextwork-eks-cluster --region us-east-1 --wait
2026-12-02 21:27:31 [✔]  kubeconfig has been updated
2026-12-02 21:27:31 [ℹ]  cleaning up AWS load balancers created by Kubernetes objects of Kind Service, Ingress, or Gateway
2026-12-02 21:27:32 [ℹ]  
2 sequential tasks: { delete nodegroup "nextwork-nodegroup", delete cluster control plane "nextwork-eks-cluster" 
}
2026-12-02 21:27:32 [ℹ]  will delete stack "eksctl-nextwork-eks-cluster-nodegroup-nextwork-nodegroup"
2026-12-02 21:36:36 [ℹ]  will delete stack "eksctl-nextwork-eks-cluster-cluster"
2026-12-02 21:38:58 [✔]  all cluster resources were deleted
$ aws ecr delete-repository --repository-name nextwork-flask-backend --force
nextwork-flask-backend
$ verify: eks clusters / cfn stacks / ecr repos / tagged instances (should be empty)

##### teardown verified (21:39:07 CST)

Cost

Estimated cost of the whole EKS session, shared by the four projects: about $0.20 (a conservative estimate) (EKS control plane $0.10/hr, 3x t3.small at about $0.02/hr each, EBS and public IPv4 for well under an hour; ECR storage for minutes). The account has a $50/month budget with email alerts at $5, $20 and $40, and the whole AWS series is logged in a private spend ledger.


Original project: https://nextwork.ai/projects/090a4709-f1f4-5d95-ae4d-b8199bf808ed · Part of my NextWork Learning portfolio (hub).

Verification output

From docs/verification.txt:

$ ./ensure-cluster.sh && ./deploy.sh

sha256:c005e11d662f6e7747ef3789b476dbdd7832045c82b09dc474f3501c69954a64
deployment.apps/nextwork-flask-backend created
service/nextwork-flask-backend created
Waiting for deployment "nextwork-flask-backend" rollout to finish: 0 of 3 updated replicas are available...
Waiting for deployment "nextwork-flask-backend" rollout to finish: 1 of 3 updated replicas are available...
Waiting for deployment "nextwork-flask-backend" rollout to finish: 2 of 3 updated replicas are available...
deployment "nextwork-flask-backend" successfully rolled out
NAME                                     READY   STATUS        RESTARTS   AGE   IP           NODE                           NOMINATED NODE   READINESS GATES
nextwork-flask-backend-b76668fbc-6z9f8   1/1     Terminating   0          26s   10.244.2.2   nextwork-eks-cluster-worker    <none>           <none>
nextwork-flask-backend-b76668fbc-95xb6   1/1     Running       0          5s    10.244.3.3   nextwork-eks-cluster-worker3   <none>           <none>
nextwork-flask-backend-b76668fbc-9lz5v   1/1     Running       0          5s    10.244.1.3   nextwork-eks-cluster-worker2   <none>           <none>
nextwork-flask-backend-b76668fbc-b6nq6   1/1     Running       0          5s    10.244.2.4   nextwork-eks-cluster-worker    <none>           <none>
nextwork-flask-backend-b76668fbc-fns7z   1/1     Terminating   0          19s   10.244.2.3   nextwork-eks-cluster-worker    <none>           <none>
nextwork-flask-backend-b76668fbc-lwjx9   1/1     Terminating   0          26s   10.244.1.2   nextwork-eks-cluster-worker2   <none>           <none>
nextwork-flask-backend-b76668fbc-xmm49   1/1     Terminating   0          26s   10.244.3.2   nextwork-eks-cluster-worker3   <none>           <none>
NAME                     TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
nextwork-flask-backend   NodePort   10.96.111.246   <none>        8080:31373/TCP   6s
Calling the backend through NodePort: http://172.22.0.2:31373/contents/aws
{"outcome":[{"id":"45640838","title":"AWS multiple services outage in us-east-1","url":"https://health.aws.amazon.com/health/status?ts=20251020"},{"id":"44972151","title":"AWS CEO says using AI to replace junior staff is 'Dumbest thing I've ever heard'","url":"https://www.theregister.com/2025/08/21/
stories: 17
Self-healing: deleting one pod
pod "nextwork-flask-backend-b76668fbc-6z9f8" deleted
deployment "nextwork-flask-backend" successfully rolled out
PASS: backend deployed, reachable via NodePort, self-healed to 3/3
Set kubectl context to "kind-nextwork-eks-cluster"
Image: "nextwork-flask-backend:latest" with ID "sha256:c005e11d662f6e7747ef3789b476dbdd7832045c82b09dc474f3501c69954a64" found to be already present on all nodes.

[exit code 0]