Created
July 14, 2022 18:23
-
-
Save sergsoares/fd876e868e851b58ccfe5c6b9e195be9 to your computer and use it in GitHub Desktop.
Create a Cluster Role but only use RoleBinding to give access for only 2 specific namespaces (otherwise all namespaces like ClusterRoleBinding)
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: ServiceAccount | |
metadata: | |
name: myapp | |
namespace: mynamespace | |
--- | |
kind: ClusterRole | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
namespace: mynamespace | |
name: myapp | |
rules: | |
- apiGroups: [""] | |
resources: | |
- "secrets" | |
- "pods" | |
- "configmaps" | |
- "services" | |
- "deployments" | |
- "replicasets" | |
- "horizontalpodautoscalers" | |
- "ingresses" | |
verbs: ["*"] | |
--- | |
kind: RoleBinding | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: myapp | |
namespace: mynamespace | |
subjects: | |
- kind: ServiceAccount | |
name: myapp | |
namespace: mynamespace | |
roleRef: | |
kind: ClusterRole | |
name: myapp | |
apiGroup: rbac.authorization.k8s.io | |
--- | |
kind: RoleBinding | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: myapp | |
namespace: default | |
subjects: | |
- kind: ServiceAccount | |
name: myapp | |
namespace: other-namespace | |
roleRef: | |
kind: ClusterRole | |
name: myapp | |
apiGroup: rbac.authorization.k8s.io |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment