Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 1.18 KB

debug_logging.md

File metadata and controls

34 lines (22 loc) · 1.18 KB

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)