Skip to Content
Kubernetes即学即用(第二版)
book

Kubernetes即学即用(第二版)

by Brendan Burns, Joe Beda, Kelsey Hightower
June 2021
Intermediate to advanced
300 pages
5h 4m
Chinese
China Electric Power Press Ltd.
Content preview from Kubernetes即学即用(第二版)
196
14
14.1.3 Kubernetes
中的角色和角色绑定
Kubernetes
中,代表角色和角色绑定的资源有两种:一对仅适用于命名
空间(
Role
RoleBinding
);另一对适用于整个集群(
ClusterRole
ClusterRoleBinding
)。
下面,我们先来看一看
Role
RoleBinding
Role
资源带有命名空间,表示
这个命名空间中的能力。你不能将命名空间的角色赋予非命名空间的资源(例
如自定义资源定义
CustomResourceDefinition
等),而且将
RoleBinding
绑定
给某个角色只能提供同时包含了这个
Role
RoleDefinition
的命名空间内的
授权。
举一个具体的例子,下面是一个简单的角色,能够赋予某个身份创建和修改
Pod
以及服务的能力:
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: default
name: pod-and-services
rules:
- apiGroups: [""]
resources: ["pods", "services"]
verbs: ["create", "delete", "get", "list", "patch", "update", "watch"]
为了将这个
Role
绑定给用户
alice
,我们需要创建一个
RoleBinding
,如下所
示。这个
RoleBinding
还会将组
mydevs ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PyTorch深度学习

PyTorch深度学习

Posts & Telecom Press, Vishnu Subramanian
Python数据分析

Python数据分析

Posts & Telecom Press, Ivan Idris
Python贝叶斯分析(第2版)

Python贝叶斯分析(第2版)

Posts & Telecom Press, Osvaldo Martin
Python高级编程(第2版)

Python高级编程(第2版)

Posts & Telecom Press, Michał Jaworski, Tarek Ziadé

Publisher Resources

ISBN: 9787519856762