> For the complete documentation index, see [llms.txt](https://platform9.com/kb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform9.com/kb/pmk/how-to/how-to-enable-debug-log-for-kube-apiserver-on-an-existing-cluste.md).

# How To Enable Debug Log for Kube-APIserver on an Existing Cluster

## Problem

How to enable debug logs on an existing Cluster.

## Environment

* Platform9 Managed Kubernetes (PMK) - All Versions

## Procedure

The default Kube-APIserver container debug value is 2. This can be modified using the steps outlined on the master node part of the cluster.

{% hint style="warning" %}
**Warning**

The steps highlighted below are to be done directly on the master nodes that are part of the cluster and thus *post cluster upgrade they will be wiped out*.

If there is a need to persist the flag values post-cluster upgrade on existing clusters, please contact [Platform9 Support](https://support.platform9.com/hc/en-us).
{% endhint %}

1. Backup the original *master.yaml* file (PMK's default configuration file retrieved from the default template "`/opt/pf9/pf9-kube/conf/masterconfig/base/centos/master.yaml`") to some other location on the node.

```javascript
# cp /etc/pf9/kube.d/pod-manifests/master.yaml /root/
```

2. Check default value for the Kube-APIserver container on k8s-master- pod. Using "`kubectl describe pod k8s-master-<Matser-IP>`" command. Here, by default the value is 2

{% tabs %}
{% tab title="Describe output for k8s-master-<master-ip>" %}

```javascript
# kubectl describe po k8s-master-<master-IP> -n kube-system
Name:                 k8s-master-<master-IP>
Namespace:            kube-system
Node:                 <Node-IP>
..
Containers:
  kube-apiserver:
     Command:
       --v=2
```

{% endtab %}
{% endtabs %}

```
3. Now edit debug level for Kube-APIserver container in "`/etc/pf9/kube.d/pod-            manifests/master.yaml`" file. Pod will get recreated as soon as you save the edited file.
```

{% tabs %}
{% tab title="Master.yaml" %}

```javascript
apiVersion: v1
kind: Pod
metadata:
  name: k8s-master
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-apiserver
    - --v=8                       <----- Edit Debug level value e.g here we changed it from 2 to 8
```

{% endtab %}
{% endtabs %}

4. Now, verify the change on Kube-API server container on k8s-master- pod using Kubectl describe command.

{% tabs %}
{% tab title="Describe command" %}

```javascript
# kubectl describe po k8s-master-<master-IP> -n kube-system
Name:                 k8s-master-<master-IP>
Namespace:            kube-system
Node:                 <Node-IP>
..
Containers:
  kube-apiserver:
     Command:
       --v=8                  <--------------New debug level should start reflecting
```

{% endtab %}
{% endtabs %}

5. Once you are done with the troubleshooting, please revert the debug level to 2 as higher debug level will capture many logs and utilise the pod resources.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://platform9.com/kb/pmk/how-to/how-to-enable-debug-log-for-kube-apiserver-on-an-existing-cluste.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
