This repository is a solution of the Kubernetes Resume Challenge.
This project highlights proficiency in Kubernetes and containerization, demonstrating the ability to deploy, scale, and manage web applications efficiently in a K8s environment, underscoring cloud-native deployment skills.
- Docker & K8s CLI installed
- KodeKloud K8s Crash Course Completed
- AWS Account Setup
- Github Account Setup
- Ecommerce Application & DB Script Overview
- For testing purposes locally, i pulled/ran the MariaDB image as the database container in a docker network
docker run -d —network some-network —name mysql-service DB_USER=ecomuser —env DB_PASSWORD=ecompassword —env MARIADB_ROOT_PASSWORD=ecompassword -p 3306:3306 mariadb:latest
- I accessed the database container to run SQL statements--which creates a database in the database server
docker run -it --network some-network --rm mariadb mariadb -h mysql-service -u root -p
CREATE DATABASE ecomdb;
CREATE USER 'ecomuser'@'localhost' IDENTIFIED BY 'ecompassword';
GRANT ALL PRIVILEGES ON ecomdb.* TO 'ecomuser'@'localhost';
FLUSH PRIVILEGES;
exit
- Loaded data into the new database and queried the data
USE ecomdb;
CREATE TABLE products (id mediumint(8) unsigned NOT NULL auto_increment,Name varchar(255) default NULL,Price varchar(255) default NULL, ImageUrl varchar(255) default NULL,PRIMARY KEY (id)) AUTO_INCREMENT=1;
INSERT INTO products (Name,Price,ImageUrl) VALUES ("Laptop","100","c-1.png"),("Drone","200","c-2.png"),("VR","300","c-3.png"),("Tablet","50","c-5.png"),("Watch","90","c-6.png"),("Phone Covers","20","c-7.png"),("Phone","80","c-8.png"),("Laptop","150","c-4.png");
select * from ecomdb.products;
- I wrote a Dockerfile at the root of the Web Application
- I built a Docker image for the application and started the image in the same network as the database container
docker build -t ecom-web:v1 .
docker run -d —network some-network —name ecom-web -p 8080:80 ecom-web:v1
- Created a
.github/workflows/deploy.yml
file to build the Docker image and push it to Docker Hub
- Setup an AWS EKS cluster using Infrastructure As Code:Terraform
Deployed Website to Kubernetes and Exposed The Wesbite Using Kubernetes Deployment and Service Manifests
- Kubernetes Deployment and Service Manifests
- Outcome URL: http://a37a0662677084f048a9b0287d65371a-762690969.eu-north-1.elb.amazonaws.com/
- Added a dark theme CSS file and a simple feature toggle in the application code
- Created a ConfigMap named ecom-web-config with the data FEATURE_DARK_MODE=true.
- Outcome: Website Dark Mode
- Current number of running pods:
kubectl get pods
-
Using
kubectl scale deployment/ecom-web --replicas=6
to handle the increased load -
Observing the deployment scaling up with
kubectl get pods
- Modified web application’s code to include promotional banner
- Built a updated Docker image--
tomiwa97/ecom-web:v2
and pushed to DockerHub - Updated
ecom-web.yaml
with the new image version - Outcome:
kubectl rollout status deployment/ecom-web
- Executed
kubectl rollout undo deployment/ecom-web
to revert to the previous deployment state
- Added liveness and readiness probes to ecom-web.yml, targeting an endpoint/port in the application that confirms its operational status
- Updated deployment with the new configuration and tested probes
- Installed Kubernetes Metrics Server:
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
- Verify that the
metrics-server
deployment is running the desired number of pods:
- Created a HorizontalPodAutoscaler Manifest
- Apply HPA:
kubectl apply -f ecom-hpa.yml
- Using Kubectl Load Generator or Apache Bench to generate traffic and increase CPU load:
kubectl run -i --tty load-generator --rm --image=busybox:1.28 --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://a8a04786e58eb4c5e8c38676cc7d08eb-1285750877.eu-north-1.elb.amazonaws.com/; done"
kubectl run -i --rm --restart=Never --image=mocoso/apachebench apachebench-1 -- bash -c "ab -n 10000 -c 1000 http://a8a04786e58eb4c5e8c38676cc7d08eb-1285750877.eu-north-1.elb.amazonaws.com/"
- Defined Deployment, PersistentVolumeClaim, PersistentVolume and StorageClass for MariaDB Storage needs
- Defined Helm Charts for the application making deployment and management on Kubernetes clusters more efficient and scalable