当前位置: 首页>>代码示例>>Python>>正文


Python client.CustomObjectsApi方法代码示例

本文整理汇总了Python中kubernetes.client.CustomObjectsApi方法的典型用法代码示例。如果您正苦于以下问题:Python client.CustomObjectsApi方法的具体用法?Python client.CustomObjectsApi怎么用?Python client.CustomObjectsApi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kubernetes.client的用法示例。


在下文中一共展示了client.CustomObjectsApi方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_instance

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def get_instance(spec, api_custom_objects=None, api_resources=None):
        # due to https://github.com/kubernetes-client/python/issues/387
        if spec.get('kind') in Adapter.kinds_builtin:
            if spec.get('apiVersion') == 'test/test':
                return AdapterBuiltinKind(spec, K8sClientMock(spec.get('metadata', {}).get('name')))

            api = Adapter.api_versions.get(spec.get('apiVersion'))

            if not api:
                return None

            return AdapterBuiltinKind(spec, api())

        api_custom_objects = api_custom_objects or client.CustomObjectsApi()
        api_resources = api_resources or ResourcesAPI()
        return AdapterCustomKind(spec, api_custom_objects, api_resources) 
开发者ID:2gis,项目名称:k8s-handle,代码行数:18,代码来源:adapters.py

示例2: __init__

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def __init__(self) -> None:
        kube_config.load_kube_config(
            config_file=os.environ.get("KUBECONFIG", KUBE_CONFIG_PATH),
            context=os.environ.get("KUBECONTEXT"),
        )
        models.V1beta1PodDisruptionBudgetStatus.disrupted_pods = property(
            fget=lambda *args, **kwargs: models.V1beta1PodDisruptionBudgetStatus.disrupted_pods(
                *args, **kwargs
            ),
            fset=_set_disrupted_pods,
        )
        self.deployments = kube_client.AppsV1Api()
        self.core = kube_client.CoreV1Api()
        self.policy = kube_client.PolicyV1beta1Api()
        self.apiextensions = kube_client.ApiextensionsV1beta1Api()
        self.custom = kube_client.CustomObjectsApi()
        self.autoscaling = kube_client.AutoscalingV2beta1Api()
        self.request = kube_client.ApiClient().request 
开发者ID:Yelp,项目名称:paasta,代码行数:20,代码来源:kubernetes_tools.py

示例3: create_custom_resource_definition

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def create_custom_resource_definition(self,
                                          group: str,
                                          version: str,
                                          plural: str,
                                          body: Union[str, dict],
                                          namespace: Optional[str] = None
                                          ):
        """
        Creates custom resource definition object in Kubernetes

        :param group: api group
        :type group: str
        :param version: api version
        :type version: str
        :param plural: api plural
        :type plural: str
        :param body: crd object definition
        :type body: Union[str, dict]
        :param namespace: kubernetes namespace
        :type namespace: str
        """
        api = client.CustomObjectsApi(self.get_conn())
        if namespace is None:
            namespace = self.get_namespace()
        if isinstance(body, str):
            body = _load_body_to_dict(body)
        try:
            response = api.create_namespaced_custom_object(
                group=group,
                version=version,
                namespace=namespace,
                plural=plural,
                body=body
            )
            self.log.debug("Response: %s", response)
            return response
        except client.rest.ApiException as e:
            raise AirflowException("Exception when calling -> create_custom_resource_definition: %s\n" % e) 
开发者ID:apache,项目名称:airflow,代码行数:40,代码来源:kubernetes.py

示例4: get_custom_resource_definition

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def get_custom_resource_definition(self,
                                       group: str,
                                       version: str,
                                       plural: str,
                                       name: str,
                                       namespace: Optional[str] = None):
        """
        Get custom resource definition object from Kubernetes

        :param group: api group
        :type group: str
        :param version: api version
        :type version: str
        :param plural: api plural
        :type plural: str
        :param name: crd object name
        :type name: str
        :param namespace: kubernetes namespace
        :type namespace: str
        """
        custom_resource_definition_api = client.CustomObjectsApi(self.get_conn())
        if namespace is None:
            namespace = self.get_namespace()
        try:
            response = custom_resource_definition_api.get_namespaced_custom_object(
                group=group,
                version=version,
                namespace=namespace,
                plural=plural,
                name=name
            )
            return response
        except client.rest.ApiException as e:
            raise AirflowException("Exception when calling -> get_custom_resource_definition: %s\n" % e) 
开发者ID:apache,项目名称:airflow,代码行数:36,代码来源:kubernetes.py

示例5: __init__

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [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

示例6: _get_k8s_custom_objects_client

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def _get_k8s_custom_objects_client():
    k8s_config.load_incluster_config()
    return k8s.CustomObjectsApi() 
开发者ID:kubeflow-kale,项目名称:kale,代码行数:5,代码来源:pod_utils.py

示例7: get_k8s_api_custom_client

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def get_k8s_api_custom_client(id_token):
    custom_obj_api_instance = client.CustomObjectsApi(get_simple_client(id_token))
    return custom_obj_api_instance 
开发者ID:IntelAI,项目名称:inference-model-manager,代码行数:5,代码来源:kubernetes_resources.py

示例8: get_k8s_custom_obj_client

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def get_k8s_custom_obj_client(configuration):
    return client.CustomObjectsApi(K8sApiClient(configuration)) 
开发者ID:IntelAI,项目名称:inference-model-manager,代码行数:4,代码来源:conftest.py

示例9: wait_for_benchmark_job

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def wait_for_benchmark_job(job_name, namespace, timeout_minutes=20, replicas=1):
  """Wait for benchmark to be complete.
  Args:
    namespace: The name space for the deployment.
    job_name: The name of the benchmark workflow.
    timeout_minutes: Timeout interval in minutes.
    replicas: Number of replicas that must be running.
  Returns:
    deploy: The deploy object describing the deployment.
  Raises:
    TimeoutError: If timeout waiting for deployment to be ready.
  """
  end_time = datetime.datetime.now() + datetime.timedelta(minutes=timeout_minutes)
  config.load_kube_config()

  crd_api = k8s_client.CustomObjectsApi()
  GROUP = "argoproj.io"
  VERSION = "v1alpha1"
  PLURAL = "workflows"

  while datetime.datetime.now() < end_time:
    workflow = crd_api.get_namespaced_custom_object(GROUP, VERSION, namespace, PLURAL, job_name)
    if workflow and workflow['status'] and workflow['status']['phase'] and workflow['status']['phase'] == "Succeeded":
      logging.info("Job Completed")
      return workflow
    logging.info("Waiting for job %s:%s", namespace, job_name)
    time.sleep(10)
  logging.error("Timeout waiting for workflow %s in namespace %s to be "
                "complete", job_name, namespace)
  raise TimeoutError(
    "Timeout waiting for deployment {0} in namespace {1}".format(
      job_name, namespace)) 
开发者ID:aws-samples,项目名称:aws-eks-deep-learning-benchmark,代码行数:34,代码来源:deploy_utils.py

示例10: __init__

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def __init__(self, token=None, ca_file=None, context=None, multus=True, host='127.0.0.1', port=443,
                 user='root', debug=False, tags=None, namespace=None, cdi=False, datavolumes=True, readwritemany=False):
        Kubecommon.__init__(self, token=token, ca_file=ca_file, context=context, host=host, port=port,
                            namespace=namespace, readwritemany=readwritemany)
        self.crds = client.CustomObjectsApi(api_client=self.api_client)
        self.debug = debug
        self.multus = multus
        self.tags = tags
        self.cdi = False
        self.datavolumes = False
        if cdi:
            try:
                cdipods = self.core.list_pod_for_all_namespaces(label_selector='app=containerized-data-importer').items
                if cdipods:
                    for pod in cdipods:
                        if pod.metadata.name.startswith('cdi-deployment'):
                            self.cdinamespace = pod.metadata.namespace
                            self.cdi = True
                if self.cdi and datavolumes:
                    try:
                        cm = self.core.read_namespaced_config_map('kubevirt-config', KUBEVIRTNAMESPACE)
                        if 'feature-gates' in cm.data and 'DataVolumes' in cm.data['feature-gates']:
                            self.datavolumes = True
                    except:
                        pass
            except:
                pass
        return 
开发者ID:karmab,项目名称:kcli,代码行数:30,代码来源:__init__.py

示例11: __init__

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def __init__(self):
        # Create Kubernetes config.
        load_incluster_config()
        config = Configuration()
        config.debug = Settings.KUBERNETES_SERVICE_DEBUG
        self.api_client = client.ApiClient(config)

        # Re-usable API client instances.
        self.core_api = client.CoreV1Api(self.api_client)
        self.custom_objects_api = client.CustomObjectsApi(self.api_client)
        self.extensions_api = client.ApiextensionsV1beta1Api(self.api_client)
        self.apps_api = client.AppsV1beta1Api(self.api_client) 
开发者ID:Ultimaker,项目名称:k8s-mongo-operator,代码行数:14,代码来源:KubernetesService.py

示例12: __init__

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def __init__(self, group, plural, version, client):
    self.group = group
    self.plural = plural
    self.version = version
    self.client = k8s_client.CustomObjectsApi(client) 
开发者ID:kubeflow,项目名称:pipelines,代码行数:7,代码来源:launch_crd.py

示例13: k8s_custom_object_api

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def k8s_custom_object_api(self):
        if not self._k8s_custom_object_api:
            self._k8s_custom_object_api = client.CustomObjectsApi(self.api_client)
        return self._k8s_custom_object_api 
开发者ID:polyaxon,项目名称:polyaxon,代码行数:6,代码来源:manager.py

示例14: create_custom_api

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def create_custom_api(self):
        cfg = self.get_kubecfg()
        return client.CustomObjectsApi(cfg) 
开发者ID:gardener,项目名称:cc-utils,代码行数:5,代码来源:ctx.py

示例15: __init__

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import CustomObjectsApi [as 别名]
def __init__(self):
        config.load_kube_config()

        # Make v1 and cv1 as global pointer that can be called from anywhere when this class instantiated.
        global v1
        global cv1
        v1 = client.CoreV1Api()
        cv1 = client.CustomObjectsApi() 
开发者ID:redhat-cop,项目名称:openshift-toolkit,代码行数:10,代码来源:k8sHelper.py


注:本文中的kubernetes.client.CustomObjectsApi方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。