Skip to content

Commit

Permalink
examples/operator: Change recommended port-forward shell aliases.
Browse files Browse the repository at this point in the history
Naming the aliases the same as the underlying command has been
tripping up users. Also fix port-forwarding for the possibility of
multiple query results, and send vtctl output to the console by default
instead of log files.

Signed-off-by: Anthony Yeh <enisoc@planetscale.com>
  • Loading branch information
enisoc committed Jul 7, 2020
1 parent c43bab5 commit cbf33ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
38 changes: 19 additions & 19 deletions examples/operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,47 @@ kubectl apply -f operator.yaml
# Bring up initial cluster and commerce keyspace
kubectl apply -f 101_initial_cluster.yaml
vtctlclient ApplySchema -sql="$(cat create_commerce_schema.sql)" commerce
vtctlclient ApplyVSchema -vschema="$(cat vschema_commerce_initial.json)" commerce
kvtctl ApplySchema -sql="$(cat create_commerce_schema.sql)" commerce
kvtctl ApplyVSchema -vschema="$(cat vschema_commerce_initial.json)" commerce
# Insert and verify data
mysql < ../common/insert_commerce_data.sql
mysql --table < select_commerce_data.sql
kmysql < ../common/insert_commerce_data.sql
kmysql --table < select_commerce_data.sql
# Bring up customer keyspace
kubectl apply -f 201_customer_tablets.yaml
# Initiate move tables
vtctlclient MoveTables -workflow=commerce2customer commerce customer '{"customer":{}, "corder":{}}'
kvtctl MoveTables -workflow=commerce2customer commerce customer '{"customer":{}, "corder":{}}'
# Validate
vtctlclient VDiff customer.commerce2customer
kvtctl VDiff customer.commerce2customer
# Cut-over
vtctlclient SwitchReads -tablet_type=rdonly customer.commerce2customer
vtctlclient SwitchReads -tablet_type=replica customer.commerce2customer
vtctlclient SwitchWrites customer.commerce2customer
kvtctl SwitchReads -tablet_type=rdonly customer.commerce2customer
kvtctl SwitchReads -tablet_type=replica customer.commerce2customer
kvtctl SwitchWrites customer.commerce2customer
# Clean-up
vtctlclient DropSources customer.commerce2customer
kvtctl DropSources customer.commerce2customer
# Prepare for resharding
vtctlclient ApplySchema -sql="$(cat create_commerce_seq.sql)" commerce
vtctlclient ApplyVSchema -vschema="$(cat vschema_commerce_seq.json)" commerce
vtctlclient ApplySchema -sql="$(cat create_customer_sharded.sql)" customer
vtctlclient ApplyVSchema -vschema="$(cat vschema_customer_sharded.json)" customer
kvtctl ApplySchema -sql="$(cat create_commerce_seq.sql)" commerce
kvtctl ApplyVSchema -vschema="$(cat vschema_commerce_seq.json)" commerce
kvtctl ApplySchema -sql="$(cat create_customer_sharded.sql)" customer
kvtctl ApplyVSchema -vschema="$(cat vschema_customer_sharded.json)" customer
kubectl apply -f 302_new_shards.yaml
# Reshard
vtctlclient Reshard customer.cust2cust '-' '-80,80-'
kvtctl Reshard customer.cust2cust '-' '-80,80-'
# Validate
vtctlclient VDiff customer.cust2cust
kvtctl VDiff customer.cust2cust
# Cut-over
vtctlclient SwitchReads -tablet_type=rdonly customer.cust2cust
vtctlclient SwitchReads -tablet_type=replica customer.cust2cust
vtctlclient SwitchWrites customer.cust2cust
kvtctl SwitchReads -tablet_type=rdonly customer.cust2cust
kvtctl SwitchReads -tablet_type=replica customer.cust2cust
kvtctl SwitchWrites customer.cust2cust
# Down shard 0
kubectl apply -f 306_down_shard_0.yaml
Expand Down
8 changes: 4 additions & 4 deletions examples/operator/pf.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh

kubectl port-forward --address localhost deployment/"$(kubectl get deployment --selector="planetscale.com/component=vtctld" -o=jsonpath="{.items..metadata.name}")" 15000 15999 &
kubectl port-forward --address localhost "$(kubectl get service --selector="planetscale.com/component=vtctld" -o name | head -n1)" 15000 15999 &
process_id1=$!
kubectl port-forward --address localhost deployment/"$(kubectl get deployment --selector="planetscale.com/component=vtgate" -o=jsonpath="{.items..metadata.name}")" 15306:3306 &
kubectl port-forward --address localhost "$(kubectl get service --selector="planetscale.com/component=vtgate,!planetscale.com/cell" -o name | head -n1)" 15306:3306 &
process_id2=$!
sleep 2
echo "You may point your browser to http://localhost:15000, use the following aliases as shortcuts:"
echo 'alias vtctlclient="vtctlclient -server=localhost:15999"'
echo 'alias mysql="mysql -h 127.0.0.1 -P 15306 -u user"'
echo 'alias kvtctl="vtctlclient -server=localhost:15999 -logtostderr"'
echo 'alias kmysql="mysql -h 127.0.0.1 -P 15306 -u user"'
echo "Hit Ctrl-C to stop the port forwards"
wait $process_id1
wait $process_id2

0 comments on commit cbf33ff

Please sign in to comment.