- Overview
- Prerequisites
- Initial Steps
- Database Deployment
- Food Order App Deployment
- Food Order UI Deployment
- CI and CD with GitHub Actions
- Test the Food Order Application
- Food Order App Buid and Push to docker repository
- Food Order UI Buid and Push to docker repository
- Uninstall
- Verify Database and data
- Improvements
This repository contains a small test project called the 'Food Order Application,' written in GoLang, with a simple UI. It consists of the following main components:
- Food App UI: This component is Dockerized and runs as a container.
- Food Middleware Application: This component is Dockerized and runs as a container.
- MYSQL database: The database is also running as a container and includes a persistent volume (PV).
- Kubernetes Cluster: The project can be deployed on a Kubernetes cluster, such as AKS, EKS, or a test Minikube setup.
Following tools are required to install the Food Order System.
- Kubectl
- Kubernetes cluster(e.g Kubeconfig pointing to any cloud Kubernetes e.g EKS , GKS, AKS or minimuke etc)
- MYSQL client [optional]
- Helm command line tool.
Clone the foodorderingsystem
repository from GitHub to your local system, as shown below
git clone [email protected]:Mshahidtaj/foodorderingsystem.git
cd foodorderingsystem
All building and deployment tasks are encapsulated within a Makefile to facilitate straightforward administration, make help
command can be used show the available options, as shown below
make help
It will show the following commands menu
- Make sure, context is correctly set to desired kubenetes cluster.e.g
kubectl config current-context
- Install MYSQL Database as Container to the Kubernets
make deploy-mysql
Wait for the mysql pods, it should only take few seconds to get stablised. we can verify it by using the following command.
kubectl get pods -n mysql
- Create MYSQL database Secret for Food Order Application
make create-mysql-secret
make deploy-food-order-app
make deploy-food-order-ui
make start-food-order-app-ui
Open the browser using the url "http://localhost:8081", as shown below
[Optional, Only required if there is a new change in the code, which we want to deploy]
make build
This project implements a CI/CD (Continuous Integration/Continuous Deployment) pipeline using GitHub Actions. The pipeline is responsible for building and deploying the application's Docker containers.
The build-and-push.yml
workflow file in the .github/workflows
directory defines the CI/CD pipeline. This workflow is triggered on every push to the main
branch.
The workflow performs the following steps:
- Checks out the repository code.
- Sets up Docker Buildx for multi-platform builds.
- Logs in to the Docker registry using the provided Docker credentials.
- Builds and pushes the latest version of the app container.
- Generates a tag for the app container based on the branch or commit.
- Builds and pushes the tagged version of the app container.
- Builds and pushes the UI container.
[Optional, Only required if there is a new change in the code, which we want to deploy]
make build-food-order-app
make push-food-order-app
[Optional, Only required if there is a new change in the code, which we want to deploy]
make build-food-order-ui
make push-food-order-ui
make uninstall-food-system
make uninstall-mysql-db
- Get the dataabse password
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace mysql mysql -o jsonpath="{.data.mysql-root-password}" | base64 -d)
- Run a pod that you can use as a client:
kubectl run mysql-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mysql:8.0.33-debian-11-r17 --namespace mysql --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash
- To connect to primary service (read/write):
mysql -h mysql.mysql.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"
- Misc SQL commands
Show databasees;
use food-ordering;
show tables;
select * from menu;
select * from orders;
- Add continueos deployment feature to Kubernetes e.g using GitOPS stratetgy (tools Flux / Argocd)
- Add Ingress controller like
Nginx
& ingress resource forFood Order App UI
with TLS secret to supportHTTPS
- Consider Security features for UI ingress like putting WAF e.g Cloudflare , Azure WAF or AWS Sheild etc
- Add unit Test coverage