From 1360011a7231c3084e74d22574cfbf54ddff4505 Mon Sep 17 00:00:00 2001 From: Sugu Sougoumarane Date: Sat, 9 May 2020 16:11:28 -0700 Subject: [PATCH 1/5] examples: update to latest helm Also add instructions for final teardown. Signed-off-by: Sugu Sougoumarane --- examples/helm/README.md | 5 +++++ helm/vitess/values.yaml | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/helm/README.md b/examples/helm/README.md index 11af8cc427c..ce4999cab46 100644 --- a/examples/helm/README.md +++ b/examples/helm/README.md @@ -48,4 +48,9 @@ vtctlclient SwitchWrites customer.cust2cust # Down shard 0 helm upgrade vitess ../../helm/vitess/ -f 306_down_shard_0.yaml vtctlclient DeleteShard -recursive customer/0 + +# Delete deployment +helm delete vitess +kubectl delete pvc -l "app=vitess" +kubectl delete vitesstoponodes --all ``` diff --git a/helm/vitess/values.yaml b/helm/vitess/values.yaml index 054361bfe84..1ec66366ba9 100644 --- a/helm/vitess/values.yaml +++ b/helm/vitess/values.yaml @@ -182,7 +182,7 @@ etcd: # Default values for vtctld resources defined in 'topology' vtctld: serviceType: ClusterIP - vitessTag: helm-2.0.1-0 + vitessTag: helm-2.0.2-0 resources: # requests: # cpu: 100m @@ -193,7 +193,7 @@ vtctld: # Default values for vtgate resources defined in 'topology' vtgate: serviceType: ClusterIP - vitessTag: helm-2.0.1-0 + vitessTag: helm-2.0.2-0 resources: # requests: # cpu: 500m @@ -212,13 +212,13 @@ vtgate: # Default values for vtctlclient resources defined in 'topology' vtctlclient: - vitessTag: helm-2.0.1-0 + vitessTag: helm-2.0.2-0 extraFlags: {} secrets: [] # secrets are mounted under /vt/usersecrets/{secretname} # Default values for vtworker resources defined in 'jobs' vtworker: - vitessTag: helm-2.0.1-0 + vitessTag: helm-2.0.2-0 extraFlags: {} resources: # requests: @@ -229,7 +229,7 @@ vtworker: # Default values for vttablet resources defined in 'topology' vttablet: - vitessTag: helm-2.0.1-0 + vitessTag: helm-2.0.2-0 # valid values are # - mysql56 (for MySQL 8.0) From 328f3956fd37770c88ca812838f85c0cbdc2819a Mon Sep 17 00:00:00 2001 From: Sugu Sougoumarane Date: Sun, 10 May 2020 16:07:36 -0700 Subject: [PATCH 2/5] examples: use newer commands Signed-off-by: Sugu Sougoumarane --- examples/helm/README.md | 16 +++++++++------- examples/helm/alias.source | 35 ----------------------------------- examples/helm/kvtctld.sh | 19 ------------------- examples/helm/pf.sh | 14 ++++++++++++++ examples/local/README.md | 13 +++++++++---- 5 files changed, 32 insertions(+), 65 deletions(-) delete mode 100644 examples/helm/alias.source delete mode 100755 examples/helm/kvtctld.sh create mode 100755 examples/helm/pf.sh diff --git a/examples/helm/README.md b/examples/helm/README.md index ce4999cab46..dcf017a727e 100644 --- a/examples/helm/README.md +++ b/examples/helm/README.md @@ -11,9 +11,6 @@ minikube start --cpus=4 --memory=8000 # Bring up initial cluster and commerce keyspace helm install vitess ../../helm/vitess -f 101_initial_cluster.yaml -# Setup aliases -source alias.source - # Insert and verify data mysql < ../common/insert_commerce_data.sql mysql --table < ../common/select_commerce_data.sql @@ -24,16 +21,16 @@ helm upgrade vitess ../../helm/vitess/ -f 201_customer_tablets.yaml # Initiate move tables vtctlclient MoveTables -workflow=commerce2customer commerce customer '{"customer":{}, "corder":{}}' +# Validate +vtctlclient VDiff customer.commerce2customer + # Cut-over vtctlclient SwitchReads -tablet_type=rdonly customer.commerce2customer vtctlclient SwitchReads -tablet_type=replica customer.commerce2customer vtctlclient SwitchWrites customer.commerce2customer # Clean-up -vtctlclient SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 rdonly -vtctlclient SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 replica -vtctlclient SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 master -vtctlclient ApplyRoutingRules -rules='{}' +vtctlclient DropSources customer.commerce2customer # Prepare for resharding helm upgrade vitess ../../helm/vitess/ -f 301_customer_sharded.yaml @@ -41,6 +38,11 @@ helm upgrade vitess ../../helm/vitess/ -f 302_new_shards.yaml # Reshard vtctlclient Reshard customer.cust2cust '0' '-80,80-' + +# Validate +vtctlclient VDiff customer.cust2cust + +# Cut-over vtctlclient SwitchReads -tablet_type=rdonly customer.cust2cust vtctlclient SwitchReads -tablet_type=replica customer.cust2cust vtctlclient SwitchWrites customer.cust2cust diff --git a/examples/helm/alias.source b/examples/helm/alias.source deleted file mode 100644 index f10a5d6a47d..00000000000 --- a/examples/helm/alias.source +++ /dev/null @@ -1,35 +0,0 @@ -function vhostport() { - vhost=$(minikube service $1 --url=true --format="{{.IP}}" | tail -n 1) - vport=$(minikube service $1 --url=true --format="{{.Port}}" | tail -n 1) - - if [ -z $vport ]; then - # This checks K8s running on an single node by kubeadm - if [ $(kubectl get nodes | grep -v NAM | wc -l) -eq 1 -o $(kubectl get nodes | grep -v NAM | grep master | wc -l ) -eq 1 ]; then - vhost="127.0.0.1" - vport=`kubectl describe service vtgate-zone1 | grep NodePort | grep mysql | awk '{print $3}' | awk -F'/' '{print $1}'` - fi - fi -} - -function vsetmysql() { - vhostport vtgate-zone1 - if [ -z $vport ]; then - echo "Error: failed to obtain [host:port] minikube or kubectl." - return 1 - fi - echo "Setting alias mysql to: mysql -h $vhost -P $vport" - alias mysql="mysql -h $vhost -P $vport" -} - -function vsetvtctlclient() { - vhostport vtctld - if [ -z $vport ]; then - echo "Error: failed to: obtain [host:port] minikube or kubectl." - return 1 - fi - echo "Setting alias vtctlclient to vtctlclient -server=$vhost:$vport" - alias vtctlclient="vtctlclient -server=$vhost:$vport" -} - -vsetmysql -vsetvtctlclient diff --git a/examples/helm/kvtctld.sh b/examples/helm/kvtctld.sh deleted file mode 100755 index 2499e706301..00000000000 --- a/examples/helm/kvtctld.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Copyright 2019 The Vitess Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This is a convenience script to run vtctlclient against the local example. - -xdg-open "$(minikube service vtctld --url|head -n 1)" diff --git a/examples/helm/pf.sh b/examples/helm/pf.sh new file mode 100755 index 00000000000..5f8fee8bda7 --- /dev/null +++ b/examples/helm/pf.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +kubectl port-forward service/vtctld 15000 15999 & +process_id1=$! +kubectl port-forward service/vtgate-zone1 15306:3306 15001 & +process_id2=$! +sleep 2 +echo "You may point your browser to http://localhost:15000 for vtctld." +echo "You may point your browser to http://localhost:15001 for vtgate, use the following aliases as shortcuts:" +echo 'alias vtctlclient="vtctlclient -server=localhost:15999"' +echo 'alias mysql="mysql -h 127.0.0.1 -P 15306"' +echo "Hit Ctrl-C to stop the port forwards" +wait $process_id1 +wait $process_id2 diff --git a/examples/local/README.md b/examples/local/README.md index 46f647e7aff..c6d8510cc52 100644 --- a/examples/local/README.md +++ b/examples/local/README.md @@ -21,16 +21,16 @@ mysql --table < ../common/select_commerce_data.sql # Initiate move tables vtctlclient MoveTables -workflow=commerce2customer commerce customer '{"customer":{}, "corder":{}}' +# Validate +vtctlclient VDiff customer.commerce2customer + # Cut-over vtctlclient SwitchReads -tablet_type=rdonly customer.commerce2customer vtctlclient SwitchReads -tablet_type=replica customer.commerce2customer vtctlclient SwitchWrites customer.commerce2customer # Clean-up -vtctlclient SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 rdonly -vtctlclient SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 replica -vtctlclient SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 master -vtctlclient ApplyRoutingRules -rules='{}' +vtctlclient DropSources customer.commerce2customer # Prepare for resharding ./301_customer_sharded.sh @@ -38,6 +38,11 @@ vtctlclient ApplyRoutingRules -rules='{}' # Reshard vtctlclient Reshard customer.cust2cust '0' '-80,80-' + +# Validate +vtctlclient VDiff customer.cust2cust + +# Cut-over vtctlclient SwitchReads -tablet_type=rdonly customer.cust2cust vtctlclient SwitchReads -tablet_type=replica customer.cust2cust vtctlclient SwitchWrites customer.cust2cust From 5086f5d71d46d56682d9125f6aeaad68496fb5dc Mon Sep 17 00:00:00 2001 From: Sugu Sougoumarane Date: Sun, 10 May 2020 17:42:19 -0700 Subject: [PATCH 3/5] helm: more efficient and simplified examples Signed-off-by: Sugu Sougoumarane --- examples/helm/101_initial_cluster.yaml | 15 +-------- examples/helm/201_customer_tablets.yaml | 15 +-------- examples/helm/202_move_tables.yaml | 15 +-------- examples/helm/203_switch_reads.yaml | 15 +-------- examples/helm/204_switch_writes.yaml | 15 +-------- examples/helm/205_clean_commerce.yaml | 15 +-------- examples/helm/301_customer_sharded.yaml | 15 +-------- examples/helm/302_new_shards.yaml | 15 +-------- examples/helm/303_reshard.yaml | 15 +-------- examples/helm/304_switch_reads.yaml | 15 +-------- examples/helm/305_switch_writes.yaml | 15 +-------- examples/helm/306_down_shard_0.yaml | 15 +-------- examples/helm/307_delete_shard_0.yaml | 15 +-------- examples/helm/308_final.yaml | 15 +-------- helm/vitess/templates/_vttablet.tpl | 41 +++++++++++++++++++------ helm/vitess/values.yaml | 4 +++ 16 files changed, 50 insertions(+), 205 deletions(-) diff --git a/examples/helm/101_initial_cluster.yaml b/examples/helm/101_initial_cluster.yaml index 2992f2c83ae..b17aa9e7ce0 100644 --- a/examples/helm/101_initial_cluster.yaml +++ b/examples/helm/101_initial_cluster.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -46,24 +47,10 @@ topology: } } -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/201_customer_tablets.yaml b/examples/helm/201_customer_tablets.yaml index fba4940100b..1ef3f7f080f 100644 --- a/examples/helm/201_customer_tablets.yaml +++ b/examples/helm/201_customer_tablets.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -24,24 +25,10 @@ topology: vttablet: replicas: 3 -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/202_move_tables.yaml b/examples/helm/202_move_tables.yaml index a08f9311545..e06e90be13f 100644 --- a/examples/helm/202_move_tables.yaml +++ b/examples/helm/202_move_tables.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -29,24 +30,10 @@ jobs: kind: "vtctlclient" command: "MoveTables -workflow=commerce2customer commerce customer \'{\"customer\":{}, \"corder\":{}}\'" -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/203_switch_reads.yaml b/examples/helm/203_switch_reads.yaml index 940b1fb04dc..5d06c37fda4 100644 --- a/examples/helm/203_switch_reads.yaml +++ b/examples/helm/203_switch_reads.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -32,24 +33,10 @@ jobs: kind: "vtctlclient" command: "SwitchReads -tablet_type=replica customer.commerce2customer" -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/204_switch_writes.yaml b/examples/helm/204_switch_writes.yaml index fb38ad6d344..18716ce2198 100644 --- a/examples/helm/204_switch_writes.yaml +++ b/examples/helm/204_switch_writes.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -29,24 +30,10 @@ jobs: kind: "vtctlclient" command: "SwitchWrites customer.commerce2customer" -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/205_clean_commerce.yaml b/examples/helm/205_clean_commerce.yaml index ce4437dc9c8..5ee2cb98ab7 100644 --- a/examples/helm/205_clean_commerce.yaml +++ b/examples/helm/205_clean_commerce.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -49,24 +50,10 @@ jobs: kind: "vtctlclient" command: "ApplyRoutingRules -rules=\'{}\'" -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/301_customer_sharded.yaml b/examples/helm/301_customer_sharded.yaml index 306b1ff18de..23ba4e927e2 100644 --- a/examples/helm/301_customer_sharded.yaml +++ b/examples/helm/301_customer_sharded.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -83,24 +84,10 @@ topology: } } -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/302_new_shards.yaml b/examples/helm/302_new_shards.yaml index 85eff65b450..d055a0548b6 100644 --- a/examples/helm/302_new_shards.yaml +++ b/examples/helm/302_new_shards.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -38,24 +39,10 @@ topology: copySchema: source: "customer/0" -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/303_reshard.yaml b/examples/helm/303_reshard.yaml index cd7a0237d1b..bfb17630ef1 100644 --- a/examples/helm/303_reshard.yaml +++ b/examples/helm/303_reshard.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -39,24 +40,10 @@ jobs: kind: "vtctlclient" command: "Reshard customer.cust2cust \'0\' \'-80,80-\'" -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/304_switch_reads.yaml b/examples/helm/304_switch_reads.yaml index fbdf578fa2e..7cd4bf44980 100644 --- a/examples/helm/304_switch_reads.yaml +++ b/examples/helm/304_switch_reads.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -42,24 +43,10 @@ jobs: kind: "vtctlclient" command: "SwitchReads -tablet_type=replica customer.cust2cust" -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/305_switch_writes.yaml b/examples/helm/305_switch_writes.yaml index 6316f45c2eb..bd7848873f3 100644 --- a/examples/helm/305_switch_writes.yaml +++ b/examples/helm/305_switch_writes.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -39,24 +40,10 @@ jobs: kind: "vtctlclient" command: "SwitchWrites customer.cust2cust" -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/306_down_shard_0.yaml b/examples/helm/306_down_shard_0.yaml index 7bbc7ef62ed..c9ab143922a 100644 --- a/examples/helm/306_down_shard_0.yaml +++ b/examples/helm/306_down_shard_0.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -29,24 +30,10 @@ topology: vttablet: replicas: 3 -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/307_delete_shard_0.yaml b/examples/helm/307_delete_shard_0.yaml index 59de5b2f369..7f628a2a3d0 100644 --- a/examples/helm/307_delete_shard_0.yaml +++ b/examples/helm/307_delete_shard_0.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -34,24 +35,10 @@ jobs: kind: "vtctlclient" command: "DeleteShard -recursive customer/0" -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/examples/helm/308_final.yaml b/examples/helm/308_final.yaml index 7bbc7ef62ed..c9ab143922a 100644 --- a/examples/helm/308_final.yaml +++ b/examples/helm/308_final.yaml @@ -1,4 +1,5 @@ topology: + deploymentType: test cells: - name: "zone1" vtctld: @@ -29,24 +30,10 @@ topology: vttablet: replicas: 3 -vtctld: - serviceType: "NodePort" - resources: - -vtgate: - serviceType: "NodePort" - resources: - vttablet: - mysqlSize: "prod" - resources: - mysqlResources: # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 -vtworker: - resources: - pmm: enabled: false diff --git a/helm/vitess/templates/_vttablet.tpl b/helm/vitess/templates/_vttablet.tpl index 192873b1b1b..63711eb1180 100644 --- a/helm/vitess/templates/_vttablet.tpl +++ b/helm/vitess/templates/_vttablet.tpl @@ -132,19 +132,26 @@ spec: serviceAccountName: vttablet terminationGracePeriodSeconds: {{ $defaultVttablet.terminationGracePeriodSeconds | default 60000000 }} {{ include "pod-security" . | indent 6 }} + +{{ if eq ($topology.deploymentType | default "prod") "prod" }} {{ include "vttablet-affinity" (tuple $cellClean $keyspaceClean $shardClean $cell.region) | indent 6 }} +{{ end }} initContainers: -{{ include "init-mysql" (tuple $vitessTag $cellClean) | indent 8 }} -{{ include "init-vttablet" (tuple $vitessTag $cell $cellClean $namespace) | indent 8 }} +{{ include "init-mysql" (tuple $topology $vitessTag $cellClean) | indent 8 }} +{{ include "init-vttablet" (tuple $topology $vitessTag $cell $cellClean $namespace) | indent 8 }} containers: {{ include "cont-mysql" (tuple $topology $cell $keyspace $shard $tablet $defaultVttablet $uid) | indent 8 }} {{ include "cont-vttablet" (tuple $topology $cell $keyspace $shard $tablet $defaultVttablet $defaultVtctlclient $vitessTag $uid $namespace $config $orc) | indent 8 }} + +{{ if eq ($topology.deploymentType | default "prod") "prod" }} {{ include "cont-logrotate" . | indent 8 }} {{ include "cont-mysql-generallog" . | indent 8 }} {{ include "cont-mysql-errorlog" . | indent 8 }} {{ include "cont-mysql-slowlog" . | indent 8 }} +{{ end }} + {{ if $pmm.enabled }}{{ include "cont-pmm-client" (tuple $pmm $namespace $keyspace) | indent 8 }}{{ end }} volumes: @@ -196,12 +203,18 @@ spec: # init-container to copy binaries for mysql ################################### {{ define "init-mysql" -}} -{{- $vitessTag := index . 0 -}} -{{- $cellClean := index . 1 }} +{{- $topology := index . 0 -}} +{{- $vitessTag := index . 1 -}} +{{- $cellClean := index . 2 }} - name: "init-mysql" image: "vitess/mysqlctld:{{$vitessTag}}" imagePullPolicy: IfNotPresent +{{ if eq ($topology.deploymentType | default "prod") "test" }} + resources: + requests: + cpu: 10m +{{ end }} volumeMounts: - name: vtdataroot mountPath: "/vtdataroot" @@ -239,14 +252,20 @@ spec: # into a 31-bit unsigned integer for use as a Vitess tablet UID. ################################### {{ define "init-vttablet" -}} -{{- $vitessTag := index . 0 -}} -{{- $cell := index . 1 -}} -{{- $cellClean := index . 2 -}} -{{- $namespace := index . 3 }} +{{- $topology := index . 0 -}} +{{- $vitessTag := index . 1 -}} +{{- $cell := index . 2 -}} +{{- $cellClean := index . 3 -}} +{{- $namespace := index . 4 }} - name: init-vttablet image: "vitess/vtctl:{{$vitessTag}}" imagePullPolicy: IfNotPresent +{{ if eq ($topology.deploymentType | default "prod") "test" }} + resources: + requests: + cpu: 10m +{{ end }} volumeMounts: - name: vtdataroot mountPath: "/vtdataroot" @@ -559,7 +578,7 @@ spec: - | set -ex {{ include "mycnf-exec" (.extraMyCnf | default $defaultVttablet.extraMyCnf) | indent 6 }} -{{- if eq (.mysqlSize | default $defaultVttablet.mysqlSize) "test" }} +{{- if eq ($topology.deploymentType | default "prod") "test" }} export EXTRA_MY_CNF="$EXTRA_MY_CNF:/vt/config/mycnf/default-fast.cnf" {{- end }} @@ -577,6 +596,10 @@ spec: {{- end -}} {{- end -}} +#################################### +# Everything below here is enabled only if deploymentType is prod. +#################################### + ########################## # run logrotate for all log files in /vtdataroot/tabletdata ########################## diff --git a/helm/vitess/values.yaml b/helm/vitess/values.yaml index 1ec66366ba9..7f63f52b5d7 100644 --- a/helm/vitess/values.yaml +++ b/helm/vitess/values.yaml @@ -72,6 +72,10 @@ config: s3Secret: vitess-s3-creds topology: + # deploymentType can be "test" or "prod". Default is "prod". + # If the value is "test", then mysql is instanitated with a smaller footprint. + # For vttablet, additional containers like log-rotate, etc will not be brought up. + deploymentType: prod globalCell: topologyProvider: k8s etcd: From a7731e5479ac1ad913ab3736ee09bea1cc4b6c82 Mon Sep 17 00:00:00 2001 From: Sugu Sougoumarane Date: Sun, 10 May 2020 18:57:56 -0700 Subject: [PATCH 4/5] helm: address review comments Signed-off-by: Sugu Sougoumarane --- examples/helm/101_initial_cluster.yaml | 1 - examples/helm/201_customer_tablets.yaml | 1 - examples/helm/202_move_tables.yaml | 1 - examples/helm/203_switch_reads.yaml | 1 - examples/helm/204_switch_writes.yaml | 1 - examples/helm/205_clean_commerce.yaml | 1 - examples/helm/301_customer_sharded.yaml | 1 - examples/helm/302_new_shards.yaml | 1 - examples/helm/303_reshard.yaml | 1 - examples/helm/304_switch_reads.yaml | 1 - examples/helm/305_switch_writes.yaml | 1 - examples/helm/306_down_shard_0.yaml | 1 - examples/helm/307_delete_shard_0.yaml | 1 - examples/helm/308_final.yaml | 1 - 14 files changed, 14 deletions(-) diff --git a/examples/helm/101_initial_cluster.yaml b/examples/helm/101_initial_cluster.yaml index b17aa9e7ce0..237d65264cc 100644 --- a/examples/helm/101_initial_cluster.yaml +++ b/examples/helm/101_initial_cluster.yaml @@ -48,7 +48,6 @@ topology: } vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/201_customer_tablets.yaml b/examples/helm/201_customer_tablets.yaml index 1ef3f7f080f..d3bb7403f84 100644 --- a/examples/helm/201_customer_tablets.yaml +++ b/examples/helm/201_customer_tablets.yaml @@ -26,7 +26,6 @@ topology: replicas: 3 vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/202_move_tables.yaml b/examples/helm/202_move_tables.yaml index e06e90be13f..0e04ea377b6 100644 --- a/examples/helm/202_move_tables.yaml +++ b/examples/helm/202_move_tables.yaml @@ -31,7 +31,6 @@ jobs: command: "MoveTables -workflow=commerce2customer commerce customer \'{\"customer\":{}, \"corder\":{}}\'" vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/203_switch_reads.yaml b/examples/helm/203_switch_reads.yaml index 5d06c37fda4..e387ba84429 100644 --- a/examples/helm/203_switch_reads.yaml +++ b/examples/helm/203_switch_reads.yaml @@ -34,7 +34,6 @@ jobs: command: "SwitchReads -tablet_type=replica customer.commerce2customer" vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/204_switch_writes.yaml b/examples/helm/204_switch_writes.yaml index 18716ce2198..1fc09d9ad0a 100644 --- a/examples/helm/204_switch_writes.yaml +++ b/examples/helm/204_switch_writes.yaml @@ -31,7 +31,6 @@ jobs: command: "SwitchWrites customer.commerce2customer" vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/205_clean_commerce.yaml b/examples/helm/205_clean_commerce.yaml index 5ee2cb98ab7..2bd5b60af6f 100644 --- a/examples/helm/205_clean_commerce.yaml +++ b/examples/helm/205_clean_commerce.yaml @@ -51,7 +51,6 @@ jobs: command: "ApplyRoutingRules -rules=\'{}\'" vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/301_customer_sharded.yaml b/examples/helm/301_customer_sharded.yaml index 23ba4e927e2..34c6c7edcde 100644 --- a/examples/helm/301_customer_sharded.yaml +++ b/examples/helm/301_customer_sharded.yaml @@ -85,7 +85,6 @@ topology: } vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/302_new_shards.yaml b/examples/helm/302_new_shards.yaml index d055a0548b6..7acc253f556 100644 --- a/examples/helm/302_new_shards.yaml +++ b/examples/helm/302_new_shards.yaml @@ -40,7 +40,6 @@ topology: source: "customer/0" vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/303_reshard.yaml b/examples/helm/303_reshard.yaml index bfb17630ef1..772549f7c97 100644 --- a/examples/helm/303_reshard.yaml +++ b/examples/helm/303_reshard.yaml @@ -41,7 +41,6 @@ jobs: command: "Reshard customer.cust2cust \'0\' \'-80,80-\'" vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/304_switch_reads.yaml b/examples/helm/304_switch_reads.yaml index 7cd4bf44980..4c4adad6398 100644 --- a/examples/helm/304_switch_reads.yaml +++ b/examples/helm/304_switch_reads.yaml @@ -44,7 +44,6 @@ jobs: command: "SwitchReads -tablet_type=replica customer.cust2cust" vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/305_switch_writes.yaml b/examples/helm/305_switch_writes.yaml index bd7848873f3..cba04977c3f 100644 --- a/examples/helm/305_switch_writes.yaml +++ b/examples/helm/305_switch_writes.yaml @@ -41,7 +41,6 @@ jobs: command: "SwitchWrites customer.cust2cust" vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/306_down_shard_0.yaml b/examples/helm/306_down_shard_0.yaml index c9ab143922a..28297b42c80 100644 --- a/examples/helm/306_down_shard_0.yaml +++ b/examples/helm/306_down_shard_0.yaml @@ -31,7 +31,6 @@ topology: replicas: 3 vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/307_delete_shard_0.yaml b/examples/helm/307_delete_shard_0.yaml index 7f628a2a3d0..3ff4b6e364d 100644 --- a/examples/helm/307_delete_shard_0.yaml +++ b/examples/helm/307_delete_shard_0.yaml @@ -36,7 +36,6 @@ jobs: command: "DeleteShard -recursive customer/0" vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: diff --git a/examples/helm/308_final.yaml b/examples/helm/308_final.yaml index c9ab143922a..28297b42c80 100644 --- a/examples/helm/308_final.yaml +++ b/examples/helm/308_final.yaml @@ -31,7 +31,6 @@ topology: replicas: 3 vttablet: - # It's generally not recommended to override this value for production usage. terminationGracePeriodSeconds: 1 pmm: From 761bab89f71a965f58248f2bda08c98377f8f3b9 Mon Sep 17 00:00:00 2001 From: Sugu Sougoumarane Date: Sun, 10 May 2020 20:56:31 -0700 Subject: [PATCH 5/5] helm: remove special-casing for init containers They don't eat into the resource budget Signed-off-by: Sugu Sougoumarane --- helm/vitess/templates/_vttablet.tpl | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/helm/vitess/templates/_vttablet.tpl b/helm/vitess/templates/_vttablet.tpl index 63711eb1180..4c168dc1572 100644 --- a/helm/vitess/templates/_vttablet.tpl +++ b/helm/vitess/templates/_vttablet.tpl @@ -210,11 +210,6 @@ spec: - name: "init-mysql" image: "vitess/mysqlctld:{{$vitessTag}}" imagePullPolicy: IfNotPresent -{{ if eq ($topology.deploymentType | default "prod") "test" }} - resources: - requests: - cpu: 10m -{{ end }} volumeMounts: - name: vtdataroot mountPath: "/vtdataroot" @@ -261,11 +256,6 @@ spec: - name: init-vttablet image: "vitess/vtctl:{{$vitessTag}}" imagePullPolicy: IfNotPresent -{{ if eq ($topology.deploymentType | default "prod") "test" }} - resources: - requests: - cpu: 10m -{{ end }} volumeMounts: - name: vtdataroot mountPath: "/vtdataroot"