Skip to content

Commit

Permalink
Gke terraform upgrade to 0.12 and fix bastion instance zone to be reg…
Browse files Browse the repository at this point in the history
…ion agnostic (#554)

* Upgrades to terraform 0.12

* Makes script more usable on destroy, specifies terraform >= 0.12 in readme

* Updates readme to remove note about node pool deletion contention
  • Loading branch information
jlerche authored and tennix committed Jun 6, 2019
1 parent ef33ba5 commit 36e4ae0
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 110 deletions.
4 changes: 1 addition & 3 deletions deploy/gcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This document describes how to deploy TiDB Operator and a TiDB cluster on GCP GK
First of all, make sure the following items are installed on your machine:

* [Google Cloud SDK](https://cloud.google.com/sdk/install)
* [terraform](https://www.terraform.io/downloads.html)
* [terraform](https://www.terraform.io/downloads.html) >= 0.12
* [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl) >= 1.11
* [helm](https://github.com/helm/helm/blob/master/docs/install.md#installing-the-helm-client) >= 2.9.0
* [jq](https://stedolan.github.io/jq/download/)
Expand Down Expand Up @@ -236,5 +236,3 @@ terraform destroy
You have to manually delete disks in the Google Cloud Console, or with `gcloud` after running `terraform destroy` if you do not need the data anymore.

> *Note*: When `terraform destroy` is running, an error with the following message might occur: `Error reading Container Cluster "my-cluster": Cluster "my-cluster" has status "RECONCILING" with message""`. This happens when GCP is upgrading the kubernetes master node, which it does automatically at times. While this is happening, it is not possible to delete the cluster. When it is done, run `terraform destroy` again.
> *Note*: When `terraform destroy` is running, an error with the following message might occur: `Error deleting NodePool: googleapi: Error 400: Operation operation-1558952543255-89695179 is currently deleting a node pool for cluster my-cluster. Please wait and try again once it is done., failedPrecondition`. This happens when terraform issues delete requests to cluster resources concurrently. To resolve, wait a little bit and then run `terraform destroy` again.
28 changes: 17 additions & 11 deletions deploy/gcp/data.tf
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
data "template_file" "tidb_cluster_values" {
template = "${file("${path.module}/templates/tidb-cluster-values.yaml.tpl")}"
template = file("${path.module}/templates/tidb-cluster-values.yaml.tpl")

vars {
cluster_version = "${var.tidb_version}"
pd_replicas = "${var.pd_replica_count}"
tikv_replicas = "${var.tikv_replica_count}"
tidb_replicas = "${var.tidb_replica_count}"
operator_version = "${var.tidb_operator_version}"
vars = {
cluster_version = var.tidb_version
pd_replicas = var.pd_replica_count
tikv_replicas = var.tikv_replica_count
tidb_replicas = var.tidb_replica_count
operator_version = var.tidb_operator_version
}
}

data external "available_zones_in_region" {
depends_on = [null_resource.prepare-dir]
program = ["bash", "-c", "gcloud compute regions describe ${var.GCP_REGION} --format=json | jq '{zone: .zones|.[0]|match(\"[^/]*$\"; \"g\")|.string}'"]
}

data "external" "tidb_ilb_ip" {
depends_on = ["null_resource.deploy-tidb-cluster"]
depends_on = [null_resource.deploy-tidb-cluster]
program = ["bash", "-c", "kubectl --kubeconfig ${local.kubeconfig} get svc -n tidb tidb-cluster-tidb -o json | jq '.status.loadBalancer.ingress[0]'"]
}

data "external" "monitor_ilb_ip" {
depends_on = ["null_resource.deploy-tidb-cluster"]
depends_on = [null_resource.deploy-tidb-cluster]
program = ["bash", "-c", "kubectl --kubeconfig ${local.kubeconfig} get svc -n tidb tidb-cluster-grafana -o json | jq '.status.loadBalancer.ingress[0]'"]
}

data "external" "tidb_port" {
depends_on = ["null_resource.deploy-tidb-cluster"]
depends_on = [null_resource.deploy-tidb-cluster]
program = ["bash", "-c", "kubectl --kubeconfig ${local.kubeconfig} get svc -n tidb tidb-cluster-tidb -o json | jq '.spec.ports | .[] | select( .name == \"mysql-client\") | {port: .port|tostring}'"]
}

data "external" "monitor_port" {
depends_on = ["null_resource.deploy-tidb-cluster"]
depends_on = [null_resource.deploy-tidb-cluster]
program = ["bash", "-c", "kubectl --kubeconfig ${local.kubeconfig} get svc -n tidb tidb-cluster-grafana -o json | jq '.spec.ports | .[] | select( .name == \"grafana\") | {port: .port|tostring}'"]
}

Loading

0 comments on commit 36e4ae0

Please sign in to comment.