Kubernetes Run Bash / Get Logs for Pod in Namespace

Here are some useful commands for managing pods within a given namespace.

List Pods in Namespace “qaas”

This will show you all the available pods in the given namespace.

$> kubectl get pods -n qaas
dapper-kudu-pgadmin-694bdf8c7f-ljcc4 1/1 Running 0 9h

Get Logs for Pod

After finding the pod name, you can view its logs centrally from kubernetes which is very cool.

$> kubectl logs dapper-kudu-pgadmin-694bdf8c7f-ljcc4 -n qaas
::ffff: - - [01/Nov/2019:13:18:26 +0000] "GET / HTTP...
::ffff: - - [01/Nov/2019:13:18:26 +0000] "GET /login?...

Exec Into Pod And Run a Shell

This will let you get into the pod with a shell (like BASH) so that you can look around and see what’s going on.

$> kubectl exec -it dapper-kudu-pgadmin-694bdf8c7f-ljcc4 /bin/sh -n qaas
/pgadmin4 #



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s