-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(k8s): update terraform-gke example for Bonsai (#4000)
* Generate kubeconfig for GKE cluster In order to "one-shot" deploy the example a GKE cluster and our demo services, we need a kubeconfig. Because of #3475, a kubeconfig managed by Garden should be generated with elevated privileges. * Set hardcoded values to variables To improve comprehension and expose the values a user should set for a project at the top of the file, we set the hardcoded values of the Garden project file to variables. * Convert 0.12 modules to 0.13 * Specify Terraform one-shot deployments in docs The README previously assumed a cluster ready to work with. We change the instructions to assume no pre-existing cluster. * Simplify and atomize terraform Previously the GKE example was an all-in-one terraform file. I've chosen to make use of battle-tested GKE modules and split the terraform for easy comprehension.
- Loading branch information
1 parent
94c9d91
commit d4f3ef0
Showing
13 changed files
with
568 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
kind: Module | ||
kind: Build | ||
name: backend | ||
type: container | ||
|
||
--- | ||
|
||
kind: Deploy | ||
name: backend | ||
build: backend | ||
description: Backend service container | ||
type: container | ||
services: | ||
- name: backend | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
# Maps service:80 -> container:8080 | ||
servicePort: 80 | ||
ingresses: | ||
- path: /hello-backend | ||
port: http | ||
spec: | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
servicePort: 80 | ||
ingresses: | ||
- path: /hello-backend | ||
port: http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,43 @@ | ||
kind: Module | ||
kind: Build | ||
name: frontend | ||
type: container | ||
|
||
--- | ||
kind: Deploy | ||
name: frontend | ||
build: frontend | ||
description: Frontend service container | ||
type: container | ||
services: | ||
- name: frontend | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
healthCheck: | ||
httpGet: | ||
path: /hello-frontend | ||
port: http | ||
ingresses: | ||
- path: /hello-frontend | ||
port: http | ||
- path: /call-backend | ||
port: http | ||
dependencies: | ||
- backend | ||
tests: | ||
- name: unit | ||
args: [npm, test] | ||
- name: integ | ||
args: [npm, run, integ] | ||
dependencies: | ||
- frontend | ||
spec: | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
healthCheck: | ||
httpGet: | ||
path: /hello-frontend | ||
port: http | ||
ingresses: | ||
- path: /hello-frontend | ||
port: http | ||
- path: /call-backend | ||
port: http | ||
dependencies: | ||
- deploy.backend | ||
|
||
--- | ||
kind: Test | ||
name: frontend-unit | ||
build: frontend | ||
type: container | ||
spec: | ||
args: [npm, test] | ||
|
||
--- | ||
kind: Test | ||
name: frontend-integ | ||
build: frontend | ||
type: container | ||
spec: | ||
args: [npm, run, integ] | ||
dependencies: | ||
- deploy.backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,45 @@ | ||
kind: Project | ||
name: terraform-gke | ||
|
||
environments: | ||
- name: dev | ||
defaultNamespace: ${project.name}-${variables.userId} | ||
- name: prod | ||
defaultNamespace: ${project.name} | ||
production: true | ||
|
||
variables: | ||
# change these values to your own | ||
username: worldofgeese | ||
gcpProjectId: devrel-348008 | ||
gcpRegion: europe-north1 | ||
registryHostname: docker.io | ||
registryNamespace: worldofgeese | ||
terraformInitRoot: "./terraform/" | ||
userId: ${local.username} | ||
providers: | ||
- name: terraform | ||
# This must be set to indicate that there is a stack in the project root. | ||
initRoot: "." | ||
# This must be set to indicate that there is a stack in the terraform project folder. | ||
initRoot: "${var.terraformInitRoot}" | ||
autoApply: true | ||
# You can either uncomment and replace these with your own values, or provide the values in a | ||
# terraform.tfvars file in the project root. | ||
# variables: | ||
# gcp_project_id: garden-gke-tf-${var.userId} | ||
# gcp_region: europe-west1 | ||
allowDestroy: true | ||
# You can either uncomment and replace these with your own values, or provide the values in a | ||
# terraform.tfvars file in the project root. | ||
variables: | ||
project_id: ${var.gcpProjectId} | ||
region: ${var.gcpRegion} | ||
|
||
- name: kubernetes | ||
kubeconfig: ${providers.terraform.outputs.kubeconfig_path} | ||
context: gke | ||
defaultHostname: terraform-gke-${var.userId}.dev-2.sys.garden | ||
buildMode: kaniko | ||
kubeconfig: ${var.terraformInitRoot}/${providers.terraform.outputs.kubeconfig_path} | ||
context: ${providers.terraform.outputs.cluster_name} | ||
# any hostname that points to your cluster's ingress controller | ||
defaultHostname: ${var.userId}-gke.dev-1.sys.garden | ||
# Replace the below values as appropriate | ||
deploymentRegistry: | ||
hostname: eu.gcr.io # <- set this according to the region your cluster runs in | ||
namespace: garden-ci # <- set this to the project ID of the target cluster | ||
imagePullSecrets: | ||
# Make sure this matches the name and namespace of the imagePullSecret you've created | ||
# to authenticate with your registry (if needed) | ||
- name: gcr-config | ||
namespace: default | ||
hostname: ${variables.registryHostname} | ||
namespace: ${variables.registryNamespace} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.