Search⌘ K

Playing with Running Pods

Explore how to manage and interact with running Kubernetes pods using kubectl. Learn to forward ports, stream application logs live, execute commands inside containers, and safely terminate pods while understanding practical use cases for debugging and failure simulation.

After we have a pod running, we can interact with it in a few different ways. Let’s see a few examples.

First, let’s run the pod from our previous example by using the following command:

kubectl apply -f nginx.yaml

To access the application locally, you need to run:

kubectl port-forward nginx 3001:80

Note: Please wait for the pods to be in a running state before executing the port-forward command.

But to access the application on this platform, you need to add an additional address flag. After running the port-forward command, in order to run further commands, we can open a new terminal, or we can run the port-forward command with nohup.

kubectl port-forward --address 0.0.0.0 nginx 3001:80

Note: nohup is a POSIX command which ...