Skip to content

Commit

Permalink
Ensure postgresclusters are available to admin/edit/view clusterroles
Browse files Browse the repository at this point in the history
See https://kubernetes.io/docs/reference/access-authn-authz/rbac/#aggregated-clusterroles

Signed-off-by: Mathieu Parent <math.parent@gmail.com>
  • Loading branch information
sathieu committed Apr 29, 2022
1 parent 6e91c1d commit d7f0c8b
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
24 changes: 24 additions & 0 deletions helm/install/templates/clusterrole-aggregate-edit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.createAggregateRoles }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Chart.Name }}-aggregate-edit
labels:
{{- include "install.labels" . | nindent 4 }}
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rules:
- apiGroups:
- postgres-operator.crunchydata.com
resources:
- postgresclusters
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
{{- end }}
20 changes: 20 additions & 0 deletions helm/install/templates/clusterrole-aggregate-view.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.createAggregateRoles }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Chart.Name }}-aggregate-view
labels:
{{- include "install.labels" . | nindent 4 }}
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-view: "true"
rules:
- apiGroups:
- postgres-operator.crunchydata.com
resources:
- postgresclusters
verbs:
- get
- list
- watch
{{- end }}
4 changes: 4 additions & 0 deletions helm/install/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ debug: true
# imagePullSecretNames is a list of secret names to use for pulling controller images.
# More info: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod
imagePullSecretNames: []

# Create aggregated ClusterRoles
# See https://kubernetes.io/docs/reference/access-authn-authz/rbac/#aggregated-clusterroles
createAggregateRoles: true
21 changes: 21 additions & 0 deletions kustomize/install/rbac/cluster/clusterrole-aggregate-edit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: postgres-operator-aggregate-edit
labels:
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rules:
- apiGroups:
- postgres-operator.crunchydata.com
resources:
- postgresclusters
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
17 changes: 17 additions & 0 deletions kustomize/install/rbac/cluster/clusterrole-aggregate-view.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: postgres-operator-aggregate-view
labels:
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-view: "true"
rules:
- apiGroups:
- postgres-operator.crunchydata.com
resources:
- postgresclusters
verbs:
- get
- list
- watch
2 changes: 2 additions & 0 deletions kustomize/install/rbac/cluster/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ resources:
- service_account-upgrade.yaml
- role-upgrade.yaml
- role_binding-upgrade.yaml
- clusterrole-aggregate-edit.yaml
- clusterrole-aggregate-view.yaml

0 comments on commit d7f0c8b

Please sign in to comment.