Troubleshooting/ Debugging: Kubernetes Pods

Troubleshooting/ Debugging: Kubernetes Pods

1) Background

1.1) Throughout we will use kubectl command-line utility to interact with K8S.

1.2) RCA (Root Cause Analysis) of failing Pods:

i) Configurational Errors. Like: deployment and services.

Affect: Containers do not start.

ii) Code Errors.

Affect: Post container start up, application code get failed.

2) Troubleshooting

Step-0: Know the debugging commands

// i) This command gives you the list of debugging commands in K8S.

$ kubectl | grep -i -A 10 debugging

Output: ....


// ii) Lists basic commands you can run on K8S resources.

$ kubectl | grep -i -A 5 Basic

Output: ....


// iii) List your operatiuing K8S resources.

$ kubectl api-resources
Output: ....


// iv) List K8S namespaces.

$ kubectl get ns

Output: ....



Step-1: Check Pods status

// Check the Pods status: Running/ Ready

$ kubectl get pods

If its shows:

a) Pending: Pending status ==> Make sure, there is no pods, with this status.

b) ImagePullBackoff: Docker image registry not accessible ==> Make sure the image name is correct, and the registry is accessible.

c) RunContainerError: ConfigMap/Secrets may missing ==> Make sure ConfigMap/Secrets is available.

d) ContainerCreating: Its taking few time to become available ==> Make sure creation process is completed, before start using it.

e) CrashLoopBackOff: Either Liveness check has failed or Image (Docker) has some issue.

May CMD (docker command): Exiting immediately => RESTARTS column has some number x.

f) Pods in running: But not working appropriately.

Step-2: Check Pods Events

// Describe command: It give more info about errors, when container failed to start.

$ kubectl describe <podName>


It may shows: Less resources allocation, like: RAM, CPU, etc. ==> Increase the corresponding resources, and redeployed it.

Step-3: Check Pods Logs

// Check if application is functioning appropriately or not by checking logs.

$ kubectl logs --tail=20 <podName>

Output: Produces logs

$ kubectl logs -f <podName>

Output: <Nothing>: May be it running the newly restarted pod.

$ kubectl logs <podName> --previous
Output: Produces logs



Step-4: Check Inside Pods by executing commands

//Get inside the pods, and Run "sh", "bash", "ash" Directly in the Pods. To get out of pod. <hit exit>.

$ kubectl exec -it <podName> /bin/sh



Step-5: Check Events at Cluster-Level

//K8S Fires EVENTS: [NORMAL, WARNING, ETC] <== whenever ==> State of Resources changes.

// Better to look into its. All events sorted by time. 

$ kubectl get events --sort-by=.metadata.creationTimestamp

// Warnings only

$ kubectl get events --field-selector type=Warning

// Events related to Nodes

$ kubectl get events --field-selector involvedObject.kind=Node



*************** The END *************************


要查看或添加评论,请登录

Arun Dhwaj的更多文章

  • Data Flow Diagram (DFD): Brief Tutorial

    Data Flow Diagram (DFD): Brief Tutorial

    1) How to create it Step1: Start with definition and purpose. Step2: Explain components with symbols.

    1 条评论
  • Translation of Work to ROI

    Translation of Work to ROI

    Why Translate Your Work to ROI ( Return On Investment) ? 1) It will make easy for you to show your stakeholders, about…

  • Sr. Architect/ Solution Architect Responsibility

    Sr. Architect/ Solution Architect Responsibility

    I) A brief dive of Responsibility 1) Understand the System’s Requirements, 2) Understand the Non-Functional…

  • 7 Tips for Optimising System Performance

    7 Tips for Optimising System Performance

    Step-1:Measure most of the things as much as you can. Step-2: Prioritise based on outcome vs intake/ Cost ( Money/…

  • Great Leader creates DNA/Culture

    Great Leader creates DNA/Culture

    They took the following steps to creates: 1) Routine The purpose of Routine is to creates The Sense of Community and…

  • Leadership: Remotely Leading the Team

    Leadership: Remotely Leading the Team

    1) Be Output Oriented Instead of inputs, be output oriented. Explain the team, they would like to see these…

  • Be on the TOP of the WORLD

    Be on the TOP of the WORLD

    1) Be a Constant Learner Make a habit of learning, learning and learning. There is no alternative to a constant…

  • React: Demystifying Component, Props, and State

    React: Demystifying Component, Props, and State

    ******************* 1.0) Part-1: Component - Start ************************* What is React Component? Background: In…

  • Best Practice: Versioning REST API

    Best Practice: Versioning REST API

    1) When we should do the Versioning of API Versioning (REST) API is often a last priority during development process…

  • Java: Stopping Serialization and Deserialization

    Java: Stopping Serialization and Deserialization

    There are scenario/ situation where we want to avoid our class to be serialized or deserialized. Like: our class is a…

社区洞察

其他会员也浏览了