Skip to content

Instantly share code, notes, and snippets.

@edonosotti
Last active June 9, 2020 17:17
Show Gist options
  • Save edonosotti/90df8cd83401d1eaec0ce9621bfec8a3 to your computer and use it in GitHub Desktop.
Save edonosotti/90df8cd83401d1eaec0ce9621bfec8a3 to your computer and use it in GitHub Desktop.
Quick PostgreSQL Maintenance Access in Kubernetes
#!/bin/bash
# Scenario: the database server is running outside of Kubernetes
# and it is in a private network.
# The database connection string is stored into a ConfigMap named:
# `MY_CONFIG_MAP` and its variable name is: `DATABASE_CONNECTION_STRING`.
# We don't want to copy & paste the connection string into the
# command line, we want it to be automatically pulled from the config and
# piped into the command.
kubectl run -i --tty --rm pgclient --image=jbergknoff/postgresql-client \
`kubectl get configmap MY_CONFIG_MAP -o=jsonpath='{.data.DATABASE_CONNECTION_STRING}'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment