當前位置: 首頁>>代碼示例>>Python>>正文


Python client.BatchV1beta1Api方法代碼示例

本文整理匯總了Python中kubernetes.client.BatchV1beta1Api方法的典型用法代碼示例。如果您正苦於以下問題:Python client.BatchV1beta1Api方法的具體用法?Python client.BatchV1beta1Api怎麽用?Python client.BatchV1beta1Api使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kubernetes.client的用法示例。


在下文中一共展示了client.BatchV1beta1Api方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import BatchV1beta1Api [as 別名]
def __init__(self, bearer_token=None):
        '''
        Initialize connection to Kubernetes
        '''
        self.bearer_token = bearer_token
        api_client = None

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

        if self.bearer_token:
            # Configure API key authorization: Bearer Token
            configuration = client.Configuration()
            configuration.api_key_prefix['authorization'] = 'Bearer'
            configuration.api_key['authorization'] = self.bearer_token
            api_client = client.ApiClient(configuration)

        self.client = client.CoreV1Api(api_client)
        self.batch_api = client.BatchV1Api(api_client)
        self.batch_v1beta1_api = client.BatchV1beta1Api(api_client)
        self.custom_objects = client.CustomObjectsApi(api_client)
        self.api_extensions = client.ApiextensionsV1beta1Api(api_client)
        self.extension_api = client.ExtensionsV1beta1Api(api_client)
        self.apps_v1_api = client.AppsV1Api(api_client) 
開發者ID:airshipit,項目名稱:armada,代碼行數:28,代碼來源:k8s.py

示例2: __init__

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import BatchV1beta1Api [as 別名]
def __init__(self):
        '''
        Initialize connection to Kubernetes
        '''
        try:
            config.load_incluster_config()
        except config.config_exception.ConfigException:
            config.load_kube_config()

        self.client = client.CoreV1Api()
        self.batch_api = client.BatchV1Api()
        self.batch_v1beta1_api = client.BatchV1beta1Api()
        self.extension_api = client.ExtensionsV1beta1Api() 
開發者ID:att-comdev,項目名稱:armada,代碼行數:15,代碼來源:k8s.py

示例3: run_step_cronjob

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import BatchV1beta1Api [as 別名]
def run_step_cronjob(
    step: Dict[str, Any], context: PipelineContext
) -> List[Tuple[Callable, Dict[str, str]]]:
    # Update a Kubernetes CronJob
    context.workspace.log.info(f"Updating CronJob: {repr(step)}")

    api = client.BatchV1beta1Api(context.kube.client)

    selector = format_task(step["selector"], context.task)
    selector.setdefault("namespace", "default")
    containers = format_task(step["containers"], context.task)

    watchers: List[Tuple[Callable, Dict[str, str]]] = []

    # See comments about Deployments, it's almost identical, with the key
    # difference being we don't need to need to wait for any rollout, since
    # this just gets applied immediately to the spec.
    for cronjob in api.list_namespaced_cron_job(**selector).items:
        namespace = cronjob.metadata.name
        name = cronjob.metadata.name
        changes = False
        for container in cronjob.spec.job_template.spec.template.spec.containers:
            for c in containers:
                if container.name == c["name"]:
                    container.image = c["image"]
                    changes = True

        if changes:
            if cronjob.metadata.annotations is None:
                cronjob.metadata.annotations = {}
            for k, v in asdict(context.task).items():
                if k == "ssh_key":
                    continue
                k = f"freight.sentry.io/{k}"
                cronjob.metadata.annotations[k] = v

            resp = api.patch_namespaced_cron_job(
                name=cronjob.metadata.name,
                namespace=cronjob.metadata.namespace,
                body=cronjob,
            ) 
開發者ID:getsentry,項目名稱:freight,代碼行數:43,代碼來源:pipeline.py


注:本文中的kubernetes.client.BatchV1beta1Api方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。