Skip to content

Commit

Permalink
Reworking demo, adding LB for CockroachDB console and SQL connections…
Browse files Browse the repository at this point in the history
… (thanks to @jhatcher9999)
  • Loading branch information
mgoddard committed Jul 29, 2021
1 parent ca25d0a commit 4fc3f42
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
19 changes: 19 additions & 0 deletions k8s/cockroachdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,22 @@ spec:
name: cockroachdb/cockroach:v21.1.5
nodes: 3

---
apiVersion: v1
kind: Service
metadata:
name: crdb-lb
labels:
app: cockroachdb
spec:
selector:
app.kubernetes.io/name: cockroachdb
ports:
- protocol: "TCP"
port: 8080
name: dbconsole
- protocol: "TCP"
port: 26257
name: sql
type: LoadBalancer

38 changes: 15 additions & 23 deletions k8s/deploy_k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ run_cmd kubectl get pods
echo "After a couple of minutes, rerun this check"
run_cmd kubectl get pods

echo "Check to see whether the LB for DB Console and SQL is ready yet"
echo "Look for the external IP of the app in the 'LoadBalancer Ingress:' line of output"
run_cmd kubectl describe service crdb-lb
echo "If not, run 'kubectl describe service crdb-lb' in a separate window"

# 3. Add DB user for app
echo "Once all three show 'Running', use the SQL CLI to add a user for use by the Web app"
echo "Press ENTER to run this SQL"
Expand All @@ -68,11 +73,8 @@ echo "Run 'kubectl get pods' periodically until the line for 'crdb-geo-loader' s
run_cmd kubectl get pods

# 5. Start the CockroachDB DB Console
echo "First, we set up a tunnel from port $LOCAL_PORT on localhost to port 8080 on one of the CockroachDB pods"
port_fwd
URL="http://localhost:$LOCAL_PORT/"
run_cmd open $URL
echo "** Use 'tourist' as both login and password for this Admin UI **"
echo "Open a browser tab to port 8080 at the IP provided for the DB Console endpoint"
echo "** Use 'tourist' as both login and password **"

# 6. Start the Web app
echo "Press ENTER to start the CockroachDB Geo Tourist app"
Expand All @@ -87,31 +89,21 @@ run_cmd kubectl describe service crdb-geo-tourist-lb
echo "Once that IP is available, open the URL http://THIS_IP/ to see the app running"
echo

# 8. Scale out: add a node
echo "Scale out by adding a new CockroachDB pod"
run_cmd kubectl apply -f ./scale_out.yaml
echo "Run 'kubectl get pods' a couple of times to verify 4 pods are running"
echo "Check the DB Console to verify the version has changed"
echo

# 9. Perform an online rolling upgrade
echo "Perform a zero downtime upgrade of CockroachDB (note the version in the DB Console UI)"
run_cmd kubectl apply -f ./rolling_upgrade.yaml
echo "Check the DB Console to verify the version has changed"
echo
echo "If the DB Console becomes inaccessible, press ENTER to restart the port forwarding process"
read
port_fwd

# 10. Kill a node
# 8. Kill a node
echo "Kill a CockroachDB pod"
run_cmd kubectl delete pods cockroachdb-0
echo "Reload the app page to verify it continues to run"
echo "Also, note the state in the DB Console"
echo "A new pod should be started to replace the failed pod"
run_cmd kubectl get pods

# 11. Tear it down
# 9. Perform an online rolling upgrade
echo "Perform a zero downtime upgrade of CockroachDB (note the version in the DB Console UI)"
run_cmd kubectl apply -f ./rolling_upgrade.yaml
echo "Check the DB Console to verify the version has changed"
echo

# 10. Tear it down
echo
echo
echo "** Finally: tear it all down. CAREFUL -- BE SURE YOU'RE DONE! **"
Expand Down

0 comments on commit 4fc3f42

Please sign in to comment.