def __init__( self, namespace: str = None, name: str = None, labels: Iterable[str] = None, env_vars: dict = None, max_polls: int = None, agent_address: str = None, no_cloud_logs: bool = False, ) -> None: super().__init__( name=name, labels=labels, env_vars=env_vars, max_polls=max_polls, agent_address=agent_address, no_cloud_logs=no_cloud_logs, ) self.namespace = namespace from kubernetes import client, config try: self.logger.debug("Loading incluster configuration") config.load_incluster_config() except config.config_exception.ConfigException as exc: self.logger.warning( "{} Using out of cluster configuration option.".format(exc)) self.logger.debug("Loading out of cluster configuration") config.load_kube_config() self.batch_client = client.BatchV1Api() self.logger.debug(f"Namespace: {self.namespace}")
def __init__( self, agent_config_id: str = None, namespace: str = None, service_account_name: str = None, image_pull_secrets: Iterable[str] = None, job_template_path: str = None, name: str = None, labels: Iterable[str] = None, env_vars: dict = None, max_polls: int = None, agent_address: str = None, no_cloud_logs: bool = False, volume_mounts: List[dict] = None, volumes: List[dict] = None, ) -> None: super().__init__( agent_config_id=agent_config_id, name=name, labels=labels, env_vars=env_vars, max_polls=max_polls, agent_address=agent_address, no_cloud_logs=no_cloud_logs, ) self.namespace = namespace or os.getenv("NAMESPACE", "default") self.service_account_name = service_account_name or os.getenv( "SERVICE_ACCOUNT_NAME") if image_pull_secrets is None: image_pull_secrets_env = os.getenv("IMAGE_PULL_SECRETS") image_pull_secrets = ([ s.strip() for s in image_pull_secrets_env.split(",") ] if image_pull_secrets_env is not None else None) self.image_pull_secrets = image_pull_secrets self.job_template_path = job_template_path or DEFAULT_JOB_TEMPLATE_PATH self.volume_mounts = volume_mounts self.volumes = volumes from kubernetes import client, config try: self.logger.debug("Loading incluster configuration") config.load_incluster_config() except config.config_exception.ConfigException as exc: self.logger.warning( "{} Using out of cluster configuration option.".format(exc)) self.logger.debug("Loading out of cluster configuration") config.load_kube_config() self.batch_client = client.BatchV1Api() self.core_client = client.CoreV1Api() self.k8s_client = client min_datetime = datetime.min.replace(tzinfo=pytz.UTC) self.job_pod_event_timestamps = defaultdict( # type: ignore lambda: defaultdict(lambda: min_datetime)) self.logger.debug(f"Namespace: {self.namespace}")
def __init__(self) -> None: super().__init__() from kubernetes import client, config try: config.load_incluster_config() except config.config_exception.ConfigException as exc: self.logger.warning( "{} Using out of cluster configuration option.".format(exc)) config.load_kube_config() self.batch_client = client.BatchV1Api()
def __init__(self, name: str = None, labels: Iterable[str] = None) -> None: super().__init__(name=name, labels=labels) from kubernetes import client, config try: self.logger.debug("Loading incluster configuration") config.load_incluster_config() except config.config_exception.ConfigException as exc: self.logger.warning( "{} Using out of cluster configuration option.".format(exc)) self.logger.debug("Loading out of cluster configuration") config.load_kube_config() self.batch_client = client.BatchV1Api()
def __init__( self, agent_config_id: str = None, namespace: str = None, job_template_path: str = None, name: str = None, labels: Iterable[str] = None, env_vars: dict = None, max_polls: int = None, agent_address: str = None, no_cloud_logs: bool = False, volume_mounts: List[dict] = None, volumes: List[dict] = None, ) -> None: super().__init__( agent_config_id=agent_config_id, name=name, labels=labels, env_vars=env_vars, max_polls=max_polls, agent_address=agent_address, no_cloud_logs=no_cloud_logs, ) self.namespace = namespace or os.getenv("NAMESPACE", "default") self.job_template_path = job_template_path or DEFAULT_JOB_TEMPLATE_PATH self.volume_mounts = volume_mounts self.volumes = volumes from kubernetes import client, config try: self.logger.debug("Loading incluster configuration") config.load_incluster_config() except config.config_exception.ConfigException as exc: self.logger.warning( "{} Using out of cluster configuration option.".format(exc) ) self.logger.debug("Loading out of cluster configuration") config.load_kube_config() self.batch_client = client.BatchV1Api() self.core_client = client.CoreV1Api() self.k8s_client = client self.logger.debug(f"Namespace: {self.namespace}")