This repos presents the necessary configuration to bootstrap a GKE private cluster, connect to it through bastion VM using Identity-Aware Proxy (IAP) TCP forwarding and deploy the Wundergraph Router using helm Chart.
The terraform code used too bootstrap the infrastructure is based on the Cloud Foundation Fabric
-
Initialize Git repo with submodules:
git clone --recurse-submodules REPO_URL
-
Create the GCP project using gcloud for example
export PROJECT_NAME=gke-autopilot-wunder && gcloud projects create $PROJECT_NAME
. -
Create the service account that would be used with terrafrom:
gcloud iam service-accounts create terraform --project=$PROJECT_NAME
gcloud iam service-accounts keys create terraform-private-key.json \
--iam-account=terraform@gke-autopilot-wunder.iam.gserviceaccount.com
- Enable billing account for project:
gcloud services enable cloudresourcemanager.googleapis.com --project $PROJECT_NAME
export ACCOUNT_ID=YOUR_ACCOUNT_ID && gcloud beta billing projects link $PROJECT_NAME --billing-account $ACCOUNT_ID`
- Set-up required roles for the service account:
export SERVICE_ACCOUNT_EMAIL=serviceAccount:[email protected]
./utils/roles.sh
-
Set-up the env variables:
-
using the generated key from step 2
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/terraform-private-key.json
-
set-up the google region:
export GOOGLE_REGION=europe-west1
and the zone for the bastion vm.export VM_ZONE=$GOOGLE_REGION-b
-
set up project id and region for terraform use:
export TF_VAR_project_id=$PROJECT_NAME export TF_VAR_region=$GOOGLE_REGION
-
-
Create terraform plan:
terraform init
-
Initialize terraform plan:
terraform plan -out terraplan --var-file=./envs/dev.tfvars
-
Validate and apply the plan:
terraform apply terraplan
-
Provison required tools for bastion vm using ansible:
cd ansible && ansible-playbook -v playbook.yaml
-
Run command to download the kubernetes cluster config:
gcloud container clusters get-credentials wundergaph-cluster --region $GOOGLE_REGION
-
Get the full ssh command that you need to launch each time to create the IAP proxy enabling communicating with GKE:
gcloud compute ssh mgmt --tunnel-through-iap --zone=$VM_ZONE --project=$PROJECT_NAME --dry-run -- -L 8888:localhost:8888 -N -q -f > connect.sh && chmod +x connect.sh && echo export HTTPS_PROXY=localhost:8888 >> connect.sh
Otherwise run directly
gcloud compute ssh mgmt --tunnel-through-iap --zone=$VM_ZONE --project=$PROJECT_NAME -- -L 8888:localhost:8888 -N -q -f
andexport HTTPS_PROXY=localhost:8888
-
Create the namespace for deploying the wundergraph router:
kubectl create namespace router
-
Finally, deploy the wundergraph router:
helm upgrade router --install --atomic --wait --namespace router ./router
Run Terrafrom commands:
terraform plan -destroy -out destroyplan --var-file=./envs/dev.tfvars terraform
apply destroyplan
Because of
GCP ISSUE
run gcloud compute network-endpoint-groups list
and for each NEG listed, run
gcloud compute network-endpoint-groups delete NAME --zone ZONE
and run again
terraform destroy
to delete the rest of the infrastructure.
Deploy two subgraphs for testing
helm upgrade employees --install --atomic --wait ./subgraphs/employees
helm upgrade family --install --atomic --wait ./subgraphs/family