FreeKB - OpenShift View pod logs using the oc logs command
OpenShift - View pod logs using the oc logs command

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

SSH onto the OpenShift jump box. Issue the oc login command. Use the oc project command to use the project that contains the pod. Use the oc get pods command with the -o wide option to determine the node that contains the pod. Let's say you want to view the logs for mypod001.

oc get pods -o wide
. . .
NAME        READY   STATUS     RESTARTS  AGE  IP              NODE                 NOMINATED MODE
mypod001    1/1     Running    0         8d   10.142.118.51   server1.example.com  <none>
mypod002    1/1     Running    0         8d   10.142.118.52   server2.example.com  <none>
mypod003    1/1     Running    0         8d   10.142.118.53   server3.example.com  <none>

 

The oc logs pod/<pod name> command can be used to view a pods log.

oc logs pod/mypod001

 

The -f or --follow option can be used to stream the log in real time.

oc logs -f pod/mypod001

 

The -p or --previous flag can be used to see previous logs.

oc logs -p pod/mypod001

 

The -s or --since option can be used to only display logs in the last x seconds, x mintues, or x days.

oc logs -p pod/mypod001 --since=24h

 

Or, you could SSH onto node server1.example.com. Switch to the root user account.

sudo -i

 

The container will contain the POD log, like this.

ll /var/lib/docker/containers/9db83c50f717fd4a42e98397aa8bc05442c6794bbe7e76337bb601f6d6197d1d


-rw-r-----. 1 root root 233245 Jul 22 15:23 9db83c50f717fd4a42e98397aa8bc05442c6794bbe7e76337bb601f6d6197d1d-json.log
drwx------. 2 root root      6 Jul 21 17:20 checkpoints
-rw-r--r--. 1 root root  12137 Jul 21 17:20 config.v2.json
-rw-r--r--. 1 root root   2668 Jul 21 17:20 hostconfig.json
drwxr-xr-x. 8 root root    220 Jul 21 17:20 secrets

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 9e166 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |