https://github.com/sylvioneto/gcp_mig
GCP - Regional Managed Instance Groups with Global Load Balancer.
https://github.com/sylvioneto/gcp_mig
gce gcp mig terraform
Last synced: about 1 month ago
JSON representation
GCP - Regional Managed Instance Groups with Global Load Balancer.
- Host: GitHub
- URL: https://github.com/sylvioneto/gcp_mig
- Owner: sylvioneto
- Created: 2021-01-23T22:11:49.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-15T19:48:51.000Z (12 months ago)
- Last Synced: 2025-05-01T14:58:34.814Z (5 months ago)
- Topics: gce, gcp, mig, terraform
- Language: HCL
- Homepage:
- Size: 93.8 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GCP - Managed Instance Groups with Global Load Balancer
This project demonstrates how to deploy a Global Load Balancer with two regional Managed Instance Groups as backends.
It deploys two Managed Instance Groups running NGINX. The USA group is located in us-east1, and the CANADA group in northamerica-northeast1.
After deploying it, you can hit the Load Balancer IP from different regions using VMs, and see how GCP is spliting the traffic, for example:
## Deploy
### Preparation (only first time)
```
# TF State bucket creation
gsutil mb gs://-tf-state# Set permissions
export PROJECT_ID=
PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format='value(projectNumber)')
MEMBER=serviceAccount:$PROJECT_NUMBER@cloudbuild.gserviceaccount.com
gcloud projects add-iam-policy-binding $PROJECT_ID --member=$MEMBER --role=roles/editorMEMBER=serviceAccount:$PROJECT_NUMBER-compute@developer.gserviceaccount.com
gcloud projects add-iam-policy-binding $PROJECT_ID --member=$MEMBER --role=roles/editor# Enable APIs
gcloud services enable compute.googleapis.com \
cloudresourcemanager.googleapis.com \
iam.googleapis.com \
logging.googleapis.com \
--project $PROJECT_ID
```### Deploy
```
gcloud builds submit . --config build/cloudbuild.yaml
```### Destroy
```
gcloud builds submit . --config build/cloudbuild_destroy.yaml
```