This repository contains the source code and configuration files for the "Task Management System" application, a PHP application with MySQL backend. The application is deployed on Google Kubernetes Engine (GKE) and uses Cloud SQL for the database. The repository is organized into multiple directories, each serving a specific purpose in the deployment and management of the application.
task-management-system/: Contains the source code of the Task Management System.k8s/: Kubernetes manifest files for each service.frontend-service/logout-service/users-service/ingress/: Manifests for ingress to navigate between service containers.mysql-job/: A Kubernetes job to connect to Cloud SQL and create tables for the application.
terraform/: Terraform configuration files for infrastructure as code..github/: GitHub workflows for Continuous Integration (CI) and Continuous Deployment (CD).
build.sh: Script to build and deploy the entire project.destroy.sh: Script to tear down the entire environment.github_secrets.sh: Script to automate storing secrets in GitHub Secrets.
- Google Cloud SDK
- Docker
- kubectl
- Terraform
- jq
- GitHub CLI (gh)
-
Clone the Repository
git clone https://github.com/johnbedeir/End-to-End-DevOps-GCP-Python-MySQL.git cd End-to-End-DevOps-GCP-Python-MySQL -
Set Up Google Cloud Credentials
Make sure you have the appropriate IAM roles and the service account key file.
-
Build and Deploy the Project
./build.sh
The build.sh script performs the following steps:
- Authenticate with Google Cloud.
- Delete existing service account keys.
- Create new service account keys.
- Initialize and apply Terraform configurations to set up GKE and other resources.
- Update kubeconfig to interact with the GKE cluster.
- Build Docker images for each service and push them to Google Container Registry (GCR).
- Create necessary Kubernetes secrets.
- Deploy Kubernetes manifests to the cluster.
- Output the URLs for various services (application, Prometheus, Grafana, etc.).
The destroy.sh script performs the following steps:
- Authenticate with Google Cloud.
- Delete Docker images from Google Container Registry.
- Destroy all GCP resources using Terraform.
The github_secrets.sh script performs the following steps:
- Delete existing service account keys.
- Create new service account keys.
- Base64 encode the credentials and environment variables.
- Store the encoded values as GitHub Secrets.
- CI Workflows: Defined for each service in
.github/workflows/service-ci-workflow. - CD Workflows: Defined for each service in
.github/workflows/service-cd-workflow.
The terraform/ directory contains Terraform configuration files to provision the following resources:
- Google Kubernetes Engine (GKE) cluster.
- Google Cloud SQL instance.
- Networking and IAM configurations.
The deployment process is managed using Kubernetes and involves the following steps:
- Deploy the frontend, logout, and users services.
- Set up ingress for routing traffic between service containers.
- Run the
mysql-jobto set up the database schema in Cloud SQL.
- Prometheus and Grafana are deployed for monitoring.
- ArgoCD are used for Continuous Deployment.
Secrets are managed using Kubernetes secrets and GitHub Secrets. The github_secrets.sh script automates the process of storing secrets in GitHub.
To clean up all resources, run the destroy.sh script:
./destroy.shAfter running the build.sh script, you can access the Task Management System application by navigating to the IP address provided in the output:
APP_URL: <Your_APP_URL>
To access Grafana, navigate to the URL provided in the output:
Grafana_URL: <Your_Grafana_URL>
- Login: Use the default username and password:
- Username:
admin - Password:
admin
- Username:
- Change Password: You will be prompted to create a new password or you can skip this step.
- Navigate to Dashboard: From the upper left corner, click on the Grafana icon and select "Dashboards".
- Select a Dashboard: Choose the preferred dashboard, for example, the Kubernetes/Kubelet Dashboard.
To access ArgoCD, navigate to the URL provided in the output:
ArgoCD_URL: <Your_ArgoCD_URL>
-
Login: Use the default username:
- Username:
admin
- Username:
-
Find the Password: The password is stored in a Kubernetes secret called
argocd-initial-admin-secret.How to retrieve the ArgoCD password: a. Open K9s in your terminal. b. Press
Ctrl+Ato navigate to the main menu. c. Press/to start a search. d. Typesecretsto search for secrets. e. Look for theargocd-initial-admin-secret. f. PressXto decode the secret and retrieve the password. -
Login to ArgoCD: Use the decoded password to log in.
-
Add Applications: Add each service as an application in ArgoCD using the GitHub Repository HTTP URL.



