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

Add the capability to use RoleBindings instead of ClusterRoleBindings #841

Open
wants to merge 5 commits into
base: main
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.useRoleBindings }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-manager-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-manager-role
subjects:
- kind: ServiceAccount
name: {{ include "opensearch-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- else }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-manager-cluster-rolebinding
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-manager-cluster-rolebinding
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-manager-rolebinding

Name should stay the same as it is now, IMO it is also not a problem if rolebinding and clusterrolebinding are named the same

roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-manager-role
subjects:
- kind: ServiceAccount
name: {{ include "opensearch-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.useRoleBindings }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-proxy-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-proxy-role
subjects:
- kind: ServiceAccount
name: {{ include "opensearch-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- else }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-proxy-cluster-rolebinding
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-proxy-cluster-rolebinding
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-proxy-rolebinding

roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "opensearch-operator.fullname" . }}-{{ .Release.Namespace }}-proxy-role
subjects:
- kind: ServiceAccount
name: {{ include "opensearch-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/opensearch-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,9 @@ kubeRbacProxy:
image:
repository: "gcr.io/kubebuilder/kube-rbac-proxy"
tag: "v0.15.0"

## If this is set to true, RoleBindings will be used instead of ClusterRoleBindings, inorder to restrict ClusterRoles
## to the namespace where the operator and OpenSearch cluster are in. In that case, specify the namespace where they
## are in in manager.watchNamespace field.
## If false, ClusterRoleBindings will be used
useRoleBindings: false