Skip to content

Commit

Permalink
helm: improved commands
Browse files Browse the repository at this point in the history
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
  • Loading branch information
sougou committed Apr 15, 2020
1 parent d8808db commit f9094ed
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 36 deletions.
51 changes: 51 additions & 0 deletions examples/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Instructions

Detailed instructions for running this example can be found at https://vitess.io.
This document contains the summary of the commands to be run.


```
# Start minikube
minikube start --kubernetes-version v1.15.0 --cpus=4 --memory=5000
# 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
vmysql < ../common/insert_commerce_data.sql
vmysql --table < ../common/select_commerce_data.sql
# Bring up customer keyspace
helm upgrade vitess ../../helm/vitess/ -f 201_customer_tablets.yaml
# Initiate move tables
vclient MoveTables -workflow=commerce2customer commerce customer '{"customer":{}, "corder":{}}'
# Cut-over
vclient SwitchReads -tablet_type=rdonly customer.commerce2customer
vclient SwitchReads -tablet_type=replica customer.commerce2customer
vclient SwitchWrites customer.commerce2customer
# Clean-up
vclient SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 rdonly
vclient SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 replica
vclient SetShardTabletControl -blacklisted_tables=customer,corder -remove commerce/0 master
vclient ApplyRoutingRules -rules='{}'
# Prepare for resharding
helm upgrade vitess ../../helm/vitess/ -f 301_customer_sharded.yaml
helm upgrade vitess ../../helm/vitess/ -f 302_new_shards.yaml
# Reshard
vclient Reshard customer.cust2cust '0' '-80,80-'
vclient SwitchReads -tablet_type=rdonly customer.cust2cust
vclient SwitchReads -tablet_type=replica customer.cust2cust
vclient SwitchWrites customer.cust2cust
# Down shard 0
helm upgrade vitess ../../helm/vitess/ -f 306_down_shard_0.yaml
vclient DeleteShard -recursive customer/0
```
35 changes: 35 additions & 0 deletions examples/helm/alias.source
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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 vmysql to: mysql -h $vhost -P $vport"
alias vmysql="mysql -h $vhost -P $vport"
}

function vsetvclient() {
vhostport vtctld
if [ -z $vport ]; then
echo "Error: failed to: obtain [host:port] minikube or kubectl."
return 1
fi
echo "Setting alias vclient to vtctlclient -server=$vhost:$vport"
alias vclient="vtctlclient -server=$vhost:$vport"
}

vsetmysql
vsetvclient
36 changes: 0 additions & 36 deletions examples/helm/kmysql.sh

This file was deleted.

0 comments on commit f9094ed

Please sign in to comment.