Skip to content
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
38 changes: 36 additions & 2 deletions charts/sourcegraph/README.md

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion charts/sourcegraph/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ Create the name of the service account to use
{{- define "sourcegraph.serviceAccountName" -}}
{{- $top := index . 0 }}
{{- $service := index . 1 }}
{{- default $service (index $top.Values $service "serviceAccount" "name") }}
{{- $defaultServiceAccountName := ((snakecase $service) | replace "_" "-") }}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think the convention of resource name is dashed instead of camelCase

this line does the following

camelCase -> snake_case -> replace("_", "-")

repoUpdater -> repo_updater -> repo-updater

codeInsightsDb -> code_insights_db -> code-insights-db
in this case, ideally we want codeinsights-db to be consistent with the deployment name, but the top-level key in values.yaml is codeInsightsDB instead of `codeinsightsDB.

{{- default $defaultServiceAccountName (index $top.Values $service "serviceAccount" "name") }}
{{- end }}

{{- define "sourcegraph.renderServiceAccountName" -}}
{{- $top := index . 0 }}
{{- $service := index . 1 }}
{{- if or (index $top.Values $service "serviceAccount" "create") (index $top.Values $service "serviceAccount" "name") }}
serviceAccountName: {{ include "sourcegraph.serviceAccountName" (list $top $service) }}
{{- end }}
Comment on lines +44 to +53
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

a different implementation would be rendering serviceAccountName: default whenever .serviceAccount.create=true and .serviceAccount.name!="

They work the same tho

{{- end }}

{{/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
deploy: sourcegraph
app: cadvisor
spec:
serviceAccountName: {{ include "sourcegraph.serviceAccountName" (list . "cadvisor") }}
{{- include "sourcegraph.renderServiceAccountName" (list . "cadvisor") | trim | nindent 6 }}
containers:
- name: cadvisor
image: {{ include "sourcegraph.image" (list . "cadvisor" ) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: 120
{{- include "sourcegraph.renderServiceAccountName" (list . "codeInsightsDB") | trim | nindent 6 }}
volumes:
- name: disk
persistentVolumeClaim:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.codeInsightsDB.enabled .Values.codeInsightsDB.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: codeinsights-db
name: {{ include "sourcegraph.serviceAccountName" (list . "codeInsightsDB") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "codeIntelDB") | trim | nindent 6 }}
volumes:
- name: disk
persistentVolumeClaim:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.codeIntelDB.enabled .Values.codeIntelDB.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: codeintel-db
name: {{ include "sourcegraph.serviceAccountName" (list . "codeIntelDB") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "sourcegraph.serviceAccountName" (list . "frontend") }}
{{- include "sourcegraph.renderServiceAccountName" (list . "frontend") | trim | nindent 6 }}
volumes:
- emptyDir: {}
name: cache-ssd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "githubProxy") | trim | nindent 6 }}
volumes:
{{- if .Values.githubProxy.extraVolumes }}
{{- toYaml .Values.githubProxy.extraVolumes | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.githubProxy.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: github-proxy
name: {{ include "sourcegraph.serviceAccountName" (list . "githubProxy") }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.gitserver.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: gitserver
name: {{ include "sourcegraph.serviceAccountName" (list . "gitserver") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "gitserver") | trim | nindent 6 }}
volumes:
- name: repos
{{- if .Values.gitserver.sshSecret }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ spec:
{{- end }}
securityContext:
{{- toYaml .Values.grafana.containerSecurityContext | nindent 10 }}
serviceAccountName: grafana
{{- include "sourcegraph.renderServiceAccountName" (list . "grafana") | trim | nindent 6 }}
{{- if .Values.grafana.extraContainers }}
{{- toYaml .Values.grafana.extraContainers | nindent 6 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.indexedSearch.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: indexed-search
name: {{ include "sourcegraph.serviceAccountName" (list . "indexedSearch") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "indexedSearch") | trim | nindent 6 }}
volumes:
- name: data
{{- if .Values.indexedSearch.extraVolumes }}
Expand Down
1 change: 1 addition & 0 deletions charts/sourcegraph/templates/jaeger/jaeger.Deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ spec:
{{- with .Values.sourcegraph.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- include "sourcegraph.renderServiceAccountName" (list . "tracing") | trim | nindent 6 }}
{{- end }}
volumes:
{{- if .Values.tracing.extraVolumes }}
Expand Down
10 changes: 10 additions & 0 deletions charts/sourcegraph/templates/jaeger/jaeger.ServiceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.tracing.enabled .Values.tracing.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: tracing
name: {{ include "sourcegraph.serviceAccountName" (list . "tracing") }}
{{- end }}
1 change: 1 addition & 0 deletions charts/sourcegraph/templates/minio/minio.Deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "minio") | trim | nindent 6 }}
volumes:
- name: minio-data
persistentVolumeClaim:
Expand Down
10 changes: 10 additions & 0 deletions charts/sourcegraph/templates/minio/minio.ServiceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.minio.enabled .Values.minio.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: minio
name: {{ include "sourcegraph.serviceAccountName" (list . "minio") }}
{{- end }}
1 change: 1 addition & 0 deletions charts/sourcegraph/templates/pgsql/pgsql.Deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "pgsql") | trim | nindent 6 }}
volumes:
- name: disk
persistentVolumeClaim:
Expand Down
10 changes: 10 additions & 0 deletions charts/sourcegraph/templates/pgsql/pgsql.ServiceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.pgsql.enabled .Values.pgsql.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: pgsql
name: {{ include "sourcegraph.serviceAccountName" (list . "pgsql") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "preciseCodeIntel") | trim | nindent 6 }}
volumes:
{{- if .Values.preciseCodeIntel.extraVolumes }}
{{- toYaml .Values.preciseCodeIntel.extraVolumes | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.preciseCodeIntel.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: precise-code-intel
name: {{ include "sourcegraph.serviceAccountName" (list . "preciseCodeIntel") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: prometheus
{{- include "sourcegraph.renderServiceAccountName" (list . "prometheus") | trim | nindent 6 }}
volumes:
- name: data
persistentVolumeClaim:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "redisCache") | trim | nindent 6 }}
volumes:
- name: redis-data
persistentVolumeClaim:
Expand Down
10 changes: 10 additions & 0 deletions charts/sourcegraph/templates/redis/redis-cache.ServiceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.redisCache.enabled .Values.redisCache.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: redis
name: {{ include "sourcegraph.serviceAccountName" (list . "redisCache") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "redisStore") | trim | nindent 6 }}
volumes:
- name: redis-data
persistentVolumeClaim:
Expand Down
10 changes: 10 additions & 0 deletions charts/sourcegraph/templates/redis/redis-store.ServiceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.redisStore.enabled .Values.redisStore.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: redis
name: {{ include "sourcegraph.serviceAccountName" (list . "redisStore") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "repoUpdater") | trim | nindent 6 }}
volumes:
{{- if .Values.repoUpdater.extraVolumes }}
{{- toYaml .Values.repoUpdater.extraVolumes | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.repoUpdater.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: repo-updater
name: {{ include "sourcegraph.serviceAccountName" (list . "repoUpdater") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "searcher") | trim | nindent 6 }}
volumes:
- emptyDir: {}
name: cache-ssd
Expand Down
10 changes: 10 additions & 0 deletions charts/sourcegraph/templates/searcher/searcher.ServiceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.searcher.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: searcher
name: {{ include "sourcegraph.serviceAccountName" (list . "searcher") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "symbols") | trim | nindent 6 }}
volumes:
- emptyDir: {}
name: cache-ssd
Expand Down
10 changes: 10 additions & 0 deletions charts/sourcegraph/templates/symbols/symbols.ServiceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.symbols.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: symbols
name: {{ include "sourcegraph.serviceAccountName" (list . "symbols") }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "syntectServer") | trim | nindent 6 }}
volumes:
{{- if .Values.syntectServer.extraVolumes }}
{{- toYaml .Values.syntectServer.extraVolumes | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.syntectServer.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: syntect-server
name: {{ include "sourcegraph.serviceAccountName" (list . "syntectServer") }}
{{- end }}
1 change: 1 addition & 0 deletions charts/sourcegraph/templates/worker/worker.Deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "worker") | trim | nindent 6 }}
volumes:
{{- if .Values.worker.extraVolumes }}
{{- toYaml .Values.worker.extraVolumes | nindent 6 }}
Expand Down
10 changes: 10 additions & 0 deletions charts/sourcegraph/templates/worker/worker.ServiceAccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.worker.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
category: rbac
deploy: sourcegraph
app.kubernetes.io/component: worker
name: {{ include "sourcegraph.serviceAccountName" (list . "worker") }}
{{- end }}
Loading