Interview Prep/Python for DevOps/boto3, HTTP & API errors

`kubernetes.config.config_exception.ConfigException: Service host/port is not set.`

BeginnerTroubleshootingboto3, HTTP & API errors
Answer

Likely causes → load_incluster_config() was called outside a pod (laptop, CI), where KUBERNETES_SERVICE_HOST is not set.

Diagnose → env | grep KUBERNETES_SERVICE.

Fix → Fall back to kubeconfig:

try:
    config.load_incluster_config()
except config.ConfigException:
    config.load_kube_config()

Prevent → Use this fallback pattern in every tool that runs both in and out of cluster.

All Python for DevOps questions Roadmap: Python for automation

More on boto3, HTTP & API errors