- Docker
- Helm
- Kubectl
- Minikube/k8s cluster
-
Build and Push application image
-
Build A docker image
cd app docker build -t userapi .
-
-
Push it to dockerhub or ECR
DOCKERHUB_USERNAME="vegito" REPO_IMAGE_NAME="${DOCKERHUB_USERNAME}/userapi" docker login --username $DOCKERHUB_USERNAME docker tag userapi ${REPO_IMAGE_NAME}:latest docker push ${REPO_IMAGE_NAME}:latest
-
Setup Mysql Db Using Helm Chart
helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update helm install my-mysql --values charts/mysql.yml bitnami/mysql
Test this mysql database using below command
$ MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default my-mysql -o jsonpath="{.data.mysql-root-password}" | base64 -d) $ kubectl run my-mysql-client --rm --tty -i --restart='Never' --image \ docker.io/bitnami/mysql:8.0.34-debian-11-r8 --namespace default \ --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash $ mysql -h my-mysql.default.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"
-
Create the table and insert a sample value
use userapi; CREATE TABLE IF NOT EXISTS users ( id INT AUTO_INCREMENT PRIMARY KEY, user_name VARCHAR(255) NOT NULL, user_email VARCHAR(255) NOT NULL, user_password VARCHAR(255) NOT NULL ); INSERT INTO users (user_name, user_email, user_password) VALUES ('John Doe', 'john.doe@example.com', 'secretpassword');
-
Deploy our app on the k8s using our app chart
cd charts/app helm upgrade --install userapi .
-
Test the application by creating new test pod
$ kubectl run --rm -it test --image nginx -- bash > curl http://userapi:5000 > curl http://userapi:5000/users
-
All Helm charts will be stored in a centralized Git repository for version control and collaboration.
-
CI/CD pipelines will automatically build Docker images for each application upon code changes, tagging them with the corresponding application version.
docker build -t userapi:0.1.0 . docker build -t userapi:2.2.0 .
-
The CI pipeline will update Helm charts with the new Docker image tags, ensuring up-to-date charts.
-
Upon successful CI pipeline runs, the CD pipeline will deploy the updated Helm charts to the target Kubernetes environment (e.g., staging, production).
$ helm upgrade --install userapi --set image.tag="0.1.0" . $ kubectl run --rm -it test1 --image nginx -- sh > curl http://userapi:5000 $ helm upgrade --install userapi --set image.tag="2.2.0" . $ kubectl run --rm -it test2 --image nginx -- sh > curl http://userapi:5000
-
Set up a Kubernetes cluster.
-
Install Helm on the Kubernetes cluster.
-
Create a Helm chart for the Flask app.
-
Configure the Helm chart with the necessary Kubernetes resources (e.g., Deployment, Service, Ingress).
-
Store the Helm chart in a Git repository.
-
Set up a CI/CD pipeline to build the Docker image of the Flask app on code changes.
-
Tag the Docker image with the appropriate version.
-
Update the Helm chart with the new Docker image tag.
-
Trigger the CD pipeline to deploy the updated Helm chart to the Kubernetes cluster.
-
Verify the deployment and application functionality.


