Set Up Kubernetes Deployment¶
| Category | System Design & Kubernetes |
| Status | ✅ Completed |
| Repo | nextwork-set-up-kubernetes-deployment |
| 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 Set Up Kubernetes Deployment guide. It is part of my Learning portfolio and is fully separate from my production projects.
Category: Learning › System Design & Kubernetes
Status: ✅ Completed
Overview¶
Project 2 of the Kubernetes x AWS series: get a backend ready to deploy. The backend is a Flask + flask-restx API that searches Hacker News for a topic. I built it into a hardened container image (non-root, pinned deps), tested it, and pushed it to a registry, using a local registry:2 container in place of Amazon ECR.
Summary¶
I created a real Amazon ECR repository, built the Flask backend image, pushed it (latest, about 28.7 MB), and pulled it into a live EKS cluster where 3 replicas ran from it. The ECR repository, its images and the cluster were deleted right after.
The checks behind this are in docs/verification.txt.
Skills & tools¶
Docker, Container images, Container registries, Amazon ECR (CLI), Flask, flask-restx, Python, Kubernetes prep
What I built¶
backend/: Flask + flask-restx API withGET /contents/<topic>(Hacker News search through the Algolia API) andGET /healthz.backend/Dockerfile: Python 3.12 alpine image that runs as a non-root user.push-image.sh: build, tag, and push to a local registry atlocalhost:5050, mirroring thedocker taganddocker pushflow from ECR.ecr-commands.md: the exact AWS commands for real ECR (create repository with scan-on-push, log in, tag, push).
How to run¶
./push-image.sh # builds, runs a smoke test, pushes to localhost:5050
ecr-commands.md for the Amazon ECR equivalent.
Verification¶
I ran the verification command on 2026-12-02. The full output is in docs/verification.txt.
./push-image.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. The push used aws ecr get-login-password | docker login, and I logged Docker out of the registry afterwards.
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
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/ca1e2f05-dd07-5e77-b83c-1e6a6516944c · Part of my NextWork Learning portfolio (hub).
Verification output¶
From docs/verification.txt:
$ ./push-image.sh
sha256:c005e11d662f6e7747ef3789b476dbdd7832045c82b09dc474f3501c69954a64
Smoke test:
{"status": "ok"}
GET /contents/kubernetes -> 20 stories
localhost:5050/nextwork-flask-backend:latest
Registry catalog:
{"repositories":["nextwork-flask-backend"]}
{"name":"nextwork-flask-backend","tags":["latest"]}
PASS: image built, tested and pushed
Unable to find image 'registry:2' locally
2: Pulling from library/registry
44cf07d57ee4: Pulling fs layer
bbbdd6c6894b: Pulling fs layer
8e82f80af0de: Pulling fs layer
3493bf46cdec: Pulling fs layer
6d464ea18732: Pulling fs layer
3493bf46cdec: Waiting
6d464ea18732: Waiting
bbbdd6c6894b: Verifying Checksum
bbbdd6c6894b: Download complete
44cf07d57ee4: Verifying Checksum
44cf07d57ee4: Download complete
8e82f80af0de: Verifying Checksum
8e82f80af0de: Download complete
3493bf46cdec: Verifying Checksum
3493bf46cdec: Download complete
6d464ea18732: Verifying Checksum
6d464ea18732: Download complete
44cf07d57ee4: Pull complete
bbbdd6c6894b: Pull complete
8e82f80af0de: Pull complete
3493bf46cdec: Pull complete
6d464ea18732: Pull complete
Digest: sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373
Status: Downloaded newer image for registry:2
[exit code 0]