This tutorial will walk you through setting up a Google Kubernetes Engine (GKE) Cluster with ArgoCD pre-installed, utilizing Terraform, in less than 10 minutes. This will be a great starting point to manage your cluster entirely through GitOps.
Prerequisites
GCP account with permissions to provision a GKE Cluster
To authenticate GCP with GitLab, create a GCP service account with the following roles: Compute Network Viewer, Kubernetes Engine Admin, Service Account User, and Service Account Admin. Both User and Admin service accounts are necessary. The User role impersonates the default service account when creating the node pool. The Admin role creates a service account in the kube-system namespace.
Download the JSON file with the service account key you created in the previous step.
On your computer, encode the JSON file to base64 (replace /path/to/sa-key.json to the path to your key):
base64 -i /path/to/sa-key.json
Use the output of this command as the BASE64_GOOGLE_CREDENTIALS environment variable in the next step.
On the left sidebar, select Settings > CI/CD. Expand Variables.
5. Set the variable BASE64_GOOGLE_CREDENTIALS to the base64 encoded JSON file you just created.
6. Set the variable TF_VAR_gcp_project to your GCP’s project name.
Run GitLab CI to deploy your Kubernetes cluster with ArgoCD Installed.
Connect to your GKE Cluster through your terminal using the following bash command.