Search code examples
kuberneteskubectl

how to take a problematic pod offline to troubleshoot


HI I know there's a way i can pull out a problematic node out of loadbalancer to troubleshoot. But how can i pull a pod out of service to troubleshoot. What tools or command can do it ?


Solution

  • As mentioned in Oreilly's "Kubernetes recipes: Maintenance and troubleshooting" page here

    Removing a Pod from a Service

    Problem

    You have a well-defined service (see not available) backed by several pods. But one of the pods is misbehaving, and you would like to take it out of the list of endpoints to examine it at a later time.

    Solution

    Relabel the pod using the --overwrite option—this will allow you to change the value of the run label on the pod. By overwriting this label, you can ensure that it will not be selected by the service selector (not available) and will be removed from the list of endpoints. At the same time, the replica set watching over your pods will see that a pod has disappeared and will start a new replica.

    To see this in action, start with a straightforward deployment generated with kubectl run (see not available):

    For commands, check the recipes page mentioned above. There is also a section talking about "Debugging Pods" which will be helpful