-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helm: restrict RBAC namespaced deployments (#145)
* Helm: restrict RBAC namespaced deployments * Helm: restrict RBAC verbs, same changes as PR #143
- Loading branch information
Showing
3 changed files
with
104 additions
and
46 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{{- if .Values.rbacEnabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: nats-io:nats-operator-crd | ||
rules: | ||
# Allow creating CRDs | ||
- apiGroups: | ||
- apiextensions.k8s.io | ||
resources: | ||
- customresourcedefinitions | ||
verbs: ["get", "list", "create", "update", "watch"] | ||
# Allow all actions on NatsClusters | ||
- apiGroups: | ||
- nats.io | ||
resources: | ||
- natsclusters | ||
- natsserviceroles | ||
verbs: ["*"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: nats-io:nats-operator-crd-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: nats-io:nats-operator-crd | ||
subjects: | ||
- kind: ServiceAccount | ||
name: nats-operator | ||
namespace: {{ .Release.Namespace }} | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
{{- if .Values.clusterScoped }} | ||
kind: ClusterRole | ||
{{- else }} | ||
kind: Role | ||
{{- end }} | ||
metadata: | ||
name: nats-io:nats-operator | ||
rules: | ||
# Allowed actions on Pods | ||
- apiGroups: [""] | ||
resources: | ||
- pods | ||
verbs: ["create", "get", "patch", "update", "delete", "list"] | ||
|
||
# Allowed actions on Services | ||
- apiGroups: [""] | ||
resources: | ||
- services | ||
verbs: ["create", "get", "patch", "update", "delete", "list"] | ||
|
||
# Allowed actions on Secrets | ||
- apiGroups: [""] | ||
resources: | ||
- secrets | ||
verbs: ["create", "get", "update", "delete", "list"] | ||
|
||
# Allow all actions on some special subresources | ||
- apiGroups: [""] | ||
resources: | ||
- pods/exec | ||
- pods/log | ||
- serviceaccounts/token | ||
- events | ||
verbs: ["*"] | ||
|
||
# Allow listing Namespaces and ServiceAccounts | ||
- apiGroups: [""] | ||
resources: | ||
- namespaces | ||
- serviceaccounts | ||
verbs: | ||
- list | ||
|
||
# Allow actions on Endpoints | ||
- apiGroups: [""] | ||
resources: | ||
- endpoints | ||
verbs: ["get", "list", "update"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
{{- if .Values.clusterScoped }} | ||
kind: ClusterRoleBinding | ||
{{- else }} | ||
kind: RoleBinding | ||
{{- end }} | ||
metadata: | ||
name: nats-io:nats-operator-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
{{- if .Values.clusterScoped }} | ||
kind: ClusterRole | ||
{{- else }} | ||
kind: Role | ||
{{- end }} | ||
name: nats-io:nats-operator | ||
subjects: | ||
- kind: ServiceAccount | ||
name: nats-operator | ||
namespace: {{ .Release.Namespace }} | ||
{{- end }} |