Junior — Middle
What methods and tools can be used to manage user access rights to applications and resources in Kubernetes?
sobes.tech AI
Answer from AI
In Kubernetes, access rights management is implemented through the following mechanisms:
-
RBAC (Role-Based Access Control) — the main and most flexible method. It allows creating roles with a set of permissions and binding them to users or service accounts via RoleBinding or ClusterRoleBinding.
-
ABAC (Attribute-Based Access Control) — an older method based on policies describing attributes of subjects and objects. Less common.
-
Webhook Token Authentication — external authentication and authorization service.
-
Service Accounts — special accounts for pods, which can be assigned roles.
Example of creating a role and binding:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-pods
namespace: default
subjects:
- kind: User
name: jane
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.io
Thus, you can flexibly manage user and service access to Kubernetes resources.