Skip to content

Files

Failed to load latest commit information.

Latest commit

 Cannot retrieve latest commit at this time.

History

History
 
 

example-gke-k8s-service-lb

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Kubernetes Engine Example

Example showing how to integrate the Terraform kubernetes provider with a Google Kubernetes Engine cluster.

button

Change to the example directory

[[ `basename $PWD` != example-gke-k8s-service-lb ]] && cd example-gke-k8s-service-lb

Install Terraform

  1. Install Terraform if it is not already installed (visit terraform.io for other distributions):
../terraform-install.sh

Set up the environment

  1. Set the project, replace YOUR_PROJECT with your project ID:
PROJECT=YOUR_PROJECT
gcloud config set project ${PROJECT}
  1. Configure the environment for Terraform:
[[ $CLOUD_SHELL ]] || gcloud auth application-default login
export GOOGLE_PROJECT=$(gcloud config get-value project)

Run Terraform

terraform init
terraform apply

Testing

  1. Wait for the load balancer to be provisioned:
./test.sh
  1. Verify response from load balancer:
curl http://$(terraform output load-balancer-ip)

Connecting with kubectl

  1. Get the cluster credentials and configure kubectl:
gcloud container clusters get-credentials $(terraform output cluster_name) --zone $(terraform output cluster_zone)
  1. Verify kubectl connectivity:
kubectl get pods -n staging

Cleanup

  1. Delete resources created by terraform:
terraform destroy