Skip to content

TomiwaAribisala-git/kubernetes-resume-challenge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Prerequisites

  • Docker & K8s CLI installed
  • KodeKloud K8s Crash Course Completed
  • AWS Account Setup
  • Github Account Setup
  • Ecommerce Application & DB Script Overview

Database Containerization & Web Application Containerization(Local Testing using Docker Desktop)

  • 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

Implement CI(Continuous Integration)

Setup Kubernetes Cluster on AWS

Deployed Website to Kubernetes and Exposed The Wesbite Using Kubernetes Deployment and Service Manifests

Implement Configuration Management

Autoscale the application; preparing for a marketing campaign

  • Current number of running pods: kubectl get 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

kubectl get pods

Performing a Rolling Update

  • 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

Rollout-Update

Wesbite-Rollout-Update

Rolling Back Deployment

  • Executed kubectl rollout undo deployment/ecom-web to revert to the previous deployment state

Rollback-Update

Wesbite-Rollback-Update

Implement Liveness and Readiness Probes for the Application

  • 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

Update Deployment

Autoscaling the application based on CPU usage to handle unpredictable traffic spikes

  • Installed Kubernetes Metrics Server: kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

Metrics Server

  • Verify that the metrics-server deployment is running the desired number of pods:

Metrics

Apply HPA

Apply HPA

  • 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/"

Observe HPA

Observe Pods

Implement Persistent Storage

Helm Charts

  • Defined Helm Charts for the application making deployment and management on Kubernetes clusters more efficient and scalable

About

Kubernetes Resume Challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • SCSS 48.0%
  • CSS 30.8%
  • PHP 14.6%
  • JavaScript 3.6%
  • HCL 2.6%
  • Dockerfile 0.4%