in cdsresponder/rabbitmq/K8MessageProcessor.py [0:0]
def __init__(self, namespace:str):
try:
config.load_incluster_config()
except config.config_exception.ConfigException as e:
kube_config_file = os.getenv("KUBE_CONFIG", os.path.join(os.getenv("HOME"), ".kube", "config"))
logger.warning("Could not load in-cluster configuration: {0}. Trying external connection from {1}...".format(str(e), kube_config_file))
config.load_kube_config(kube_config_file)
self.should_keep_jobs = self.get_should_keep_jobs()
self.batch = client.BatchV1Api()
self.k8core = client.CoreV1Api()
self.namespace = k8s.k8utils.get_current_namespace()
if self.namespace is None and namespace is not None:
logger.info("Not running in cluster, falling back to configured namespace {0}", namespace)
self.namespace = namespace
elif self.namespace is None and namespace is None:
logger.error("If we are not running in a cluster you must specify a namespace within which to start jobs")
raise ValueError("No namespace configured")
logger.info("Startup - we are in namespace {0}".format(self.namespace))