python/devel/debug_logging.md
Raj Bhargav e3b373fc1f Added proxy variable to read values from environment
What type of PR is this?
/kind bug

What this PR does / why we need it:
This PRs will read environment variables assigned for proxy and no_proxy.

Update ws_client_test.py

Update configuration.py
What type of PR is this?
/kind bug

What this PR does / why we need it:
This PRs will read environment variables assigned for proxy and no_proxy.

Update configuration.py

Add debug logging doc and example

add .readthedocs.yaml config file

Added

Added insert_proxy_config.sh to edit configuration.py in client

Revert "Added insert_proxy_config.sh to edit configuration.py in client"

This reverts commit b295c2ddcbb838196823c4d7a55a67fd1d1dc290.

To avoid condition self.no_proxy is already present
2025-06-10 16:27:05 +05:30

1.2 KiB

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:

    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)