GCP-GKE ¶
Cluster.dev uses stack templates to generate users' projects in a desired cloud. GCP-GKE is a stack template that creates and provisions Kubernetes clusters in GCP cloud by means of Google Kubernetes Engine (GKE).
On this page you will find guidance on how to create a GKE cluster on GCP using one of the Cluster.dev prepared samples – the GCP-GKE stack template. Running the example code will have the following resources created:
-
VPC
-
GKE Kubernetes cluster with addons:
-
cert-manager
-
ingress-nginx
-
external-secrets (with GCP Secret Manager backend)
-
external-dns
-
argocd
-
Prerequisites ¶
- Terraform version >= 1.4
- GCP account and project
- GCloud CLI installed and configured with your GCP account
- kubectl installed
- Cluster.dev client installed
- Parent Domain
Before you begin ¶
-
Create or select a Google Cloud project:
gcloud projects create cdev-demo gcloud config set project cdev-demo
-
Enable Secret Manager:
gcloud services enable secretmanager.googleapis.com
Quick Start ¶
- Clone example project:
git clone https://github.com/shalb/cdev-gcp-gke.git cd examples/
- Update
project.yaml
:name: demo-project kind: Project backend: default variables: organization: my-organization project: cdev-demo region: us-west1 state_bucket_name: gke-demo-state state_bucket_prefix: demo
- Create GCP bucket for Terraform backend:
gcloud projects create cdev-demo gcloud config set project cdev-demo gsutil mb gs://gke-demo-state
- Edit variables in the example's files, if necessary.
- Run
cdev plan
- Run
cdev apply
-
Set up DNS delegation for subdomain by creating NS records for subdomain in parent domain. Run
cdev output
:Add records from name_server list.cdev output 12:58:52 [INFO] Printer: 'cluster.outputs', Output: domain = demo.gcp.cluster.dev. name_server = [ "ns-cloud-d1.googledomains.com.", "ns-cloud-d2.googledomains.com.", "ns-cloud-d3.googledomains.com.", "ns-cloud-d4.googledomains.com." ] region = us-west1
-
Authorize cdev/Terraform to interact with GCP via SDK:
gcloud auth application-default login
- Connect to GKE cluster:
gcloud components install gke-gcloud-auth-plugin gcloud container clusters get-credentials demo-cluster --zone us-west1-a --project cdev-demo
- Retrieve ArgoCD admin password,
install the ArgoCD CLI:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo