This project demonstrates how to create a GKE Autopilot cluster. Resources created:
- VPC
- Subnet
- NAT
- GKE
-
Create a new project and select it.
-
Open Cloud Shell and ensure the var below is set, otherwise set it with
gcloud config set project
command
echo $GOOGLE_CLOUD_PROJECT
- Create a bucket to store your project's Terraform state
gsutil mb gs://$GOOGLE_CLOUD_PROJECT-tf-state
- Enable the necessary APIs
gcloud services enable cloudbuild.googleapis.com \
compute.googleapis.com \
container.googleapis.com \
cloudresourcemanager.googleapis.com \
containersecurity.googleapis.com
-
Go to IAM and add
Editor
. -
Clone this repo into the Cloud Shell VM
git clone https://github.com/sylvioneto/terraform_gcp.git
cd ./terraform_gcp/gke-autopilot
-
Find and replace
your-domain.com
by your own domain. -
Execute Terraform using Cloud Build
gcloud builds submit . --config cloudbuild.yaml
-
At this point your cluster and workloads ar up and running, please check it on GKE.
-
(Optional) In other to issue the managed certificate, add the Ingresses IPs to your DNS records, so that GKE will provision the certificate. (reference).
- Execute Terraform using Cloud Build
cd ./terraform_gcp/gke
gcloud builds submit . --config cloudbuild_destroy.yaml