클러스터롤
Role and ClusterRole
롤, 클러스터롤
An RBAC Role or ClusterRole contains rules that represent a set of permissions. Permissions are purely additive (there are no “deny” rules).
알백 롤 또는 클러스터 롤은 권한을 나타내는 규칙을 포함합니다. 권한들은 순수하게 추가적입니다 (거절 규칙은 없습니다).
A Role always sets permissions within a particular namespace; when you create a Role, you have to specify the namespace it belongs in.
Role은 항상 특정 네임스페이스 내에서 권한을 설정합니다. Role을 만들 때, 속한 네임스페이스를 명시해야 합니다.
ClusterRole, by contrast, is a non-namespaced resource. The resources have different names (Role and ClusterRole) because a Kubernetes object always has to be either namespaced or not namespaced; it can’t be both.
클러스터 롤은 대조적으로 네임스페이스가 없는 리소스입니다. 리소스들은 다른 이름들(Role, ClusterRole)을 가집니다. 이는 쿠버네티스 객체가 항상 네임스페이스가 있거나 네임스페이스가 없어야 하기 때문입니다. 둘 다일 수는 없습니다.
ClusterRoles have several uses. You can use a ClusterRole to:
클러스터 롤은 여러 가지 용도로 사용됩니다. ClusterRole을 다음과 같이 사용할 수 있습니다:
- Define permissions on namespaced resources and be granted access within individual namespace(s)
- Define permissions on namespaced resources and be granted access across all namespaces
- Define permissions on cluster-scoped resources
If you want to define a role within a namespace, use a Role; if you want to define a role cluster-wide, use a ClusterRole.
네임스페이스 내에서 역할을 정의하려면 Role을 사용하고, 클러스터 전체에 대한 역할을 정의하려면 ClusterRole을 사용하십시오.
RBAC Info
Let’s talk a little about RBAC resources:
RBAC 리소스에 대해 조금 이야기해 봅시다:
-
A ClusterRole Role defines a set of permissions and where it is available, in the whole cluster or just a single Namespace. -
ClusterRole Role은 권한의 집합과 그것이 사용 가능한 위치(전체 클러스터 또는 단일 네임스페이스)를 정의합니다. -
A ClusterRoleBinding RoleBinding connects a set of permissions with an account and defines where it is applied, in the whole cluster or just a single Namespace. -
ClusterRoleBinding RoleBinding은 권한의 집합을 계정과 연결하고 그것이 적용되는 위치(전체 클러스터 또는 단일 네임스페이스)를 정의합니다.
Because of this, there are 4 different RBAC combinations and 3 valid ones:
이로 인해 4가지 다른 RBAC 조합과 3가지 유효한 조합이 있습니다:
- Role + RoleBinding (available in single Namespace, applied in single Namespace)
- ClusterRole + ClusterRoleBinding (available cluster-wide, applied cluster-wide)
- ClusterRole + RoleBinding (available cluster-wide, applied in single Namespace)
- Role + ClusterRoleBinding (NOT POSSIBLE: available in single Namespace, applied cluster-wide)
Example
# Create SAs
k -n ns1 create sa pipeline
k -n ns2 create sa pipeline
# Use ClusterRole view
k get clusterrole view
k create clusterrolebinding pipeline-view --clusterrole view --serviceaccount ns1:pipeline --serviceaccount ns2:pipeline
# Manage Deployments in both Namespaces
k create clusterrole pipeline-deployment-manager --verb create,delete --resource deployments
# Instead of one ClusterRole we could also create the same Role in both Namespaces
k -n ns1 create rolebinding pipeline-deployment-manager --clusterrole pipeline-deployment-manager --serviceaccount ns1:pipeline
k -n ns2 create rolebinding pipeline-deployment-manager --clusterrole pipeline-deployment-manager --serviceaccount ns2:pipeline