From 39805347f9755667b649e52aef6141b0b0c89ee4 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Wed, 25 Mar 2020 14:21:05 +0800 Subject: [PATCH] Deploy TiDB Cluster with CR via TiDB Operator v1.1 on GKE --- deploy/gcp/examples/tidb-customized.tfvars | 25 ------ deploy/gcp/manifests/db-monitor.yaml.example | 82 ++++++++++++++++++++ deploy/gcp/manifests/db.yaml.example | 63 +++++++++++++++ deploy/gcp/outputs.tf | 25 ------ deploy/gcp/tidbclusters.tf | 47 +++++------ deploy/gcp/variables.tf | 8 +- deploy/modules/gcp/tidb-cluster/data.tf | 24 +++++- deploy/modules/gcp/tidb-cluster/main.tf | 2 + deploy/modules/gcp/tidb-cluster/variables.tf | 5 ++ 9 files changed, 203 insertions(+), 78 deletions(-) delete mode 100644 deploy/gcp/examples/tidb-customized.tfvars create mode 100644 deploy/gcp/manifests/db-monitor.yaml.example create mode 100644 deploy/gcp/manifests/db.yaml.example diff --git a/deploy/gcp/examples/tidb-customized.tfvars b/deploy/gcp/examples/tidb-customized.tfvars deleted file mode 100644 index f2ca40b6d4b..00000000000 --- a/deploy/gcp/examples/tidb-customized.tfvars +++ /dev/null @@ -1,25 +0,0 @@ -pd_instance_type = "n1-standard-2" -tikv_instance_type = "n1-highmem-4" -tidb_instance_type = "n1-standard-8" - -# specify tidb version -tidb_version = "3.0.8" - -# override tidb cluster values -override_values = < 0 then .[0].locations | join(",") else "" end) }' +EOT + cmd_get_tidb_ilb_ip = </dev/null) || true +jq -s '.[0].status.loadBalancer.ingress[0] // {"ip":""}' <<<"$output" +EOT + cmd_get_monitor_lb_ip = </dev/null) || true +jq -s '.[0].status.loadBalancer.ingress[0] // {"ip":""}' <<<"$output" +EOT + cmd_get_tidb_port = </dev/null) || true +jq -s 'try (.[0].spec.ports | .[] | select( .name == "mysql-client") | {port: .port|tostring}) catch {"port":""}' <<<"$otuput" +EOT + cmd_get_monitor_port = </dev/null) || true +jq -s 'try (.[0].spec.ports | .[] | select( .name == "grafana") | {port: .port|tostring}) catch {"port":""}' <<<"$otuput" EOT } diff --git a/deploy/modules/gcp/tidb-cluster/main.tf b/deploy/modules/gcp/tidb-cluster/main.tf index 7166ee7787c..9aa76c3bdb2 100644 --- a/deploy/modules/gcp/tidb-cluster/main.tf +++ b/deploy/modules/gcp/tidb-cluster/main.tf @@ -135,6 +135,7 @@ locals { module "tidb-cluster" { source = "../../share/tidb-cluster-release" + create = var.create_tidb_cluster_release cluster_name = var.cluster_name pd_count = var.pd_node_count * local.num_availability_zones tikv_count = var.tikv_node_count * local.num_availability_zones @@ -149,6 +150,7 @@ module "tidb-cluster" { } resource "null_resource" "wait-lb-ip" { + count = var.create_tidb_cluster_release == true ? 1 : 0 depends_on = [ module.tidb-cluster ] diff --git a/deploy/modules/gcp/tidb-cluster/variables.tf b/deploy/modules/gcp/tidb-cluster/variables.tf index db730b919d3..258b667b1f2 100644 --- a/deploy/modules/gcp/tidb-cluster/variables.tf +++ b/deploy/modules/gcp/tidb-cluster/variables.tf @@ -72,3 +72,8 @@ variable "tikv_local_ssd_count" { description = "TiKV node pool local ssd count (cannot be changed after the node pool is created)" default = 1 } + +variable "create_tidb_cluster_release" { + description = "Whether create tidb-cluster release in the node pools automatically" + default = true +}