當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。