Skip to content

Commit

Permalink
Merge branch 'master' into feature/issue_65
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienthebo authored Mar 13, 2019
2 parents 6fcdf76 + de467d9 commit 7bf2b99
Show file tree
Hide file tree
Showing 23 changed files with 283 additions and 21 deletions.
46 changes: 37 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ check_headers:
# Integration tests
.PHONY: test_integration
test_integration:
bundle install
bundle exec kitchen create
bundle exec kitchen converge
bundle exec kitchen converge
bundle exec kitchen verify
bundle exec kitchen destroy
test/ci_integration.sh

.PHONY: generate_docs
generate_docs:
Expand Down Expand Up @@ -112,15 +107,25 @@ docker_push_kitchen_terraform:
.PHONY: docker_run
docker_run:
docker run --rm -it \
-e COMPUTE_ENGINE_SERVICE_ACCOUNT \
-e PROJECT_ID \
-e REGION \
-e ZONES \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
/bin/bash
/bin/bash -c "source test/ci_integration.sh && setup_environment && exec /bin/bash"

.PHONY: docker_create
docker_create: docker_build_kitchen_terraform
docker run --rm -it \
-e COMPUTE_ENGINE_SERVICE_ACCOUNT \
-e PROJECT_ID \
-e REGION \
-e ZONES \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
Expand All @@ -130,6 +135,11 @@ docker_create: docker_build_kitchen_terraform
.PHONY: docker_converge
docker_converge:
docker run --rm -it \
-e COMPUTE_ENGINE_SERVICE_ACCOUNT \
-e PROJECT_ID \
-e REGION \
-e ZONES \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
Expand All @@ -139,6 +149,11 @@ docker_converge:
.PHONY: docker_verify
docker_verify:
docker run --rm -it \
-e COMPUTE_ENGINE_SERVICE_ACCOUNT \
-e PROJECT_ID \
-e REGION \
-e ZONES \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
Expand All @@ -148,12 +163,25 @@ docker_verify:
.PHONY: docker_destroy
docker_destroy:
docker run --rm -it \
-e COMPUTE_ENGINE_SERVICE_ACCOUNT \
-e PROJECT_ID \
-e REGION \
-e ZONES \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen destroy"

.PHONY: test_integration_docker
test_integration_docker: docker_create docker_converge docker_verify docker_destroy
@echo "Running test-kitchen tests in docker"
test_integration_docker:
docker run --rm -it \
-e COMPUTE_ENGINE_SERVICE_ACCOUNT \
-e PROJECT_ID \
-e REGION \
-e ZONES \
-e SERVICE_ACCOUNT_JSON \
-v $(CURDIR):/cft/workdir \
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
/bin/bash -c "test/ci_integration.sh"
2 changes: 1 addition & 1 deletion autogen/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ locals {
resource "google_service_account" "cluster_service_account" {
count = "${var.service_account == "create" ? 1 : 0}"
project = "${var.project_id}"
account_id = "tf-gke-${substr(var.name, 0, 20)}"
account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}"
display_name = "Terraform-managed service account for cluster ${var.name}"
}

Expand Down
2 changes: 1 addition & 1 deletion cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ resource "google_container_node_pool" "zonal_pools" {

management {
auto_repair = "${lookup(var.node_pools[count.index], "auto_repair", true)}"
auto_upgrade = "${lookup(var.node_pools[count.index], "auto_upgrade", false)}"
auto_upgrade = "${lookup(var.node_pools[count.index], "auto_upgrade", true)}"
}

node_config {
Expand Down
3 changes: 3 additions & 0 deletions examples/deploy_service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ locals {
provider "google" {
credentials = "${file(var.credentials_path)}"
region = "${var.region}"
version = "~> 1.20"
}

provider "kubernetes" {
Expand All @@ -40,6 +41,8 @@ module "gke" {
network = "${var.network}"
subnetwork = "${var.subnetwork}"

kubernetes_version = "1.11.7-gke.12"

ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
Expand Down
21 changes: 13 additions & 8 deletions examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,29 @@ locals {
}

provider "google" {
version = "~> 1.20"
credentials = "${file(var.credentials_path)}"
region = "${var.region}"
}

module "gke" {
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = "${var.region}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
regional = "false"
region = "${var.region}"
zones = "${var.zones}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
remove_default_node_pool = "true"

node_pools = [
{
name = "pool-01"
min_count = 1
max_count = 2
service_account = "${var.compute_engine_service_account}"
},
{
Expand Down
5 changes: 5 additions & 0 deletions examples/node_pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ variable "region" {
description = "The region to host the cluster in"
}

variable "zones" {
type = "list"
description = "The zone to host the cluster in (required if is a zonal cluster)"
}

variable "network" {
description = "The VPC network to host the cluster in"
}
Expand Down
1 change: 1 addition & 0 deletions examples/shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ locals {
}

provider "google" {
version = "~> 1.20"
credentials = "${file(var.credentials_path)}"
region = "${var.region}"
}
Expand Down
1 change: 1 addition & 0 deletions examples/simple_regional_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 1.20"
credentials = "${file(var.credentials_path)}"
region = "${var.region}"
}
Expand Down
1 change: 1 addition & 0 deletions examples/simple_zonal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ locals {
}

provider "google" {
version = "~> 1.20"
credentials = "${file(var.credentials_path)}"
region = "${var.region}"
}
Expand Down
1 change: 1 addition & 0 deletions examples/simple_zonal_private/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ locals {
}

provider "google-beta" {
version = "~> 1.20"
credentials = "${file(var.credentials_path)}"
region = "${var.region}"
}
Expand Down
1 change: 1 addition & 0 deletions examples/stub_domains/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ locals {
}

provider "google" {
version = "~> 1.20"
credentials = "${file(var.credentials_path)}"
region = "${var.region}"
}
Expand Down
2 changes: 1 addition & 1 deletion modules/private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ locals {
resource "google_service_account" "cluster_service_account" {
count = "${var.service_account == "create" ? 1 : 0}"
project = "${var.project_id}"
account_id = "tf-gke-${substr(var.name, 0, 20)}"
account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}"
display_name = "Terraform-managed service account for cluster ${var.name}"
}

Expand Down
2 changes: 1 addition & 1 deletion sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ locals {
resource "google_service_account" "cluster_service_account" {
count = "${var.service_account == "create" ? 1 : 0}"
project = "${var.project_id}"
account_id = "tf-gke-${substr(var.name, 0, 20)}"
account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}"
display_name = "Terraform-managed service account for cluster ${var.name}"
}

Expand Down
18 changes: 18 additions & 0 deletions test/ci/deploy-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

platform: linux

inputs:
- name: pull-request
path: terraform-google-kubernetes-engine

run:
path: make
args: ['test_integration']
dir: terraform-google-kubernetes-engine

params:
SUITE: "deploy-service-local"
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
REGION: "us-east4"
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'
18 changes: 18 additions & 0 deletions test/ci/node-pool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

platform: linux

inputs:
- name: pull-request
path: terraform-google-kubernetes-engine

run:
path: make
args: ['test_integration']
dir: terraform-google-kubernetes-engine

params:
SUITE: "node-pool-local"
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
REGION: "us-east4"
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'
18 changes: 18 additions & 0 deletions test/ci/shared-vpc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

platform: linux

inputs:
- name: pull-request
path: terraform-google-kubernetes-engine

run:
path: make
args: ['test_integration']
dir: terraform-google-kubernetes-engine

params:
SUITE: "shared-vpc-local"
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
REGION: "us-east4"
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'
18 changes: 18 additions & 0 deletions test/ci/simple-regional-private.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

platform: linux

inputs:
- name: pull-request
path: terraform-google-kubernetes-engine

run:
path: make
args: ['test_integration']
dir: terraform-google-kubernetes-engine

params:
SUITE: "simple-regional-private-local"
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
REGION: "us-east4"
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'
18 changes: 18 additions & 0 deletions test/ci/simple-regional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

platform: linux

inputs:
- name: pull-request
path: terraform-google-kubernetes-engine

run:
path: make
args: ['test_integration']
dir: terraform-google-kubernetes-engine

params:
SUITE: "simple-regional-local"
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
REGION: "us-east4"
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'
18 changes: 18 additions & 0 deletions test/ci/simple-zonal-private.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

platform: linux

inputs:
- name: pull-request
path: terraform-google-kubernetes-engine

run:
path: make
args: ['test_integration']
dir: terraform-google-kubernetes-engine

params:
SUITE: "simple-zonal-private-local"
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
REGION: "us-east4"
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'
18 changes: 18 additions & 0 deletions test/ci/simple-zonal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

platform: linux

inputs:
- name: pull-request
path: terraform-google-kubernetes-engine

run:
path: make
args: ['test_integration']
dir: terraform-google-kubernetes-engine

params:
SUITE: "simple-zonal-local"
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
REGION: "us-east4"
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'
18 changes: 18 additions & 0 deletions test/ci/stub-domains.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

platform: linux

inputs:
- name: pull-request
path: terraform-google-kubernetes-engine

run:
path: make
args: ['test_integration']
dir: terraform-google-kubernetes-engine

params:
SUITE: "stub-domains-local"
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
REGION: "us-east4"
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'
Loading

0 comments on commit 7bf2b99

Please sign in to comment.