From ced10e3e5ad668b65fe9b34d8869ce7708b1d300 Mon Sep 17 00:00:00 2001 From: DanielZhangQD Date: Fri, 20 Mar 2020 19:40:44 +0800 Subject: [PATCH 1/6] create tidb cluster with cr on aws --- deploy/aws/clusters.tf | 59 +++++----- deploy/aws/manifests/db-monitor.yaml.example | 84 ++++++++++++++ deploy/aws/manifests/db.yaml.example | 109 +++++++++++++++++++ deploy/aws/variables.tf | 8 +- 4 files changed, 228 insertions(+), 32 deletions(-) create mode 100644 deploy/aws/manifests/db-monitor.yaml.example create mode 100644 deploy/aws/manifests/db.yaml.example diff --git a/deploy/aws/clusters.tf b/deploy/aws/clusters.tf index ac3d9ff777..a8bf9691bd 100644 --- a/deploy/aws/clusters.tf +++ b/deploy/aws/clusters.tf @@ -17,25 +17,24 @@ provider "helm" { } # TiDB cluster declaration example -#module "example-cluster" { -# source = "./tidb-cluster" -# eks_info = local.default_eks -# subnets = local.default_subnets -# -# # NOTE: cluster_name cannot be changed after creation -# cluster_name = "demo-cluster" -# cluster_version = "v3.0.8" -# ssh_key_name = module.key-pair.key_name -# pd_count = 1 -# pd_instance_type = "t2.xlarge" -# tikv_count = 1 -# tikv_instance_type = "t2.xlarge" -# tidb_count = 1 -# tidb_instance_type = "t2.xlarge" -# monitor_instance_type = "t2.xlarge" -# # yaml file that passed to helm to customize the release -# override_values = file("values/example.yaml") -#} +# module example-cluster { +# source = "../modules/aws/tidb-cluster" + +# eks = local.eks +# subnets = local.subnets +# region = var.region +# cluster_name = "example" + +# ssh_key_name = module.key-pair.key_name +# pd_count = 1 +# pd_instance_type = "c5.large" +# tikv_count = 1 +# tikv_instance_type = "c5d.large" +# tidb_count = 1 +# tidb_instance_type = "c4.large" +# monitor_instance_type = "c5.large" +# create_tidb_cluster_release = false +# } module "default-cluster" { providers = { @@ -46,15 +45,15 @@ module "default-cluster" { subnets = local.subnets region = var.region - cluster_name = var.default_cluster_name - cluster_version = var.default_cluster_version - ssh_key_name = module.key-pair.key_name - pd_count = var.default_cluster_pd_count - pd_instance_type = var.default_cluster_pd_instance_type - tikv_count = var.default_cluster_tikv_count - tikv_instance_type = var.default_cluster_tikv_instance_type - tidb_count = var.default_cluster_tidb_count - tidb_instance_type = var.default_cluster_tidb_instance_type - monitor_instance_type = var.default_cluster_monitor_instance_type - override_values = file("default-cluster.yaml") + cluster_name = var.default_cluster_name + cluster_version = var.default_cluster_version + ssh_key_name = module.key-pair.key_name + pd_count = var.default_cluster_pd_count + pd_instance_type = var.default_cluster_pd_instance_type + tikv_count = var.default_cluster_tikv_count + tikv_instance_type = var.default_cluster_tikv_instance_type + tidb_count = var.default_cluster_tidb_count + tidb_instance_type = var.default_cluster_tidb_instance_type + monitor_instance_type = var.default_cluster_monitor_instance_type + create_tidb_cluster_release = var.create_tidb_cluster_release } diff --git a/deploy/aws/manifests/db-monitor.yaml.example b/deploy/aws/manifests/db-monitor.yaml.example new file mode 100644 index 0000000000..2014969df8 --- /dev/null +++ b/deploy/aws/manifests/db-monitor.yaml.example @@ -0,0 +1,84 @@ +apiVersion: pingcap.com/v1alpha1 +kind: TidbMonitor +metadata: + name: db +spec: + alertmanagerURL: "" + annotations: {} + clusters: + - name: db + grafana: + baseImage: grafana/grafana + envs: + # Configure Grafana using environment variables except GF_PATHS_DATA, GF_SECURITY_ADMIN_USER and GF_SECURITY_ADMIN_PASSWORD + # Ref https://grafana.com/docs/installation/configuration/#using-environment-variables + GF_AUTH_ANONYMOUS_ENABLED: "true" + GF_AUTH_ANONYMOUS_ORG_NAME: "Main Org." + GF_AUTH_ANONYMOUS_ORG_ROLE: "Viewer" + # if grafana is running behind a reverse proxy with subpath http://foo.bar/grafana + # GF_SERVER_DOMAIN: foo.bar + # GF_SERVER_ROOT_URL: "%(protocol)s://%(domain)s/grafana/" + imagePullPolicy: IfNotPresent + logLevel: info + password: admin + resources: {} + # limits: + # cpu: 8000m + # memory: 8Gi + # requests: + # cpu: 4000m + # memory: 4Gi + service: + portName: http-grafana + type: LoadBalancer + username: admin + version: 6.0.1 + imagePullPolicy: IfNotPresent + initializer: + baseImage: pingcap/tidb-monitor-initializer + imagePullPolicy: IfNotPresent + resources: {} + # limits: + # cpu: 50m + # memory: 64Mi + # requests: + # cpu: 50m + # memory: 64Mi + version: v3.0.11 + kubePrometheusURL: "" + nodeSelector: {} + persistent: true + prometheus: + baseImage: prom/prometheus + imagePullPolicy: IfNotPresent + logLevel: info + reserveDays: 12 + resources: {} + # limits: + # cpu: 8000m + # memory: 8Gi + # requests: + # cpu: 4000m + # memory: 4Gi + service: + portName: http-prometheus + type: NodePort + version: v2.11.1 + reloader: + baseImage: pingcap/tidb-monitor-reloader + imagePullPolicy: IfNotPresent + resources: {} + # limits: + # cpu: 50m + # memory: 64Mi + # requests: + # cpu: 50m + # memory: 64Mi + service: + portName: tcp-reloader + type: NodePort + version: v1.0.1 + storage: 100Gi + storageClassName: ebs-gp2 + tolerations: [] + diff --git a/deploy/aws/manifests/db.yaml.example b/deploy/aws/manifests/db.yaml.example new file mode 100644 index 0000000000..0dfe92dc00 --- /dev/null +++ b/deploy/aws/manifests/db.yaml.example @@ -0,0 +1,109 @@ +apiVersion: pingcap.com/v1alpha1 +kind: TidbCluster +metadata: + name: db + namespace: db +spec: + configUpdateStrategy: RollingUpdate + enableTLSCluster: false + helper: + image: busybox:1.31.1 + hostNetwork: false + imagePullPolicy: IfNotPresent + pd: + affinity: {} + baseImage: pingcap/pd + config: + log: + level: info + replication: + location-labels: + - zone + max-replicas: 3 + nodeSelector: + dedicated: db-pd + podSecurityContext: {} + replicas: 1 + requests: + cpu: "1" + memory: 400Mi + storage: 1Gi + storageClassName: ebs-gp2 + tolerations: + - effect: NoSchedule + key: dedicated + operator: Equal + value: db-pd + pvReclaimPolicy: Retain + schedulerName: tidb-scheduler + tidb: + affinity: {} + baseImage: pingcap/tidb + config: + log: + level: info + performance: + max-procs: 0 + tcp-keep-alive: true + enableTLSClient: false + maxFailoverCount: 3 + nodeSelector: + dedicated: db-tidb + podSecurityContext: + sysctls: + - name: net.ipv4.tcp_keepalive_time + value: "300" + - name: net.ipv4.tcp_keepalive_intvl + value: "75" + - name: net.core.somaxconn + value: "32768" + replicas: 1 + requests: + cpu: "1" + memory: 400Mi + separateSlowLog: true + service: + annotations: + service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: 'true' + service.beta.kubernetes.io/aws-load-balancer-internal: '0.0.0.0/0' + service.beta.kubernetes.io/aws-load-balancer-type: nlb + exposeStatus: true + externalTrafficPolicy: Local + type: LoadBalancer + slowLogTailer: + limits: + cpu: 100m + memory: 50Mi + requests: + cpu: 20m + memory: 5Mi + tolerations: + - effect: NoSchedule + key: dedicated + operator: Equal + value: db-tidb + tikv: + affinity: {} + baseImage: pingcap/tikv + config: + log-level: info + hostNetwork: false + maxFailoverCount: 3 + nodeSelector: + dedicated: db-tikv + podSecurityContext: {} + privileged: false + replicas: 1 + requests: + cpu: "1" + memory: 2Gi + storage: 45Gi + storageClassName: local-storage + tolerations: + - effect: NoSchedule + key: dedicated + operator: Equal + value: db-tikv + timezone: UTC + version: v3.0.11 + diff --git a/deploy/aws/variables.tf b/deploy/aws/variables.tf index 0ad33b44f7..4e5792d179 100644 --- a/deploy/aws/variables.tf +++ b/deploy/aws/variables.tf @@ -19,7 +19,7 @@ variable "eks_version" { variable "operator_version" { description = "TiDB operator version" - default = "v1.0.6" + default = "v1.1.0" } variable "operator_values" { @@ -112,6 +112,10 @@ variable "default_cluster_monitor_instance_type" { } variable "default_cluster_name" { - default = "my-cluster" + default = "db" } +variable "create_tidb_cluster_release" { + description = "whether creating tidb-cluster helm release" + default = false +} From ccfa3eb2e350ae39fadc784710aea95d4a414167 Mon Sep 17 00:00:00 2001 From: DanielZhangQD Date: Fri, 20 Mar 2020 19:47:20 +0800 Subject: [PATCH 2/6] update default version --- deploy/aws/manifests/db-monitor.yaml.example | 2 +- deploy/aws/manifests/db.yaml.example | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deploy/aws/manifests/db-monitor.yaml.example b/deploy/aws/manifests/db-monitor.yaml.example index 2014969df8..8a7694909a 100644 --- a/deploy/aws/manifests/db-monitor.yaml.example +++ b/deploy/aws/manifests/db-monitor.yaml.example @@ -44,7 +44,7 @@ spec: # requests: # cpu: 50m # memory: 64Mi - version: v3.0.11 + version: v3.0.12 kubePrometheusURL: "" nodeSelector: {} persistent: true diff --git a/deploy/aws/manifests/db.yaml.example b/deploy/aws/manifests/db.yaml.example index 0dfe92dc00..e99bb9e1c3 100644 --- a/deploy/aws/manifests/db.yaml.example +++ b/deploy/aws/manifests/db.yaml.example @@ -23,7 +23,7 @@ spec: nodeSelector: dedicated: db-pd podSecurityContext: {} - replicas: 1 + replicas: 3 requests: cpu: "1" memory: 400Mi @@ -57,7 +57,7 @@ spec: value: "75" - name: net.core.somaxconn value: "32768" - replicas: 1 + replicas: 2 requests: cpu: "1" memory: 400Mi @@ -93,7 +93,7 @@ spec: dedicated: db-tikv podSecurityContext: {} privileged: false - replicas: 1 + replicas: 3 requests: cpu: "1" memory: 2Gi @@ -105,5 +105,5 @@ spec: operator: Equal value: db-tikv timezone: UTC - version: v3.0.11 + version: v3.0.12 From 1e0fd7592e27095afa9cdbf8d17cd7a56c705ba3 Mon Sep 17 00:00:00 2001 From: DanielZhangQD Date: Mon, 23 Mar 2020 09:05:37 +0800 Subject: [PATCH 3/6] update examples --- deploy/aws/manifests/db-monitor.yaml.example | 2 +- deploy/aws/manifests/db.yaml.example | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/deploy/aws/manifests/db-monitor.yaml.example b/deploy/aws/manifests/db-monitor.yaml.example index 8a7694909a..a05ee1e9fb 100644 --- a/deploy/aws/manifests/db-monitor.yaml.example +++ b/deploy/aws/manifests/db-monitor.yaml.example @@ -1,7 +1,7 @@ apiVersion: pingcap.com/v1alpha1 kind: TidbMonitor metadata: - name: db + name: DEFAULT_CLUSTER_NAME spec: alertmanagerURL: "" annotations: {} diff --git a/deploy/aws/manifests/db.yaml.example b/deploy/aws/manifests/db.yaml.example index e99bb9e1c3..d39ee8fdd7 100644 --- a/deploy/aws/manifests/db.yaml.example +++ b/deploy/aws/manifests/db.yaml.example @@ -1,8 +1,7 @@ apiVersion: pingcap.com/v1alpha1 kind: TidbCluster metadata: - name: db - namespace: db + name: DEFAULT_CLUSTER_NAME spec: configUpdateStrategy: RollingUpdate enableTLSCluster: false @@ -21,7 +20,7 @@ spec: - zone max-replicas: 3 nodeSelector: - dedicated: db-pd + dedicated: DEFAULT_CLUSTER_NAME-pd podSecurityContext: {} replicas: 3 requests: @@ -33,7 +32,7 @@ spec: - effect: NoSchedule key: dedicated operator: Equal - value: db-pd + value: DEFAULT_CLUSTER_NAME-pd pvReclaimPolicy: Retain schedulerName: tidb-scheduler tidb: @@ -48,7 +47,7 @@ spec: enableTLSClient: false maxFailoverCount: 3 nodeSelector: - dedicated: db-tidb + dedicated: DEFAULT_CLUSTER_NAME-tidb podSecurityContext: sysctls: - name: net.ipv4.tcp_keepalive_time @@ -81,7 +80,7 @@ spec: - effect: NoSchedule key: dedicated operator: Equal - value: db-tidb + value: DEFAULT_CLUSTER_NAME-tidb tikv: affinity: {} baseImage: pingcap/tikv @@ -103,7 +102,7 @@ spec: - effect: NoSchedule key: dedicated operator: Equal - value: db-tikv + value: DEFAULT_CLUSTER_NAME-tikv timezone: UTC version: v3.0.12 From d04f595064b25dd0b0b31e2d86c78cb567098eea Mon Sep 17 00:00:00 2001 From: DanielZhangQD Date: Mon, 23 Mar 2020 09:15:40 +0800 Subject: [PATCH 4/6] update template variable --- deploy/aws/manifests/db-monitor.yaml.example | 2 +- deploy/aws/manifests/db.yaml.example | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/deploy/aws/manifests/db-monitor.yaml.example b/deploy/aws/manifests/db-monitor.yaml.example index a05ee1e9fb..b8698261ad 100644 --- a/deploy/aws/manifests/db-monitor.yaml.example +++ b/deploy/aws/manifests/db-monitor.yaml.example @@ -1,7 +1,7 @@ apiVersion: pingcap.com/v1alpha1 kind: TidbMonitor metadata: - name: DEFAULT_CLUSTER_NAME + name: CLUSTER_NAME spec: alertmanagerURL: "" annotations: {} diff --git a/deploy/aws/manifests/db.yaml.example b/deploy/aws/manifests/db.yaml.example index d39ee8fdd7..5a4eb9c2bc 100644 --- a/deploy/aws/manifests/db.yaml.example +++ b/deploy/aws/manifests/db.yaml.example @@ -1,7 +1,7 @@ apiVersion: pingcap.com/v1alpha1 kind: TidbCluster metadata: - name: DEFAULT_CLUSTER_NAME + name: CLUSTER_NAME spec: configUpdateStrategy: RollingUpdate enableTLSCluster: false @@ -20,7 +20,7 @@ spec: - zone max-replicas: 3 nodeSelector: - dedicated: DEFAULT_CLUSTER_NAME-pd + dedicated: CLUSTER_NAME-pd podSecurityContext: {} replicas: 3 requests: @@ -32,7 +32,7 @@ spec: - effect: NoSchedule key: dedicated operator: Equal - value: DEFAULT_CLUSTER_NAME-pd + value: CLUSTER_NAME-pd pvReclaimPolicy: Retain schedulerName: tidb-scheduler tidb: @@ -47,7 +47,7 @@ spec: enableTLSClient: false maxFailoverCount: 3 nodeSelector: - dedicated: DEFAULT_CLUSTER_NAME-tidb + dedicated: CLUSTER_NAME-tidb podSecurityContext: sysctls: - name: net.ipv4.tcp_keepalive_time @@ -80,7 +80,7 @@ spec: - effect: NoSchedule key: dedicated operator: Equal - value: DEFAULT_CLUSTER_NAME-tidb + value: CLUSTER_NAME-tidb tikv: affinity: {} baseImage: pingcap/tikv @@ -89,7 +89,7 @@ spec: hostNetwork: false maxFailoverCount: 3 nodeSelector: - dedicated: db-tikv + dedicated: CLUSTER_NAME-tikv podSecurityContext: {} privileged: false replicas: 3 @@ -102,7 +102,7 @@ spec: - effect: NoSchedule key: dedicated operator: Equal - value: DEFAULT_CLUSTER_NAME-tikv + value: CLUSTER_NAME-tikv timezone: UTC version: v3.0.12 From be233e740aac1860a4b0ad544e382228cdec9445 Mon Sep 17 00:00:00 2001 From: DanielZhangQD Date: Mon, 23 Mar 2020 09:44:55 +0800 Subject: [PATCH 5/6] revert default cluster name --- deploy/aws/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/aws/variables.tf b/deploy/aws/variables.tf index 4e5792d179..7691663a5c 100644 --- a/deploy/aws/variables.tf +++ b/deploy/aws/variables.tf @@ -112,7 +112,7 @@ variable "default_cluster_monitor_instance_type" { } variable "default_cluster_name" { - default = "db" + default = "my-cluster" } variable "create_tidb_cluster_release" { From 94b1bbe2a369ecf3806c6fbe96121bddcb58f724 Mon Sep 17 00:00:00 2001 From: DanielZhangQD Date: Mon, 23 Mar 2020 11:53:32 +0800 Subject: [PATCH 6/6] update cluster name --- deploy/aws/manifests/db-monitor.yaml.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/aws/manifests/db-monitor.yaml.example b/deploy/aws/manifests/db-monitor.yaml.example index b8698261ad..da607309b4 100644 --- a/deploy/aws/manifests/db-monitor.yaml.example +++ b/deploy/aws/manifests/db-monitor.yaml.example @@ -6,7 +6,7 @@ spec: alertmanagerURL: "" annotations: {} clusters: - - name: db + - name: CLUSTER_NAME grafana: baseImage: grafana/grafana envs: