Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cofyc committed Aug 22, 2019
1 parent 4b8708e commit 919c7fb
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions deploy/gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module "tidb-operator" {
vpc_name = var.vpc_name
subnetwork_name = module.vpc.private_subnetwork_name
gcp_project = var.GCP_PROJECT
gke_version = var.gke_version
location = local.location
node_locations = var.node_locations
kubeconfig_path = local.kubeconfig
Expand Down
2 changes: 1 addition & 1 deletion deploy/gcp/tidbclusters.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ module "default-tidb-cluster" {
tikv_node_count = var.tikv_count
tidb_node_count = var.tidb_count
monitor_node_count = var.monitor_count
tikv_local_ssd_count = var.tikv_local_ssd_count
tikv_local_ssd_count = var.tikv_local_ssd_count
override_values = var.override_values
}
4 changes: 2 additions & 2 deletions deploy/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ variable "location" {
variable "node_locations" {
description = "The list of zones in which the cluster's nodes should be located. These must be in the same region as the cluster zone for zonal clusters, or in the region of a regional cluster. In a multi-zonal cluster, the number of nodes specified in initial_node_count is created in all specified zones as well as the primary zone. If specified for a regional cluster, nodes will be created in only these zones."
type = list(string)
default = []
default = []
}

variable "tidb_version" {
Expand Down Expand Up @@ -108,7 +108,7 @@ variable "tikv_image_type" {

variable "tikv_local_ssd_count" {
description = "TiKV node pool local ssd count (cannot be changed after the node pool is created)"
default = 1
default = 1
}

variable "monitor_instance_type" {
Expand Down
4 changes: 2 additions & 2 deletions deploy/modules/gcp/tidb-cluster/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ data "external" "monitor_port" {
}

locals {
# Location examples: us-central1 (region), us-central1-b (zone), us-central1-c (zone)
cluster_location_args = "%{if length(split("-", var.gke_cluster_location)) == 3}--zone ${var.gke_cluster_location}%{else}--region ${var.gke_cluster_location}%{endif}"
# examples of location: us-central1 (region), us-central1-b (zone), us-central1-c (zone)
cluster_location_args = "%{if length(split("-", var.gke_cluster_location)) == 3}--zone ${var.gke_cluster_location} %{else}--region ${var.gke_cluster_location} %{endif}"
# TODO Update related code when node locations is avaiable in attributes of cluster resource.
cmd_get_cluster_locations = <<EOT
gcloud --project ${var.gcp_project} container clusters list --filter='name=${var.gke_cluster_name}' --format='json[no-heading](locations)' ${local.cluster_location_args} | jq '.[0] | .locations |= join(",")'
Expand Down
8 changes: 4 additions & 4 deletions deploy/modules/gcp/tidb-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ variable "monitor_instance_type" {

variable "pd_image_type" {
description = "PD image type, avaiable: UBUNTU/COS"
default = "COS"
default = "COS"
}

variable "tidb_image_type" {
description = "TiDB image type, avaiable: UBUNTU/COS"
default = "COS"
default = "COS"
}

variable "tikv_image_type" {
description = "TiKV image type, avaiable: UBUNTU/COS"
default = "COS"
default = "COS"
}

variable "tikv_local_ssd_count" {
description = "TiKV node pool local ssd count (cannot be changed after the node pool is created)"
default = 1
default = 1
}
32 changes: 16 additions & 16 deletions deploy/modules/gcp/tidb-operator/main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
resource "google_container_cluster" "cluster" {
name = var.gke_name
network = var.vpc_name
subnetwork = var.subnetwork_name
location = var.location
name = var.gke_name
network = var.vpc_name
subnetwork = var.subnetwork_name
location = var.location
node_locations = var.node_locations
project = var.gcp_project
project = var.gcp_project

master_auth {
username = ""
Expand Down Expand Up @@ -44,8 +44,8 @@ resource "google_container_cluster" "cluster" {
}

locals {
# TODO better way to detect whether the cluster is zonal or regional
cmd_get_cluster_credentials = length(split("-", var.location)) == 3 ? "gcloud --project ${var.gcp_project} container clusters get-credentials ${google_container_cluster.cluster.name} --zone ${var.location}" : "gcloud --project ${var.gcp_project} container clusters get-credentials ${google_container_cluster.cluster.name} --region ${var.location}"
# TODO better way to detect whether the cluster is zonal or regional
cmd_get_cluster_credentials = length(split("-", var.location)) == 3 ? "gcloud --project ${var.gcp_project} container clusters get-credentials ${google_container_cluster.cluster.name} --zone ${var.location}" : "gcloud --project ${var.gcp_project} container clusters get-credentials ${google_container_cluster.cluster.name} --region ${var.location}"
}

resource "null_resource" "get-credentials" {
Expand Down Expand Up @@ -124,10 +124,10 @@ EOS
}

data "helm_repository" "pingcap" {
provider = "helm.initial"
provider = "helm.initial"
depends_on = [null_resource.setup-env]
name = "pingcap"
url = "https://charts.pingcap.org/"
name = "pingcap"
url = "https://charts.pingcap.org/"
}

resource "helm_release" "tidb-operator" {
Expand All @@ -139,10 +139,10 @@ resource "helm_release" "tidb-operator" {
]

repository = data.helm_repository.pingcap.name
chart = "tidb-operator"
version = var.tidb_operator_version
namespace = "tidb-admin"
name = "tidb-operator"
values = [var.operator_helm_values]
wait = false
chart = "tidb-operator"
version = var.tidb_operator_version
namespace = "tidb-admin"
name = "tidb-operator"
values = [var.operator_helm_values]
wait = false
}
4 changes: 2 additions & 2 deletions deploy/modules/gcp/tidb-operator/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ variable "gcp_project" {

variable "location" {
description = "The GKE cluster location. If you specify a zone (such as us-central1-a), the cluster will be a zonal cluster with a single cluster master. If you specify a region (such as us-west1), the cluster will be a regional cluster with multiple masters spread across zones in the region."
type = string
type = string
}

variable "node_locations" {
description = "The list of zones in which the cluster's nodes should be located. These must be in the same region as the cluster zone for zonal clusters, or in the region of a regional cluster. In a multi-zonal cluster, the number of nodes specified in initial_node_count is created in all specified zones as well as the primary zone. If specified for a regional cluster, nodes will be created in only these zones."
type = list(string)
type = list(string)
}

variable "gke_version" {
Expand Down

0 comments on commit 919c7fb

Please sign in to comment.