Executing a command in a running container
So, we have learned how to troubleshoot pods with pod describe
and logs
, but there might be some cases when you want to do even more advanced troubleshooting, such as checking some config files or running some commands in the container. These things can be done using the kubectl exec
command, which will allow exec
into the container and have an interactive session in the container or run your commands as well.
Let's see how to get the postgresql.conf
file content using the kubectl exec
command:
$ kubectl exec postgresql-57578b68d9-6wvpw cat \ /opt/bitnami/postgresql/conf/postgresql.conf # ----------------------------- # PostgreSQL configuration file # ----------------------------- # # This file consists of lines of the form: # #   name = value # # (The "=" is optional.)  Whitespace may be used.  Comments are introduced with # "#" anywhere on a line.  The complete list...