This repository contains a Helm chart for the application "ping", a Terraform module, and a GitHub workflow to deploy it.
-
Clone the Repository:
- Clone this repository to your local machine.
-
Configure the Workflow:
- Modify the
config.jsonfile to set the appropriate environment variables for your GCP project and GKE cluster.
- Modify the
-
Push to GitHub:
- Push the changes to your GitHub repository.
-
Add Secrets:
- Add the necessary secret
GCP_SA_KEYto your GitHub repository.
- Add the necessary secret
-
Trigger the Workflow:
- Push to the
mainbranch to trigger the GitHub Actions workflow and deploy the Helm chart to your GKE cluster.
- Push to the
NOTE: As part of Challenge 1, a preinstall hook that checks for random-service was added in templates/pre-install-check.yaml. You might want to delete that before testing.
The Helm chart for the "ping" application is configured to meet the following requirements:
- Node Affinity: Pods are scheduled to avoid specific node groups.
- Pod Anti-Affinity: Ensures that a pod will not be scheduled on a node that already has a pod of the same type.
- Topology Spread Constraints: Pods are deployed across different availability zones.
- Pre-Install Hook: Ensures that another random service is up before applying the manifests.
You can see the configuration for the first three in values.yaml(it was added to deployment.yaml in lines 30-35) For the 4th point i added a job in templates/pre-install-check.yaml, with the helm-hook pre-install that checks whether random-service exists
A Terraform module is provided to automate the process of creating a cluster, copying Helm charts from the reference Artifact Registry (reference.gcr.io) to an instance Artifact Registry (instance.gcr.io). The module:
- Creates an Artifact Registry repository if it does not already exist, and a GKE cluster.
- Uses a
null_resourcewith alocal-execprovisioner to copy the specified Helm charts from the reference registry to the instance registry.
A GitHub Actions workflow is set up to deploy the Helm chart to a GKE cluster. The workflow:
- Checks out the repository, sets up the Google Cloud SDK.
- Initializes and applies the Terraform module to copy the Helm charts.
- Deploys the Helm chart to the GKE cluster using Helm.