Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To alter the log level of a Kubernetes pod, follow these steps:

  1. Open your terminal and connect to your Kubernetes cluster using kubectl.

  2. Run the command kubectl get pods to list all the running pods in the cluster.

  3. Choose the pod for which you want to alter the log level.

  4. Issue the command kubectl logs <pod-name> to check the level of logs for the pod.

  5. To change the log level, edit the pod’s YAML file with the following changes:

    • Add the following lines under the spec: section of the YAML file:
    containers:
    - name: <container-name>
    env:
    - name: LOG_LEVEL
      value: <desired-log-level>
    
  6. Replace <container-name> with the name of the container in the pod.

  7. Replace <desired-log-level> with the desired log level (e.g. DEBUG, INFO, WARNING, ERROR etc.).

  8. Save the edited YAML file.

  9. Issue the command kubectl apply -f <edited-YAML-file> to apply the changes to the pod.

  10. Verify the changes by issuing the command kubectl logs <pod-name> again.