Skip to content

Commit

Permalink
feat: ✨ ServiceAccount: Added Role Binding
Browse files Browse the repository at this point in the history
RoleBinding is a way to bind a Role to a user, group, or ServiceAccount within a namespace. A RoleBinding grants the permissions defined in a Role to the entity associated with the RoleBinding.  A RoleBinding consists of two parts: the Role that defines the permissions, and the subject that defines the entity to which the permissions are granted. The subject can be a user, group, or ServiceAccount.
  • Loading branch information
kevencript committed Mar 21, 2023
1 parent d6493a1 commit 9f1a54b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion k8s/service-account.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Service Accont
apiVersion: v1
kind: ServiceAccount
metadata:
name: server-service-account
---
# Role
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
Expand All @@ -11,4 +13,19 @@ metadata:
rules:
- apiGroups: [""] # "" Indicates the Core API group
resources: ["services"] # We are allowing Services
verbs: ["get", "watch", "list"] # We can do list operations on Services
verbs: ["get", "watch", "list"] # We can do list operations on Services
---
# Role Binding
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: service-reader-binding
namespace: server
subjects:
- kind: ServiceAccount
name: server-service-account # ServiceAccount name created above
namespace: server # ServiceAccount namespace
roleRef:
kind: Role
name: service-reader
apiGroup: rbac.authorization.k8s.io

0 comments on commit 9f1a54b

Please # to comment.