Reputation: 13
I have a service account with a Policy Rule that works perfectly in mynamespace. But it also works perfectly in other namespaces, which I want to prevent.
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: myapp
namespace: mynamespace
rules:
- apiGroups: ["extensions"]
resources: ["deployments"]
verbs: ["get", "patch"]
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: myapp
namespace: mynamespace
---
kind: ClusterRoleBinding
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
Upvotes: 1
Views: 129