Skip to content

Instantly share code, notes, and snippets.

@rudolfratusinski
Last active August 1, 2019 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rudolfratusinski/c324df303455e0094d57d41bf36c5ec1 to your computer and use it in GitHub Desktop.
Save rudolfratusinski/c324df303455e0094d57d41bf36c5ec1 to your computer and use it in GitHub Desktop.
How to run and install TimescaleDB Stolon cluster
## Create a new Kubernetes cluster on GCP
gcloud container clusters create demo-cluster --machine-type=n1-standard-4
## Initialize Helm on the cluster
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
## Create K8s Secrets for access and replication
kubectl create secret generic timescale-root --from-literal=username='root_username' --from-literal=password='root_password'
kubectl create secret generic timescale-rep --from-literal=username='rep_username' --from-literal=password='rep_password'
# Install Helm chart
helm install --name timescale-stolon-demo -f /my/path/to/stolon/values.yaml /my/path/to/stolon
# Check the status of the installed Helm application
helm status timescale-stolon-demo
# Get all information about Stolon cluster. Write down Proxy IP address and check if Keeper, Proxy and Sentinel pods are running properly
kubectl get all
# Run separate Ubuntu container for testing
kubectl run my-shell --rm -i --tty --image ubuntu -- bash
## INSIDE Ubuntu:
# Install postgresql tools, swap 10.0.0.2 with written down Proxy IP address
apt-get update
apt-get install postgresql-client -y
watch -n 1 -b pg_isready -h 10.0.0.2 -U root_username
# Create demo database, swap 10.0.0.2 with written down Proxy IP address
createdb demo --host 10.0.0.2 --username "root_username"
##
## ADDITIONAL:
# Check if a chosen pod (timescale-stolon-demo-keeper-X where X is a pod index) is Keeper master node (pg_is_in_recovery() false)
kubectl exec -it timescale-stolon-demo-keeper-X -- psql --host 127.0.0.1 --port 5432 --username root_username -W -d demo -c 'select pg_is_in_recovery()'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment