File: debug_logging.md

package info (click to toggle)
python-kubernetes 35.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 47,168 kB
  • sloc: python: 145,021; sh: 763; makefile: 46
file content (34 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Enabling Debug Logging in Kubernetes Python Client

This document describes how to enable debug logging, view logged information, and provides examples for creating, patching, and deleting Kubernetes resources.

## 1. Why Enable Debug Logging?

Debug logging is useful for troubleshooting as it shows details like HTTP request and response headers and bodies. These details can help identify issues during interactions with the Kubernetes API server.

---

## 2. Enabling Debug Logging

To enable debug logging in the Kubernetes Python client, follow these steps:

1. **Modify the Configuration Object:**
   Enable debug mode by setting the `debug` attribute of the `client.Configuration` object to `True`.

2. **Example Code to Enable Debug Logging:**
   Below is an example showing how to enable debug logging:
   ```python
   from kubernetes import client, config

   # Load kube config
   config.load_kube_config()

   # Enable debug logging
   c = client.Configuration()
   c.debug = True

   # Pass the updated configuration to the API client
   api_client = client.ApiClient(configuration=c)

   # Use the API client with debug logging enabled
   apps_v1 = client.AppsV1Api(api_client=api_client)