From 2b7d55039a55bb2c557bbb978b3cd9af9f6feaea Mon Sep 17 00:00:00 2001 From: Will Ripley <wripley@google.com> Date: Mon, 15 Jul 2019 07:06:38 -0700 Subject: [PATCH 1/8] Upgraded demo to use TF 0.12 --- Jenkinsfile | 2 +- terraform/main.tf | 18 ++++++++++-------- terraform/provider.tf | 6 +++--- terraform/variables.tf | 6 +++--- terraform/versions.tf | 4 ++++ 5 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 terraform/versions.tf diff --git a/Jenkinsfile b/Jenkinsfile index 314c153..7aa673e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,7 +35,7 @@ metadata: spec: containers: - name: ${containerName} - image: gcr.io/pso-helmsman-cicd/jenkins-k8s-node:${env.CONTAINER_VERSION} + image: gcr.io/pso-helmsman-cicd/jenkins-k8s-node:jenkins-cicd_images_builder-185 command: ['cat'] tty: true volumeMounts: diff --git a/terraform/main.tf b/terraform/main.tf index d6c6433..32c8bda 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -14,12 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ - // Provides access to available Google Container Engine versions in a zone for a given project. // https://www.terraform.io/docs/providers/google/d/google_container_engine_versions.html data "google_container_engine_versions" "on-prem" { - zone = "${var.zone}" - project = "${var.project}" + zone = var.zone + project = var.project } // https://www.terraform.io/docs/providers/google/d/google_container_cluster.html @@ -28,9 +27,9 @@ data "google_container_engine_versions" "on-prem" { // Create the GKE Cluster resource "google_container_cluster" "primary" { name = "tracing-demo-space" - zone = "${var.zone}" + zone = var.zone initial_node_count = 1 - min_master_version = "${data.google_container_engine_versions.on-prem.latest_master_version}" + min_master_version = data.google_container_engine_versions.on-prem.latest_master_version // Scopes were a pre-IAM method of giving instances API access // They are still around we need to give our cluster nodes @@ -46,6 +45,8 @@ resource "google_container_cluster" "primary" { ] } + // Here we use gcloud to gather authentication information about our new cluster and write that + // information to kubectls config file // Here we use gcloud to gather authentication information about our new cluster and write that // information to kubectls config file provisioner "local-exec" { @@ -62,13 +63,14 @@ resource "google_pubsub_topic" "tracing-demo-topic" { // You need a subscription to pull messages from a topic resource "google_pubsub_subscription" "tracing-demo-subscription" { name = "tracing-demo-cli" - topic = "${google_pubsub_topic.tracing-demo-topic.name}" + topic = google_pubsub_topic.tracing-demo-topic.name } output "cluster_name" { - value = "${google_container_cluster.primary.name}" + value = google_container_cluster.primary.name } output "primary_zone" { - value = "${google_container_cluster.primary.zone}" + value = google_container_cluster.primary.zone } + diff --git a/terraform/provider.tf b/terraform/provider.tf index 43dd0a3..551f471 100644 --- a/terraform/provider.tf +++ b/terraform/provider.tf @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ - // Identifies allowable version range for Terraform Google Provider provider "google" { - project = "${var.project}" - version = "~> 1.13" + project = var.project + version = "~> 2.5" } + diff --git a/terraform/variables.tf b/terraform/variables.tf index d733a06..f3d9e8c 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ - variable "zone" { description = "The zone in which to create the Kubernetes cluster. Must match the region" - type = "string" + type = string } variable "project" { description = "the project for this network" - type = "string" + type = string } + diff --git a/terraform/versions.tf b/terraform/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/terraform/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} From 9fe896329212657b47b7abd402447ac5d156b7dd Mon Sep 17 00:00:00 2001 From: Will Ripley <wripley@google.com> Date: Mon, 15 Jul 2019 07:39:01 -0700 Subject: [PATCH 2/8] Added missing header to versions.tf file --- terraform/versions.tf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/terraform/versions.tf b/terraform/versions.tf index ac97c6a..c51f32c 100644 --- a/terraform/versions.tf +++ b/terraform/versions.tf @@ -1,3 +1,18 @@ +/* +Copyright 2018 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ terraform { required_version = ">= 0.12" From 20076fbbdec77f5112a13eb18c8acb70bc6ec18d Mon Sep 17 00:00:00 2001 From: Will Ripley <wripley@google.com> Date: Mon, 15 Jul 2019 07:54:37 -0700 Subject: [PATCH 3/8] Removed flag check-variables flag from make.sh --- test/make.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/make.sh b/test/make.sh index 4459ce2..5caa1ff 100644 --- a/test/make.sh +++ b/test/make.sh @@ -49,7 +49,7 @@ function docker() { function check_terraform() { echo "Running terraform validate" #shellcheck disable=SC2156 - find . -name "*.tf" -exec bash -c 'terraform validate --check-variables=false $(dirname "{}")' \; + find . -name "*.tf" -exec bash -c 'terraform validate $(dirname "{}")' \; } # This function runs 'go fmt' and 'go vet' on eery file From fd81f77a25e26d57217dc33f4530f902dffe7220 Mon Sep 17 00:00:00 2001 From: Will Ripley <wripley@google.com> Date: Mon, 15 Jul 2019 09:16:24 -0700 Subject: [PATCH 4/8] Changed Jenkinsfile image source to include env variable --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7aa673e..7a7322f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,7 +35,7 @@ metadata: spec: containers: - name: ${containerName} - image: gcr.io/pso-helmsman-cicd/jenkins-k8s-node:jenkins-cicd_images_builder-185 + image: gcr.io/pso-helmsman-cicd/jenkins-k8s-node:${env.JENKINS_CONTAINER_VERSION} command: ['cat'] tty: true volumeMounts: From 21fe75c9fb1c5f34e50884cbc832ac06456203d9 Mon Sep 17 00:00:00 2001 From: Will Ripley <wripley@google.com> Date: Mon, 15 Jul 2019 10:41:45 -0700 Subject: [PATCH 5/8] Fixed Google provider version --- terraform/provider.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/provider.tf b/terraform/provider.tf index 551f471..3432569 100644 --- a/terraform/provider.tf +++ b/terraform/provider.tf @@ -17,6 +17,6 @@ limitations under the License. // Identifies allowable version range for Terraform Google Provider provider "google" { project = var.project - version = "~> 2.5" + version = "~> 2.1" } From 51fa51d381a2278a36831f8d5992a61b866f014b Mon Sep 17 00:00:00 2001 From: Will Ripley <wripley@google.com> Date: Mon, 15 Jul 2019 10:49:47 -0700 Subject: [PATCH 6/8] Changed Google provider to 2.10. --- terraform/provider.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/provider.tf b/terraform/provider.tf index 3432569..7996d4d 100644 --- a/terraform/provider.tf +++ b/terraform/provider.tf @@ -17,6 +17,6 @@ limitations under the License. // Identifies allowable version range for Terraform Google Provider provider "google" { project = var.project - version = "~> 2.1" + version = "~> 2.10" } From 04eb5ad85bc094f83da8065847d2ed3d0c17fe7a Mon Sep 17 00:00:00 2001 From: Will Ripley <wripley@google.com> Date: Mon, 15 Jul 2019 11:02:35 -0700 Subject: [PATCH 7/8] Fixing version to make sure it targets 2.10 and not 2.1 --- terraform/provider.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/provider.tf b/terraform/provider.tf index 7996d4d..40dc2f1 100644 --- a/terraform/provider.tf +++ b/terraform/provider.tf @@ -17,6 +17,6 @@ limitations under the License. // Identifies allowable version range for Terraform Google Provider provider "google" { project = var.project - version = "~> 2.10" + version = "~> 2.10.0" } From 6d8902349395aaa78ab725ffdd4f9db66f428467 Mon Sep 17 00:00:00 2001 From: Will Ripley <wripley@google.com> Date: Wed, 17 Jul 2019 05:31:48 -0700 Subject: [PATCH 8/8] Updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8932fb6..9b73c78 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ gcloud init ``` ### Tools -1. [Terraform >= 0.11.7](https://www.terraform.io/downloads.html) +1. [Terraform >= 0.12](https://www.terraform.io/downloads.html) 2. [Google Cloud SDK version >= 204.0.0](https://cloud.google.com/sdk/docs/downloads-versioned-archives) 3. [kubectl matching the latest GKE version](https://kubernetes.io/docs/tasks/tools/install-kubectl/)