1. Knowledge Base
  2. Enterprise self-hosting

Troubleshooting Kubernetes

Sometimes you may need to troubleshoot your Kubernetes cluster.

Checking the status of pods

To check the status of pods in your Kubernetes cluster, follow these steps:

  1. Open a terminal.

  2. Run the following command to list all the pods in the default namespace:

    kubectl get pods

    This command will display a table containing the pod names, their current status, and other relevant information.

  3. Check the status column to identify any pods that are in a state other than "Running." Common pod states include "Pending," "ContainerCreating," "CrashLoopBackOff," or "Error." Note down the names of the pods that are not running as expected.

  4. To get more detailed information about a specific pod, use the following command, replacing <pod-name> with the actual name of the pod:

    kubectl describe pod <pod-name>

    The command will display detailed information about the pod, including events, conditions, and any error messages that may help identify the problem.

Inspecting pod logs

Once you have identified pods that are not running as expected, inspecting their logs can provide valuable insights into the issues. Follow these steps:

  1. Determine the name of the pod for which you want to inspect the logs.

  2. Run the following command to view the logs of a specific pod, replacing <pod-name> with the actual name of the pod:

    kubectl logs <pod-name>

    By default, this command will show the logs from the main container within the pod.

  3. If you want to stream the logs in real-time, allowing you to see new log entries as they occur, use the following command:

    kubectl logs -f <pod-name>

    Press Ctrl + C to stop streaming the logs.

  4. To view logs from the past 10 minutes, you can specify the time range using the --since flag. Run the following command, replacing <pod-name> with the actual name of the pod:

    kubectl logs --since=10m <pod-name>

    This command will display the logs from the past 10 minutes for the specified pod.