https://github.com/neilkuan/tf-gke-k8s-service-lb
tf-gke-k8s-service-lb
https://github.com/neilkuan/tf-gke-k8s-service-lb
Last synced: about 2 months ago
JSON representation
tf-gke-k8s-service-lb
- Host: GitHub
- URL: https://github.com/neilkuan/tf-gke-k8s-service-lb
- Owner: neilkuan
- Created: 2021-06-18T07:49:04.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-18T07:51:58.000Z (almost 4 years ago)
- Last Synced: 2025-03-29T02:38:27.771Z (2 months ago)
- Language: HCL
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kubernetes Engine Example
Example showing how to integrate the Terraform kubernetes provider with a Google Kubernetes Engine cluster.
[](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/terraform-google-examples&working_dir=example-gke-k8s-service-lb&page=shell&tutorial=README.md)
## 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](https://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}
```2. 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
```2. 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)
```2. Verify kubectl connectivity:
```
kubectl get pods -n staging
```## Cleanup
1. Delete resources created by terraform:
```
terraform destroy
```