The deploy-manager.sh
script automates the blue-green deployment process for your Kubernetes application.
./deploy-manager.sh deploy stable
This command:
- Builds Docker images with a random tag
- Deploys the MariaDB database
- Deploys the backend and frontend to Kubernetes in the stable environment
./deploy-manager.sh deploy beta
Similar to deploying stable, but creates a separate beta environment.
./deploy-manager.sh promote
Promotes the current beta deployment to stable.
./deploy-manager.sh teardown all
Removes all deployed resources (use beta
instead of all
to remove only beta resources).
- API Check: Open
http://localhost:<backend-port>/greeting
to verify the API. - Application Access: Open
http://localhost:<frontend-port>
to access the full application.
Note: The actual ports will be displayed in the script output after deployment.
-
Deploy Database Only:
./deploy-manager.sh deploy-db
Deploys only the MariaDB database.
-
Check Deployment Status:
./deploy-manager.sh status
Displays current status of all deployments, services, and access URLs.
-
Color-coded output for easy reading and error identification.
-
Detailed error messages and deployment information for troubleshooting.
-
Automatic image tagging for version control.
-
Environment variable inspection for both stable and beta deployments (performed during deployment).
The deployment process includes:
- Building backend and frontend Docker images with a random tag.
- Deploying the MariaDB database.
- Deploying the backend to Kubernetes with the generated tag.
- Deploying the frontend to Kubernetes with the generated tag.
- Displaying the deployment status of all components.
If you prefer step-by-step manual deployment, refer to the following section:
Follow these steps from your project root to deploy services locally:
-
Deploy the Database (MariaDB):
- Applies the MariaDB configuration.
kubectl apply -f ./deployments/local/db.yaml
-
Build and Tag Images:
- Builds and tags frontend and backend Docker images. Confirm with: "Build and tag completed." Also, ensure there are no errors, which will appear in RED.
.\build-images.sh
-
Deploy the Backend:
kubectl apply -f ./deployments/local/backend.yaml
-
Deploy the Frontend:
kubectl apply -f ./deployments/local/frontend.yaml
-
Verify Deployments:
- Checks deployment status. Expect all services to show as
1/1 READY
.
kubectl get deployments
-
You should see:
NAME READY UP-TO-DATE AVAILABLE b-g-backend 1/1 1 1 b-g-frontend 1/1 1 1 b-g-mariadb 1/1 1 1
- Checks deployment status. Expect all services to show as
To remove services, execute:
- Delete the Database (MariaDB) deployment:
kubectl delete -f ./deployments/local/db.yaml
- Delete the Backend deployment:
kubectl delete -f ./deployments/local/backend.yaml
- Delete the Frontend deployment:
kubectl delete -f ./deployments/local/frontend.yaml
For local connection instructions to MariaDB, see ./deployments/db-verification.sh.
-
Database Status Check:
./check-db.sh
Follow these steps for a detailed verification process:
-
Check Pod Status:
kubectl get pods # Wait until STATUS becomes Running otherwise investigate and troubleshoot.
-
Access Pod:
kubectl exec -it <REPLACE_WITH_POD_NAME> -- bash
Example:
kubectl exec -it mariadb-deployment-XXXXX -- bash
-
MySQL Connection:
mysql -u root -p
If you receive an error similar to following:
/bin/sh: 1: mysql: not found
, install the MySQL client:apt-get update apt-get install mysql-client
Enter
y
when prompted: "Do you want to continue? [Y/n]"Run the following again:
mysql -u root -p
-
Password Prompt:
Enter password: password
If the password fails, retry from step 3.
-
Test Commands:
SELECT NOW(); # Should return the current server timestamp
SHOW DATABASEs; # Lists all databases