Created
March 17, 2020 04:08
-
-
Save abhisek/73cd5a0972510ddadca4697fa6516faa to your computer and use it in GitHub Desktop.
Kubernetes Service Account with Pod CRUD Privilege to Single Namespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: developers | |
--- | |
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
namespace: developers | |
name: developer-sa | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: ClusterRole | |
metadata: | |
name: developer-role-ns | |
rules: | |
- apiGroups: | |
- "" | |
resources: | |
- namespaces | |
- pods | |
verbs: | |
- get | |
- list | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: Role | |
metadata: | |
name: developer-role-pod | |
namespace: developers | |
rules: | |
- apiGroups: | |
- "" | |
resources: ["pods", "pods/exec"] | |
verbs: ["get", "list", "create", "update", "delete", "exec", "watch", "patch", "edit"] | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: ClusterRoleBinding | |
metadata: | |
namespace: developers | |
name: developer-role-binding1 | |
roleRef: | |
kind: ClusterRole | |
name: developer-role-ns | |
apiGroup: rbac.authorization.k8s.io | |
subjects: | |
- kind: ServiceAccount | |
name: developer-sa | |
namespace: developers | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: RoleBinding | |
metadata: | |
namespace: developers | |
name: developer-role-binding2 | |
roleRef: | |
kind: Role | |
name: developer-role-pod | |
apiGroup: rbac.authorization.k8s.io | |
subjects: | |
- kind: ServiceAccount | |
name: developer-sa | |
namespace: developers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment