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 service account #398

Merged
merged 1 commit into from
Sep 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
7 changes: 5 additions & 2 deletions deploy/sigma/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ dependencies:
- name: mysql
repository: https://charts.bitnami.com/bitnami
version: 11.1.16
digest: sha256:c9150c78d68a1fe55f7f0ba70b03e6e949cdccb6b71dd0ea8fa835537fdab32f
generated: "2024-09-17T03:30:37.546585+08:00"
- name: common
repository: https://charts.bitnami.com/bitnami
version: 2.23.0
digest: sha256:4e84624bf97a56d365ab60c079ac19b0edd4a1299e98fa76390fb1e767557194
generated: "2024-09-17T20:45:36.213184+08:00"
3 changes: 3 additions & 0 deletions deploy/sigma/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ dependencies:
version: 11.1.16
repository: https://charts.bitnami.com/bitnami
condition: mysql.enabled
- name: common
version: 2.23.0
repository: https://charts.bitnami.com/bitnami
2 changes: 1 addition & 1 deletion deploy/sigma/templates/distribution/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ spec:
{{- include "sigma.distribution.labels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
rollme: {{ randAlphaNum 5 | quote }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
Expand Down
5 changes: 3 additions & 2 deletions deploy/sigma/templates/server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ spec:
{{- include "sigma.server.labels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
rollme: {{ randAlphaNum 5 | quote }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "sigma.server.labels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
rollme: {{ randAlphaNum 5 | quote }}
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
serviceAccountName: {{ include "sigma.fullname" . | quote }}
containers:
- name: {{ printf "%s-server" .Chart.Name }}
securityContext:
Expand Down
84 changes: 84 additions & 0 deletions deploy/sigma/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
kind: Role
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
name: {{ include "sigma.fullname" . | quote }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- $versionLabel := dict "app.kubernetes.io/version" ( include "common.images.version" ( dict "imageRoot" .Values.image "chart" .Chart ) ) }}
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.commonLabels $versionLabel ) "context" . ) }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- ""
resources:
- configmaps/status
verbs:
- get
- update
- patch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- apiGroups:
- "coordination.k8s.io"
resources:
- leases
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
---
kind: RoleBinding
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
name: {{ include "sigma.fullname" . | quote }}
{{- $versionLabel := dict "app.kubernetes.io/version" ( include "common.images.version" ( dict "imageRoot" .Values.image "chart" .Chart ) ) }}
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.commonLabels $versionLabel ) "context" . ) }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "sigma.fullname" . | quote }}
subjects:
- kind: ServiceAccount
name: {{ template "sigma.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "sigma.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
{{- $versionLabel := dict "app.kubernetes.io/version" ( include "common.images.version" ( dict "imageRoot" .Values.image "chart" .Chart ) ) }}
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.commonLabels $versionLabel ) "context" . ) }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
{{- if or .Values.serviceAccount.annotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceAccount.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
2 changes: 1 addition & 1 deletion deploy/sigma/templates/web/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ spec:
{{- include "sigma.web.labels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
rollme: {{ randAlphaNum 5 | quote }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
Expand Down
3 changes: 2 additions & 1 deletion deploy/sigma/templates/worker/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ spec:
{{- include "sigma.worker.labels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
rollme: {{ randAlphaNum 5 | quote }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
Expand All @@ -27,6 +27,7 @@ spec:
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
serviceAccountName: {{ include "sigma.fullname" . | quote }}
containers:
- name: {{ printf "%s-worker" .Chart.Name }}
securityContext:
Expand Down
14 changes: 12 additions & 2 deletions deploy/sigma/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## @param commonLabels Labels to add to all deployed objects
commonLabels: {}
## @param commonAnnotations Annotations to add to all deployed objects
commonAnnotations: {}

image:
registry: ghcr.io
repository: go-sigma/sigma
Expand Down Expand Up @@ -61,8 +66,7 @@ ingress:
# hosts:
# - chart-example.local

resources:
{}
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
Expand Down Expand Up @@ -92,6 +96,12 @@ tolerations: []

affinity: {}

serviceAccount:
## @param serviceAccount.annotations Additional Service Account annotations (evaluated as a template)
annotations: {}
## @param serviceAccount.automountServiceAccountToken Automount service account token for the server service account
automountServiceAccountToken: false

config:
log:
level: debug
Expand Down
Loading