This repository is needed for sample app deployments in GCP, that can be found here: gke-sample-app-deployment.
All of the code is based on official HashiCorp tutorial. You can use it to deploy: vpc & subnet, GKE cluster, GCR.
To do so:
- Clone this repository.
- Install Terraform (version: 0.15+).
- Install Google Cloud SDK
- Log in to your GCP project from command line (gcloud init)
- [Optional] Create terraform.auto.tfvars - add variable values for region, zone, project_id (you will be prompted to provide them if you won't create this file).
- Change backend configuration in terraform_config.tf - use your own Terraform Organisation and Workspace - if you don't want to use Terraform Cloud - change backend type to local. (if you do so, you will also have to amend code within gke-sample-app-deployment repository to get information about GKE clusters from different location than shared remote backend)
If you will use Terraform Cloud, open your terminal and log in:
terraform login
While creating namespace: make sure to set execution mode to local and select CLI-driven runs.
- Inside gke-infra/ folder run:
terraform init
terrafom plan
terrafom apply
-
Approve terraform apply and wait for around 10 mins for cluster to deploy.
-
Remember to remove your resources when you no longer need them with:
terraform destroy
This infrastructure will generate costs, check GCP documentation to learn more.
This infrastructure is only a demo, it does not contain production-ready environment. Currently GKE cluster is deployed in single zone.