Skip to content

Instantly share code, notes, and snippets.

@brianpursley
Created August 14, 2022 22:38
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 brianpursley/26d5805236db3fca1453dcde5bd984e9 to your computer and use it in GitHub Desktop.
Save brianpursley/26d5805236db3fca1453dcde5bd984e9 to your computer and use it in GitHub Desktop.
Script to start a postgres pod, forward port 5432 locally, and cleanup on exit
#!/bin/sh
kubectl run postgres --image=postgres --env=POSTGRES_PASSWORD=hunter2
kubectl wait --for=condition=Ready pod/postgres
cleanup() {
echo
kubectl delete pod postgres --now
}
trap cleanup INT
kubectl port-forward postgres 5432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment