Skip to content

Instantly share code, notes, and snippets.

@mitio
Created September 27, 2017 11:53
Show Gist options
  • Save mitio/a3dee0d64a988e8b63e6b60fbd343806 to your computer and use it in GitHub Desktop.
Save mitio/a3dee0d64a988e8b63e6b60fbd343806 to your computer and use it in GitHub Desktop.
Kubernetes readiness probes experiments (with PostgreSQL)
while true; do PGCONNECT_TIMEOUT=2 psql -U receiptbank -h monolith-postgresql --list >/dev/null && date +'Host: %Y-%m-%d %H:%M:%S.%6N' || echo -n .; sleep 0.05; done
while true; do PGCONNECT_TIMEOUT=2 psql -U receiptbank -h 0.0.0.0 --list >/dev/null && date +'IP: %Y-%m-%d %H:%M:%S.%6N' || echo -n .; sleep 0.05; done
while true; do PGCONNECT_TIMEOUT=2 psql -U receiptbank --list >/dev/null && date +'Sock: %Y-%m-%d %H:%M:%S.%6N' || echo -n .; sleep 0.05; done
while ! kubectl -n probes logs --timestamps -f `kubectl get pods -n probes -l app=monolith -l component=postgresql --show-kind=false --no-headers 2>/dev/null|cut -d' ' -f1`; do echo -n .; sleep 0.1; done
while ! kubectl-exec-in probes `kubectl get pods -n probes -l app=monolith -l component=postgresql --show-kind=false --no-headers 2>/dev/null|cut -d' ' -f1` /bin/bash -lc "while true; do PGCONNECT_TIMEOUT=2 psql -U postgres -h 0.0.0.0 --list >/dev/null && date +'IP: %Y-%m-%d %H:%M:%S.%6N' || echo -n .; sleep 0.05; done" 2>/dev/null; do echo -n .; sleep 0.1; done
while ! kubectl-exec-in probes `kubectl get pods -n probes -l app=monolith -l component=postgresql --show-kind=false --no-headers 2>/dev/null|cut -d' ' -f1` /bin/bash -lc "while true; do PGCONNECT_TIMEOUT=2 psql -U postgres --list >/dev/null && date +'Sock: %Y-%m-%d %H:%M:%S.%6N' || echo -n .; sleep 0.05; done" 2>/dev/null; do echo -n .; sleep 0.1; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment