import os import kubernetes import client, config def get_core_client() -> client.CoreV1Api: if os.getenv("IN_CLUSTER"): config.load_incluster_config() else: config.load_kube_config( # runs locally config_file=os.getenv("KUBECONFIG", "~/.kube/config") ) return client.CoreV1Api() def get_custom_client() -> client.CustomObjectsApi: return client.CustomObjectsApi()