Db shell
Use this skill when a developer asks to "open a shell on my database", "run a SQL query", "connect to the postgres / mysql / mongo / redis", "psql into prod", or "I need to inspect data". The primary path is exec into a workload pod via k9s or `kubectl exec` and use the auto-injected DB env vars to launch the matching client. The `users.debug` RoleBinding grants `pods/exec` (and port-forward) — no extra credentials needed.From its SKILL.md
npx -y skills add lwsa-tech/platform-dev-plugin --skill db-shellAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.8 KB, as published. Nobody here has run it
Open a DB Shell
The platform injects DB endpoints and credentials as env vars into every
container that declares envVarsFrom.dbServers (or .searches /
.messageBrokers). A DB shell is therefore just: exec into a pod that
already has the vars, run the client.
Prerequisite: users.debug
Your email must be in the project's users.debug list in the blueprint.
That grants (on top of read-only view): pods/exec, pods/portforward,
reading Secrets, and scaling — see convention-cheatsheet §8. If
kubectl exec returns Forbidden, you're not on the list; ask the
project team to add you and push.
Cluster access setup (kubeconfig, OIDC login) is in dev-onboarding.
Path 1 — k9s (recommended)
k9s --context <cluster> -n <namespace>
Pick a pod of a workload that declares the dbServer in envVarsFrom
(the app's own pod is ideal — it's guaranteed to have the vars). Press
s to shell in, then run the matching client below.
Path 2 — kubectl exec (scripted)
kubectl exec -n <namespace> -it deploy/<service> -- /bin/sh
Client commands per type
Inside the pod, the vars are already set:
| Type | Shell command |
|---|---|
cnpg (Postgres) | psql "$DATABASE_URL" |
pxc (MySQL) | mysql -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" |
psmdb (MongoDB) | mongosh "$MONGODB_URI" |
ferretdb | mongosh "$MONGODB_URI" |
dragonfly (Redis) | redis-cli -h "$REDIS_HOST" -a "$REDIS_PASSWORD" |
elasticsearch | curl -u "$ELASTICSEARCH_USER:$ELASTICSEARCH_PASSWORD" "$ELASTICSEARCH_URL" |
rabbitmq | curl -u "$RABBITMQ_USER:$RABBITMQ_PASSWORD" "http://$RABBITMQ_HOST:15672/api/overview" |
Full env-var reference (including mappings renames, which may apply in
your project): convention-cheatsheet §3.
If the app image lacks the client binary
Run a throwaway pod in the same namespace — cluster DNS resolves the same service hostnames, and Cilium allows intra-namespace traffic:
kubectl run -n <namespace> -it --rm dbg --image=postgres:17 --restart=Never -- bash
# no env vars here — read them from the app pod first:
kubectl exec -n <namespace> deploy/<service> -- env | grep -E 'DB_|DATABASE'
Baseline Pod Security allows this (it's an unprivileged pod). The DB
service names, if you need them directly: <name>-rw / <name>-r
(cnpg), <name>-pxc (pxc), <name>-mongos (psmdb), <name> (dragonfly),
<name>-ferretdb (ferretdb), <name>-es-http (elasticsearch),
<name>-rabbitmq (rabbitmq).
GUI clients: port-forward
users.debug deliberately includes pods/portforward, so a local GUI
client (psql, DBeaver, Compass) can tunnel:
kubectl port-forward -n <namespace> svc/<db>-rw 5432:5432
Use it read-consciously: a laptop tunnel bypasses the app's guardrails,
and a writable prod connection is how data disappears. For anything
mutating in prod, prefer a reviewed migration Job (jobs[] with a
PostSync hook) over an interactive session.
Quick sanity queries
psql: \l \dt select now();
mysql: show databases; show tables; select now();
mongosh: show dbs; db.stats();
redis: INFO server; DBSIZE
See also
convention-cheatsheet§3 — every injected env var per type.author-blueprint—envVarsFromandmappings.troubleshoot— "exec Forbidden", connection refused, etc.