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


Python client.RbacAuthorizationV1Api方法代码示例

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


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

示例1: test_create_rbac_role_from_yaml

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import RbacAuthorizationV1Api [as 别名]
def test_create_rbac_role_from_yaml(self):
        """
        Should be able to create an rbac role.
        """
        k8s_client = client.api_client.ApiClient(configuration=self.config)
        utils.create_from_yaml(
            k8s_client, self.path_prefix + "rbac-role.yaml")
        rbac_api = client.RbacAuthorizationV1Api(k8s_client)
        rbac_role = rbac_api.read_namespaced_role(
            name="pod-reader", namespace="default")
        self.assertIsNotNone(rbac_role)
        rbac_api.delete_namespaced_role(
            name="pod-reader", namespace="default", body={}) 
开发者ID:kubernetes-client,项目名称:python,代码行数:15,代码来源:test_utils.py

示例2: test_create_rbac_role_from_yaml_with_verbose_enabled

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import RbacAuthorizationV1Api [as 别名]
def test_create_rbac_role_from_yaml_with_verbose_enabled(self):
        """
        Should be able to create an rbac role with verbose enabled.
        """
        k8s_client = client.api_client.ApiClient(configuration=self.config)
        utils.create_from_yaml(
            k8s_client, self.path_prefix + "rbac-role.yaml", verbose=True)
        rbac_api = client.RbacAuthorizationV1Api(k8s_client)
        rbac_role = rbac_api.read_namespaced_role(
            name="pod-reader", namespace="default")
        self.assertIsNotNone(rbac_role)
        rbac_api.delete_namespaced_role(
            name="pod-reader", namespace="default", body={}) 
开发者ID:kubernetes-client,项目名称:python,代码行数:15,代码来源:test_utils.py

示例3: get_k8s_rbac_api_client

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

示例4: rbac_api_instance

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

示例5: api_init

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import RbacAuthorizationV1Api [as 别名]
def api_init(host=None, token_filename=None, cert_filename=None, context=None):
    global CoreV1Api
    global RbacAuthorizationV1Api
    global api_temp

    if host and token_filename:
        # remotely
        token_filename = os.path.abspath(token_filename)
        if cert_filename:
            cert_filename = os.path.abspath(cert_filename)
        BearerTokenLoader(host=host, token_filename=token_filename, cert_filename=cert_filename).load_and_set()

    else:
        if running_in_docker_container():
            # TODO: Consider using config.load_incluster_config() from container created by Kubernetes. Required service account with privileged permissions.
            # Must have mounted volume
            container_volume_prefix = '/tmp'
            kube_config_bak_path = '/KubiScan/config_bak'
            if not os.path.isfile(kube_config_bak_path):
                copyfile(container_volume_prefix + os.path.expandvars('$CONF_PATH'), kube_config_bak_path)
                replace(kube_config_bak_path, ': /', ': /tmp/')

            config.load_kube_config(kube_config_bak_path, context=context)
        else:
            config.load_kube_config(context=context)

    CoreV1Api = client.CoreV1Api()
    RbacAuthorizationV1Api = client.RbacAuthorizationV1Api()
    api_temp = ApiClientTemp() 
开发者ID:cyberark,项目名称:KubiScan,代码行数:31,代码来源:api_client.py

示例6: get_rules

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import RbacAuthorizationV1Api [as 别名]
def get_rules(self):
        config.load_kube_config()
        v1 = client.RbacAuthorizationV1Api()
        if self.kind.lower() == "role":
            return (v1.read_namespaced_role(self.name, self.namespace)).rules
        else: # "clusterrole"
            return (v1.read_cluster_role(self.name)).rules 
开发者ID:cyberark,项目名称:KubiScan,代码行数:9,代码来源:role.py

示例7: __init__

# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import RbacAuthorizationV1Api [as 别名]
def __init__(self, kube_api_client=None, image=None, namespace=None,
                 scheduler_num=1, scheduler_cpu=None, scheduler_mem=None,
                 worker_num=1, worker_cpu=None, worker_mem=None,
                 worker_spill_paths=None, worker_cache_mem=None, min_worker_num=None,
                 web_num=1, web_cpu=None, web_mem=None, service_type=None,
                 timeout=None, **kwargs):
        from kubernetes import client as kube_client

        self._api_client = kube_api_client
        self._core_api = kube_client.CoreV1Api(kube_api_client)
        self._rbac_api = kube_client.RbacAuthorizationV1Api(kube_api_client)

        self._namespace = namespace
        self._image = image
        self._timeout = timeout
        self._service_type = service_type or 'NodePort'
        self._extra_volumes = kwargs.pop('extra_volumes', ())
        self._pre_stop_command = kwargs.pop('pre_stop_command', None)
        self._log_when_fail = kwargs.pop('log_when_fail', False)

        extra_modules = kwargs.pop('extra_modules', None) or []
        extra_modules = extra_modules.split(',') if isinstance(extra_modules, str) \
            else extra_modules
        extra_envs = kwargs.pop('extra_env', None) or dict()
        service_port = kwargs.pop('service_port', None) or self._default_service_port

        def _override_modules(updates):
            modules = set(extra_modules)
            updates = updates.split(',') if isinstance(updates, str) \
                else updates
            modules.update(updates)
            return sorted(modules)

        def _override_envs(updates):
            ret = extra_envs.copy()
            ret.update(updates)
            return ret

        self._scheduler_num = scheduler_num
        self._scheduler_cpu = scheduler_cpu
        self._scheduler_mem = scheduler_mem
        self._scheduler_extra_modules = _override_modules(kwargs.pop('scheduler_extra_modules', []))
        self._scheduler_extra_env = _override_envs(kwargs.pop('scheduler_extra_env', None) or dict())
        self._scheduler_service_port = kwargs.pop('scheduler_service_port', None) or service_port

        self._worker_num = worker_num
        self._worker_cpu = worker_cpu
        self._worker_mem = worker_mem
        self._worker_spill_paths = worker_spill_paths
        self._worker_cache_mem = worker_cache_mem
        self._min_worker_num = min_worker_num
        self._worker_extra_modules = _override_modules(kwargs.pop('worker_extra_modules', []))
        self._worker_extra_env = _override_envs(kwargs.pop('worker_extra_env', None) or dict())
        self._worker_service_port = kwargs.pop('worker_service_port', None) or service_port

        self._web_num = web_num
        self._web_cpu = web_cpu
        self._web_mem = web_mem
        self._web_extra_modules = _override_modules(kwargs.pop('web_extra_modules', []))
        self._web_extra_env = _override_envs(kwargs.pop('web_extra_env', None) or dict())
        self._web_service_port = kwargs.pop('web_service_port', None) or service_port 
开发者ID:mars-project,项目名称:mars,代码行数:63,代码来源:client.py


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