Search code examples
kuberneteskubernetes-helmkubectlminikube

How to get the random pod number provided by Kubernetes


I would like to get and see the random number provided by K8s.

kubectl logs abc-abc-platform-xxxxx dicom-server

Here xxxxx has to be replaced with the random generated number.

Can you let me know which command do I have to execute to find the random number?


Solution

  • If the specific pod has the my-app label, you can find that pod and save it as bash variable:

    • POD=$(kubectl get pod -l app=my-app -o jsonpath="{.items[0].metadata.name}")

    and then execute:

    • kubectl logs $POD

    PS. This will work only if you have 1 pod with that specific label.