Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding role for RBAC #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions example/StatefulSet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,10 @@ Put these in your connection url. For example:
```
mongodb://mongo-0.mongo,mongo-1.mongo,mongo-2.mongo:27017/dbname_?'
```

## RBAC Role
If you are running Kubernetes using RBAC, you will likely need to create a role with permission to list pods. The _role.yaml_ file contains an example role and binding which grants the necessary permissions to the default service account in the "mongo" namespace. Update as needed for your environment.

```
kubectl apply -f role.yaml
```
23 changes: 23 additions & 0 deletions example/StatefulSet/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: mongo
name: mongo-pod-read
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["get", "watch", "list"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: mongo-pod-read
namespace: mongo
subjects:
- kind: ServiceAccount
name: default
namespace: mongo
roleRef:
kind: Role
name: mongo-pod-read
apiGroup: rbac.authorization.k8s.io