Search⌘ K

Playing Around with the Running Pod

Explore how to manage running Pods in Kubernetes by describing resources, executing new processes inside containers, viewing real-time logs, and handling container failures and termination. This lesson equips you with practical skills to interact and troubleshoot Pods in a Kubernetes cluster efficiently.

Describing resources

In many cases, it is more useful to describe resources by referencing the file that defines them. That way, there is no confusion or need to remember the names of resources.

Instead of using kubectl describe pod db, we could have executed the command as follows:

Shell
kubectl describe -f db.yml

The output should be the same as the previous lesson because, in both cases, kubectl sent a request to the Kubernetes API requesting information about the Pod named “db”.

Executing a new process

Just as with Docker, we can execute a new process inside a running container inside a Pod.

Shell
kubectl exec db -- ps aux

The output will be as follows:

Shell
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.5 2.9 967452 59692 ? Ssl 21:47 0:03 mongod --rest --httpinterface
root 31 0.0 0.0 17504 1980 ? Rs 21:58 0:00 ps aux

We told Kubernetes that we’d like to execute a process inside the first container of the Pod db. Since our Pod defines only one container, this container and the first container are one and the same. The --container (or -c) argument can be set to specify which container should be used. This is particularly useful when we’re running multiple containers in a Pod. ...