Openshift is designed to be a jungle, with self-contained projects! So for DevOps admins like us, who get knacked on the face by an error code pointing to a Docker containerID, we need to understand how the Docker environment swims inside the World of OpenShift.
LOG INTO THE NODE (NOT MASTER). What if you have a very large logfile you need to prune? Example:
/var/lib/docker/containers/7d530b9a01c8603b8f565b1b4a8425321f0f386884387b086a9b4f74f0747a45/config.v2.json
But before you prune it, you need to know what POD uses this log file in question. So the logic used for searching your pod is:
Logfile uses ---> ContainerID ---> Docker Containers seen via 'docker ps -a' command ---> Container Name contains the POD name also.
So in the above logicFlow, you will be guided how to search for the POD in an OpenShift Project. NOw let us walk the talk. In abovementioned sample logfile, use the log filename as the container ID.
Use only the FIRST SIX CHARS of the filename in a GREP statement shown below:
[root@ip-10-10-0-149 containers]# docker ps -a | grep -i 7d530b
7d530b9a01c8 docker-registry.default.svc:5000/mongopop1/mongodb-mongopop@sha256:263cd8cc3d05eab05bc5b48ea0173c05a942520d20081b1d56620f749d59cabd "container-entrypoint" 2 days ago Up 2 days k8s_mongodb-mongopop_mongodb-mongopop-2-ql797_mongopop1_98b8a6aa-b247-11e7-84fb-1205237d47c8_0
[root@ip-10-10-0-149 containers]#
Now focus on the output of the LAST column, and I know it is confusing but keep treading! The LAST column contains a 'k8s' character, and the POD name is the one with DASHES / HYPHENS. So parsing it from the example, the POD name is: mongodb-mongopop-2-ql797.
So your newfound POD name is ---> mongodb-mongopop-2-ql797.
GO INTO THE MASTER, then check to confirm the Project name where it belongs:
[root@ip-10-10-0-60 ~]# oc get pod --all-namespaces -o wide | grep -i mongopop-2-ql797
mongopop1 mongodb-mongopop-2-ql797 1/1 Running 0 2d 10.129.0.55 ip-10-10-0-149.ec2.internal
[root@ip-10-10-0-60 ~]#
First column is the PROJECT NAME.
Second column is the POD NAME.
~