From 1c5fd92ad6370014bfe880de849c029d24e50b53 Mon Sep 17 00:00:00 2001 From: Chia-Chun Tai Date: Fri, 31 May 2019 15:44:42 +0800 Subject: [PATCH] Add Terraform configuration and upgrade helm version (#1194) * Use terraform to manage ci cluster. Upgrade ci cluster to 1.13 * Upgrade helm version * Do not break the test if no previous resources * Do not skip install helm if helm is old version --- .gitignore | 5 ++++ hack/runtests.sh | 2 ++ hack/travis-kube-setup.sh | 5 ++-- test/cluster/main.tf | 51 +++++++++++++++++++++++++++++++++++++++ test/cluster/versions.tf | 3 +++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 test/cluster/main.tf create mode 100644 test/cluster/versions.tf diff --git a/.gitignore b/.gitignore index f2013770..5bb9de58 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,11 @@ test/logs/ .idea environments/php7/vendor/ +# terraform files +.terraform/ +*.tfstate +*.backup + # Common backup files *.swp *.bak diff --git a/hack/runtests.sh b/hack/runtests.sh index 9c38243b..cd396fd2 100755 --- a/hack/runtests.sh +++ b/hack/runtests.sh @@ -8,6 +8,7 @@ else K="kubectl --kubeconfig $KUBECONFIG --namespace default" if $K get configmap ok-to-destroy then + set +e # do not break if crd not found $K delete functions --all $K delete environments --all $K delete httptriggers --all @@ -15,6 +16,7 @@ else $K delete messagequeuetriggers --all $K delete packages --all $K delete timetriggers --all + set -e fi fi diff --git a/hack/travis-kube-setup.sh b/hack/travis-kube-setup.sh index 5b28fea6..6adc2508 100755 --- a/hack/travis-kube-setup.sh +++ b/hack/travis-kube-setup.sh @@ -14,9 +14,10 @@ then fi # Get helm -if [ ! -f $K8SCLI_DIR/helm ] +HELM_VERSION=2.14.0 +if [ ! -f $K8SCLI_DIR/helm ] || (helm version --client | grep -v $HELM_VERSION) then - curl -LO https://storage.googleapis.com/kubernetes-helm/helm-v2.7.2-linux-amd64.tar.gz + curl -LO https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz tar xzvf helm-*.tar.gz mv linux-amd64/helm $K8SCLI_DIR/helm fi diff --git a/test/cluster/main.tf b/test/cluster/main.tf new file mode 100644 index 00000000..99fbbe40 --- /dev/null +++ b/test/cluster/main.tf @@ -0,0 +1,51 @@ +terraform { + backend "gcs" { + bucket = "fission-terraform-state" + prefix = "fission-ci-cluster" + } +} + +provider "google" { + version = "~> 2.7" + project = "fission-ci" +} + +resource "google_container_cluster" "fission-ci-1" { + name = "fission-ci-1" + description = "" + min_master_version = "1.13.6-gke.0" + network = "projects/fission-ci/global/networks/default" + location = "us-central1-a" + remove_default_node_pool = true + initial_node_count = 0 + logging_service = "none" + monitoring_service = "none" + master_authorized_networks_config {} +} + +resource "google_container_node_pool" "pool-v1" { + name = "pool-v1" + location = "us-central1-a" + cluster = google_container_cluster.fission-ci-1.name + + node_config { + machine_type = "n1-standard-2" + preemptible = false + disk_size_gb = 100 + oauth_scopes = [ + "https://www.googleapis.com/auth/devstorage.read_only", + "https://www.googleapis.com/auth/monitoring.write", + ] + } + + initial_node_count = 3 + autoscaling { + min_node_count = 3 + max_node_count = 5 + } + + management { + auto_repair = true + auto_upgrade = true + } +} diff --git a/test/cluster/versions.tf b/test/cluster/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/test/cluster/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +}