Skip to content

Commit

Permalink
Merge pull request #28 from wripley/master
Browse files Browse the repository at this point in the history
Upgraded demo to use TF 0.12
  • Loading branch information
bgeesaman committed Jul 17, 2019
2 parents e639d0b + 6d89023 commit 477cf4e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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:${env.JENKINS_CONTAINER_VERSION}
command: ['cat']
tty: true
volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down
18 changes: 10 additions & 8 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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" {
Expand All @@ -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
}

6 changes: 3 additions & 3 deletions terraform/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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.10.0"
}

6 changes: 3 additions & 3 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

19 changes: 19 additions & 0 deletions terraform/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
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"
}
2 changes: 1 addition & 1 deletion test/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 477cf4e

Please sign in to comment.