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

Make ServiceAccount & RBAC configurable #138

Merged
merged 5 commits into from
Dec 17, 2024
Merged
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
2 changes: 1 addition & 1 deletion chart/templates/DeployType.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
annotations:
{{- toYaml .Values.podAnnotations | nindent 8 }}
spec:
serviceAccountName: k8s-ephemeral-storage-metrics
serviceAccountName: {{ include "chart.serviceAccountName" . }}
nodeSelector:
{{- toYaml .Values.nodeSelector | nindent 8 }}
{{- with .Values.affinity }}
Expand Down
28 changes: 14 additions & 14 deletions chart/templates/RBAC.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: {{ .Release.Name }}
{{- include "chart.labels" . | nindent 4 }}
name: {{ include "chart.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}

{{- if .Values.rbac.create }}
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand All @@ -11,18 +23,6 @@ rules:
verbs: ["get","list", "watch"]

---

apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: {{ .Release.Name }}
{{- include "chart.labels" . | nindent 4 }}
name: k8s-ephemeral-storage-metrics
namespace: {{ .Release.Namespace }}

---

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand All @@ -31,10 +31,10 @@ metadata:
{{- include "chart.labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: k8s-ephemeral-storage-metrics
name: {{ include "chart.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: k8s-ephemeral-storage-metrics
apiGroup: rbac.authorization.k8s.io

{{- end }}
2 changes: 1 addition & 1 deletion chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Create the name of the service account to use
*/}}
{{- define "chart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
{{- default (include "chart.name" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand Down
10 changes: 10 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ tolerations: []

priorityClassName:

# -- Service Account configuration
serviceAccount:
create: true
# If not set and create is true, a name is generated using the name template
name: null

# -- RBAC configuration
rbac:
create: true

# Pod Security Context
# ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
podSecurityContext:
Expand Down
Loading