diff --git a/examples/helm/101_initial_cluster.yaml b/examples/helm/101_initial_cluster.yaml index 2992f2c83ae..237d65264cc 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,9 @@ 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..d3bb7403f84 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,9 @@ 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..0e04ea377b6 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,9 @@ 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..e387ba84429 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,9 @@ 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..1fc09d9ad0a 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,9 @@ 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..2bd5b60af6f 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,9 @@ 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..34c6c7edcde 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,9 @@ 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..7acc253f556 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,9 @@ 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..772549f7c97 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,9 @@ 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..4c4adad6398 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,9 @@ 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..cba04977c3f 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,9 @@ 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..28297b42c80 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,9 @@ 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..3ff4b6e364d 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,9 @@ 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..28297b42c80 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,9 @@ 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/README.md b/examples/helm/README.md index 11af8cc427c..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 @@ -48,4 +50,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/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 diff --git a/helm/vitess/templates/_vttablet.tpl b/helm/vitess/templates/_vttablet.tpl index 192873b1b1b..4c168dc1572 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,8 +203,9 @@ 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}}" @@ -239,10 +247,11 @@ 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}}" @@ -559,7 +568,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 +586,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 054361bfe84..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: @@ -182,7 +186,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 +197,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 +216,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 +233,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)