Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Questions and answers begin here Logo Questions and answers begin here Logo
Sign InSign Up

Questions and answers begin here

Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us

Kubernetes pods stuck in terminating status.

Home/ Questions/Q 371
Next
Answered
Kubernetes pods stuck in terminating status.
ureshmalwatta
ureshmalwatta Teacher

I recently encountered a problem with my Kubernetes pods. I’ve been trying to delete them, but they seem to be stuck in a Terminating status. When I run “kubectl get pods”, I can see that they are indeed in this state for a long amount of time. I’m not sure what’s causing this issue.
Here’s a code snippet of how I’m trying to delete the pods:

$ kubectl delete pods my-pod-name

I thought perhaps there might be some dependencies that are causing the deletion to fail, so I tried to force delete the pods using the –grace-period=0 and –force flags like so:

$ kubectl delete pods my-pod-name --grace-period=0 --force

However, this still didn’t work. The pods are still in a Terminating status, and I’m not sure what else to try. Does anyone have any suggestions or ideas on how to force delete these pods? I’m really at a loss here and any help would be greatly appreciated. Thank you in advance!

debuggingkubernetespodstermination
  • 435
  • 0 Followers
  • 1
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    ajorgeferreira
    2017-02-01T05:11:21+00:00Added an answer about 6 years ago

    Greetings!
    I understand that you are facing an issue with your Kubernetes Pods being stuck in the Terminating status. This issue occurs when Kubernetes is unable to delete the Pods due to some process or activity still running within the container.
    To resolve this issue, we need to first identify the root cause. One potential reason could be that the Pod’s terminationGracePeriodSeconds that is set in the Pod’s Spec is too low. This setting defines the amount of time that Kubernetes waits for a Pod to shut down gracefully before attempting to force the Pod to stop. Inadequate time could mean that Kubernetes is unable to stop the container before it is forcefully terminated.
    Another potential reason could be the presence of finalizers. Finalizers are hooks that are added to a Kubernetes object to allow for cleanup operations before an object is deleted from the cluster. If these finalizers are not working correctly or are not present, Kubernetes may struggle to delete the Pods.
    To resolve this issue, you can try increasing the terminationGracePeriodSeconds and check if that resolves the issue. Additionally, you can also try to manually delete the Pods using the kubectl delete command with the –force flag that will forcefully delete the Pod.
    If neither solution works, you can try to identify the specific process or activity that is preventing the Pod from shutting down correctly. One way to do this is by using the kubectl describe command to get more details about the Pod, including information about the specific container running within the Pod.
    Overall, this issue can be tricky to resolve, but by following the steps above, it should give you a better idea of the root cause and help you take appropriate actions to resolve the problem.
    I hope this helps! Let me know if you have any further questions.

    • 140
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. brendancaldwell92 Begginer
    2017-02-13T15:12:00+00:00Added an answer about 6 years ago

    One reason for Pods getting stuck in a terminating status could be due to a misconfiguration in your Kubernetes cluster. Specifically, you may not have enough resources allocated for your pods to gracefully terminate.

    You can ensure that pods are able to gracefully terminate by setting an appropriate value for the `terminationGracePeriodSeconds` field in your pod specification. This value must be greater than zero and less than the `activeDeadlineSeconds` field (if set).

    Additionally, if your cluster is low on resources or you have set resource limits that are too low, pods may fail to terminate gracefully due to a lack of available resources. In such cases, you may need to adjust your resource limits or increase the resources available in your cluster.

    In my experience, I have seen this issue arise when a pod is trying to perform some cleanup tasks or finalization actions before terminating. These tasks may take longer than the default 30 seconds given to a pod for graceful termination, leading to termination getting stuck. So it’s always a good practice to check if there are any finalization tasks that your pods are performing and ensure that they complete within the specified grace period.

    Ensuring proper configuration of Kubernetes resources and allowing pods to gracefully terminate can help in avoiding scenario like Pods getting stuck in a terminating status.

    • 40
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  3. xsspc Teacher
    2017-02-05T01:29:47+00:00Added an answer about 6 years ago

    The issue with pods stuck in terminating status could be related to problems with the Kubernetes control plane. One possible solution is to check if there are any worker nodes that are no longer reachable and remove them from the cluster using kubectl command-line tools. This can be achieved by running “kubectl get nodes” and “kubectl delete node ” for any unreachable nodes that are displayed in the output.

    Another possible solution is to check if there are any orphaned resources, in which case a manual deletion using the kubectl command-line tools could be necessary. To do this, run “kubectl get pods” to see if there are any hanging pods with status “Terminating”. If there are, run “kubectl delete pod ” to remove them.

    It’s also important to check the logs of the Kubernetes API server and the controller-manager to help diagnose the problem. Reviewing the logs can provide insights into the cause of the issue and help determine the best course of action. Finally, it may be necessary to update or reinstall the Kubernetes control plane components to troubleshoot the issue further, depending on the root cause.

    • 32
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.