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


Python client.V1ConfigMap方法代码示例

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


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

示例1: update_kubernetes_secret_signature

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ConfigMap [as 别名]
def update_kubernetes_secret_signature(
    kube_client: KubeClient, secret: str, service: str, secret_signature: str
) -> None:
    service = sanitise_kubernetes_name(service)
    secret = sanitise_kubernetes_name(secret)
    kube_client.core.replace_namespaced_config_map(
        name=f"paasta-secret-{service}-{secret}-signature",
        namespace="paasta",
        body=V1ConfigMap(
            metadata=V1ObjectMeta(
                name=f"paasta-secret-{service}-{secret}-signature",
                labels={
                    "yelp.com/paasta_service": service,
                    "paasta.yelp.com/service": service,
                },
            ),
            data={"signature": secret_signature},
        ),
    ) 
开发者ID:Yelp,项目名称:paasta,代码行数:21,代码来源:kubernetes_tools.py

示例2: create_kubernetes_secret_signature

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ConfigMap [as 别名]
def create_kubernetes_secret_signature(
    kube_client: KubeClient, secret: str, service: str, secret_signature: str
) -> None:
    service = sanitise_kubernetes_name(service)
    secret = sanitise_kubernetes_name(secret)
    kube_client.core.create_namespaced_config_map(
        namespace="paasta",
        body=V1ConfigMap(
            metadata=V1ObjectMeta(
                name=f"paasta-secret-{service}-{secret}-signature",
                labels={
                    "yelp.com/paasta_service": service,
                    "paasta.yelp.com/service": service,
                },
            ),
            data={"signature": secret_signature},
        ),
    ) 
开发者ID:Yelp,项目名称:paasta,代码行数:20,代码来源:kubernetes_tools.py

示例3: createConfigMap

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ConfigMap [as 别名]
def createConfigMap(parser_args,CorV1Client):
    data={}
    if parser_args.rawconfig !=None :
       keyvaluePaires=parser_args.rawconfig.split(";")
       for keyvalue in keyvaluePaires:
           _keyvalue=keyvalue.split("::")
           print(_keyvalue)
           data.update({_keyvalue[0]:_keyvalue[1]})
    else:
       configMap=readFileForConfigMap(parser_args)
       data.update(configMap)

    print("data is %s" % data)
    objectMeta=client.V1ObjectMeta(name=parser_args.tenant+parser_args.env+parser_args.envtype+"-"+parser_args.name,namespace=parser_args.namespace)
    body = client.V1ConfigMap(kind='ConfigMap',metadata=objectMeta,data=data)  # V1ConfigMap
    pretty = 'pretty_example'  # str | If 'true', then the output is pretty printed. (optional)
    try:
        api_response = CorV1Client.create_namespaced_config_map(parser_args.namespace, body, pretty=pretty)
        print(api_response)
    except ApiException as e:
        print("Exception when calling CoreV1Api->create_namespaced_config_map: %s\n" % e) 
开发者ID:IBM,项目名称:wc-devops-utilities,代码行数:23,代码来源:kube_configmap.py

示例4: patchConfigMap

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ConfigMap [as 别名]
def patchConfigMap(parser_args,CorV1Client):
    print("patch config map")
    data = {}
    if parser_args.rawconfig != None:
        keyvaluePaires = parser_args.rawconfig.split(";")
        for keyvalue in keyvaluePaires:
            print("keyvalue is %s" % keyvalue)
            _keyvalue = keyvalue.split("::")
            print(_keyvalue)
            data.update({_keyvalue[0]: _keyvalue[1]})
    else:
       configMap=readFileForConfigMap(parser_args)
       data.update(configMap)
    objectMeta = client.V1ObjectMeta(name=parser_args.tenant+parser_args.env+parser_args.envtype+"-"+parser_args.name, namespace=parser_args.namespace)
    body = client.V1ConfigMap(kind='ConfigMap', metadata=objectMeta, data=data)
    pretty = 'pretty_example'  # str | If 'true', then the output is pretty printed. (optional)

    try:
        api_response = CorV1Client.patch_namespaced_config_map(parser_args.tenant+parser_args.env+parser_args.envtype+"-"+parser_args.name, parser_args.namespace, body, pretty=pretty)
        print(api_response)
    except ApiException as e:
        print("Exception when calling CoreV1Api->patch_namespaced_config_map: %s\n" % e) 
开发者ID:IBM,项目名称:wc-devops-utilities,代码行数:24,代码来源:kube_configmap.py

示例5: _patch_or_create

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ConfigMap [as 别名]
def _patch_or_create(self, name, annotations, resource_version=None, patch=False, retry=None, ips=None):
        metadata = {'namespace': self._namespace, 'name': name, 'labels': self._labels, 'annotations': annotations}
        if patch or resource_version:
            if resource_version is not None:
                metadata['resource_version'] = resource_version
            func = functools.partial(self._api.patch_namespaced_kind, name)
        else:
            func = functools.partial(self._api.create_namespaced_kind)
            # skip annotations with null values
            metadata['annotations'] = {k: v for k, v in metadata['annotations'].items() if v is not None}

        metadata = k8s_client.V1ObjectMeta(**metadata)
        if ips is not None and self._api.use_endpoints:
            endpoints = {'metadata': metadata}
            self._map_subsets(endpoints, ips)
            body = k8s_client.V1Endpoints(**endpoints)
        else:
            body = k8s_client.V1ConfigMap(metadata=metadata)
        ret = retry(func, self._namespace, body) if retry else func(self._namespace, body)
        if ret:
            self._kinds.set(name, ret)
        return ret 
开发者ID:zalando,项目名称:patroni,代码行数:24,代码来源:kubernetes.py

示例6: cm_create

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ConfigMap [as 别名]
def cm_create(cm_data, name, namespace="default"):
    """Create a K8S ConfigMap

    Args:
        cm_data (dict): Data to store in ConfigMap as key/value hash.
        name (str): Name of ConfigMap.
        namespace (str): Name of namespace.
    """
    # TODO: We should check that CM exists before we create it
    cm = client.V1ConfigMap()
    cm.metadata = client.V1ObjectMeta(name=name)
    cm.data = cm_data
    api.create_namespaced_config_map(namespace=namespace, body=cm)
    logging.info(f"Created ConfigMap {name} in namespace {namespace}") 
开发者ID:hyperledger-labs,项目名称:nephos,代码行数:16,代码来源:k8s.py

示例7: test_delete_resource_op

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ConfigMap [as 别名]
def test_delete_resource_op(self):
      """Test a pipeline with a delete resource operation."""
      from kubernetes import client as k8s

      @dsl.pipeline()
      def some_pipeline():
        # create config map object with k6 load test script
        config_map = k8s.V1ConfigMap(
          api_version="v1",
          data={"foo": "bar"},
          kind="ConfigMap",
          metadata=k8s.V1ObjectMeta(
              name="foo-bar-cm",
              namespace="default"
          )
        )
        # delete the config map in k8s
        dsl.ResourceOp(
          name="delete-config-map",
          action="delete",
          k8s_resource=config_map
        )

      workflow_dict = kfp.compiler.Compiler()._compile(some_pipeline)
      delete_op_template = [template for template in workflow_dict['spec']['templates'] if template['name'] == 'delete-config-map'][0]

      # delete resource operation should not have success condition, failure condition or output parameters.
      # See https://github.com/argoproj/argo/blob/5331fc02e257266a4a5887dfe6277e5a0b42e7fc/cmd/argoexec/commands/resource.go#L30
      self.assertIsNone(delete_op_template.get("successCondition"))
      self.assertIsNone(delete_op_template.get("failureCondition"))
      self.assertDictEqual(delete_op_template.get("outputs", {}), {}) 
开发者ID:kubeflow,项目名称:pipelines,代码行数:33,代码来源:compiler_tests.py

示例8: init_configmap

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ConfigMap [as 别名]
def init_configmap(self, container_props, kube_obj_name):
        config_map = None
        if container_props.config:
            configmap_name = kube_obj_name
            metadata = client.V1ObjectMeta(name=configmap_name)
            config_dict = self.pre_process_config(container_props.config)
            config_map = client.V1ConfigMap(
                api_version="v1",
                kind="ConfigMap",
                data=config_dict,
                metadata=metadata)
        return config_map 
开发者ID:openstack,项目名称:tacker,代码行数:14,代码来源:translate_outputs.py


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