Security - Role Based Access Control Flashcards
How do we link a user to a role?
via another object: RoleBinding .yaml
~~~
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: devuser-developer-binding
(namespaces if you want to limit, what it is applied to)
subjects:
- kind: User
name: dev-user
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: Role
name: developer
apiGroup: rbac.authorization.k8s.io
~~~
- create via kubectl
- falls under namespaces, applies to current namespace if not specified differently
How do we create a role?
role.yaml:
~~~
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: developer
rules:
- apiGroups: [””]
resources: [“pods”]
verbs: [“list”, “get”, “create”, “update”, “delete”]
- apiGroups: [””]
resources: [“ConfigMap”]
verbs: [“create”]
~~~
How can you check whether or not you have access to a certain object + verb?
kubectl auth can-i create deployments
How can you (as an admin) whether a certain user can do specific things?
kubectl auth can-i create pods –as dev-user
Where can you find the details about the kube-apiserver?
/etc/kubernetes/manifest/kube-apiserver.yaml
ps -aux | grep authorization
With what command can you imperatively create a role binding?
k create rolebinding dev-user-binding –role=developer –user=dev-user
What are Cluster Roles? Clusterrolebindings?
- used for access to cluster scoped resources
- beside that just like roles and rolebindings
How can resources be differentiated in terms of scope?
Resources can be
- namespaced (pods, jobs, deployments, services, roles, …)
- cluster scoped (nodes, PV, clusterroles, namespaces, clusterrolebindings, …)
What is the difference between namespaced and cluster-scoped resouces?
Namespaced resources adhere to a certain, specified namespace. If not specified to the default namespace.
Cluster-scoped resources are cluster-wide available
How does a Clusterrole yaml look like?
like a role-yaml just with kind=ClusterRole
Is it possible to define ClusterRoles for namespaced resources?
Yes, the access is then across all namespaces