Ask Your Question
2

What is the process for altering the log level of a Kubernetes pod?

asked 2023-06-15 12:03:26 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2023-06-15 12:32:02 +0000

woof gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-15 12:03:26 +0000

Seen: 8 times

Last updated: Jun 15 '23