https://github.com/harjot1singh/terraform-example
An example terraform + terragrunt repository. Features Google Kubernetes Engine, Google Cloud SQL, Google Cloud Proxy, NGINX.
https://github.com/harjot1singh/terraform-example
devops docker gke google-cloud-platform kubernetes terraform terragrunt
Last synced: 6 months ago
JSON representation
An example terraform + terragrunt repository. Features Google Kubernetes Engine, Google Cloud SQL, Google Cloud Proxy, NGINX.
- Host: GitHub
- URL: https://github.com/harjot1singh/terraform-example
- Owner: harjot1singh
- License: mit
- Created: 2020-07-23T17:06:29.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-31T14:00:54.000Z (about 5 years ago)
- Last Synced: 2025-04-05T19:54:08.881Z (6 months ago)
- Topics: devops, docker, gke, google-cloud-platform, kubernetes, terraform, terragrunt
- Language: HCL
- Homepage: http://harjot.me/blog/deploying-docker-containers-to-gke-using-terraform
- Size: 13.7 KB
- Stars: 11
- Watchers: 0
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terraform-example
This repository contains an example terraform + terragrunt configuration to deploy infrastructure declaratively as code.
View the accompanying blog post: http://harjot.me/blog/deploying-docker-containers-to-gke-using-terraform
The following prerequisites are required:
* Google Cloud Project per environment (development + production)
* Kubectl
* Terraform
* TerragruntThe following will be deployed by the repo:
* [Google Kubernetes Engine (GKE)](https://cloud.google.com/kubernetes-engine)
* Docker images onto Google Kubernetes Engine (`nginx`)
* A database provisioned by [Google Cloud SQL](https://cloud.google.com/sql)## Structure
All terraform files in `terraform`. Usually, this would sit alongside application code.
`terraform/modules` contain Terraform-only reusable module definitions.
`terraform/live/[env]` contain subfolders for each service/infrastructure, each containing a `terragrunt.hcl` which reference the aforementioned modules.
## Usage
`cd` into `terraform/live/[development] or [production]` depending on the environment you'd like to work with. You can run `terragrunt plan-all` or `terragrunt apply-all`.
## Production Tips
These will be implemented in the future.
* [x] [Use a Cloud Proxy Sidecar](https://cloud.google.com/sql/docs/postgres/connect-kubernetes-engine) to allow your applications to interact with Cloud SQL.
* [ ] Use an Ingress Controller instead of exposing each service as a `LoadBalancer`. This way you have one central point of entry. The Traefik controller is great.