Example showing how to integrate the Terraform kubernetes provider with a Google Kubernetes Engine cluster.
[[ `basename $PWD` != example-gke-k8s-service-lb ]] && cd example-gke-k8s-service-lb
- Install Terraform if it is not already installed (visit terraform.io for other distributions):
../terraform-install.sh
- Set the project, replace
YOUR_PROJECT
with your project ID:
PROJECT=YOUR_PROJECT
gcloud config set project ${PROJECT}
- Configure the environment for Terraform:
[[ $CLOUD_SHELL ]] || gcloud auth application-default login
export GOOGLE_PROJECT=$(gcloud config get-value project)
terraform init
terraform apply
- Wait for the load balancer to be provisioned:
./test.sh
- Verify response from load balancer:
curl http://$(terraform output load-balancer-ip)
- Get the cluster credentials and configure kubectl:
gcloud container clusters get-credentials $(terraform output cluster_name) --zone $(terraform output cluster_zone)
- Verify kubectl connectivity:
kubectl get pods -n staging
- Delete resources created by terraform:
terraform destroy