Skip to content
Draft
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
1 change: 1 addition & 0 deletions charts/sourcegraph/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ In addition to the documented values, all services also support the following va
- `<serviceName>.env` - consult `values.yaml` file
- `<serviceName>.serivceAccount.create` - create service account for service
- `<serviceName>.serviceAccount.annotations` - Annotations for the service-specific service account
- `<serviceName>.initContainers` - [learn more](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/)

{{ template "chart.valuesTable" . }}
10 changes: 10 additions & 0 deletions charts/sourcegraph/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,13 @@ checksum/auth: {{ toJson $checksum | sha256sum }}
{{- $checksum := append $checksum .Values.redisCache.connection -}}
checksum/redis: {{ toJson $checksum | sha256sum }}
{{- end -}}

{{- define "sourcegraph.initContainers" -}}
{{- $top := index . 0 }}
{{- $service := index . 1 }}
{{- $serviceInitContainers := (index $top.Values $service "initContainers") }}
{{- if $serviceInitContainers -}}
initContainers:
{{- $serviceInitContainers | toYaml | trim | nindent 2 -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ spec:
deploy: sourcegraph
app: blobstore
spec:
{{- include "sourcegraph.initContainers" (list . "blobstore") | nindent 6 }}
containers:
- name: blobstore
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
serviceName: indexed-search
template:
metadata:
{{- if or .Values.sourcegraph.podAnnotations .Values.indexedSearch.podAnnotations }}
{{- if or .Values.sourcegraph.podAnnotations .Values.indexedSearch.podAnnotations -}}
annotations:
{{- if .Values.sourcegraph.podAnnotations }}
{{- toYaml .Values.sourcegraph.podAnnotations | nindent 8 }}
Expand All @@ -41,6 +41,7 @@ spec:
app: indexed-search
deploy: sourcegraph
spec:
{{- include "sourcegraph.initContainers" (list . "indexedSearch") | nindent 6 }}
containers:
- name: zoekt-webserver
image: {{ include "sourcegraph.image" (list . "indexedSearch") }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
should not render initContainers when it is not set:
1: |
null
should render initContainers when it is set:
1: |
affinity: null
containers:
- env:
- name: OTEL_AGENT_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://$(OTEL_AGENT_HOST):4317
- name: OPENTELEMETRY_DISABLED
value: "false"
image: index.docker.io/sourcegraph/indexed-searcher:4.4.2@sha256:013190418308b94521e072972ae2342c41f99144205f58d61f5dfeda29ac0f58
imagePullPolicy: IfNotPresent
name: zoekt-webserver
ports:
- containerPort: 6070
name: http
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: http
scheme: HTTP
periodSeconds: 5
timeoutSeconds: 5
resources:
limits:
cpu: "2"
memory: 4G
requests:
cpu: 500m
memory: 2G
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsGroup: 101
runAsUser: 100
terminationMessagePolicy: FallbackToLogsOnError
volumeMounts:
- mountPath: /data
name: data
- env:
- name: OTEL_AGENT_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://$(OTEL_AGENT_HOST):4317
- name: OPENTELEMETRY_DISABLED
value: "false"
image: index.docker.io/sourcegraph/search-indexer:4.4.2@sha256:7716a32597300f7dfb7e974465a3bd3c62fae3aa485b48d9aa9f79ea3348f87f
imagePullPolicy: IfNotPresent
name: zoekt-indexserver
ports:
- containerPort: 6072
name: index-http
resources:
limits:
cpu: "8"
memory: 8G
requests:
cpu: "4"
memory: 4G
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsGroup: 101
runAsUser: 100
terminationMessagePolicy: FallbackToLogsOnError
volumeMounts:
- mountPath: /data
name: data
initContainers:
- command:
- echo
- hello
image: alpine
name: init
nodeSelector: null
securityContext:
fsGroup: 101
fsGroupChangePolicy: OnRootMismatch
tolerations: null
volumes:
- name: data
46 changes: 46 additions & 0 deletions charts/sourcegraph/tests/initContainers_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
suite: affinity
templates:
- searcher/searcher.StatefulSet.yaml
- indexed-search/indexed-search.StatefulSet.yaml
- codeinsights-db/codeinsights-db.StatefulSet.yaml
- grafana/grafana.StatefulSet.yaml
- codeintel-db/codeintel-db.StatefulSet.yaml
- symbols/symbols.StatefulSet.yaml
- pgsql/pgsql.StatefulSet.yaml
- gitserver/gitserver.StatefulSet.yaml
- frontend/sourcegraph-frontend.Deployment.yaml
- redis/redis-store.Deployment.yaml
- redis/redis-cache.Deployment.yaml
- jaeger/jaeger.Deployment.yaml
- blobstore/blobstore.Deployment.yaml
- syntect-server/syntect-server.Deployment.yaml
- precise-code-intel/worker.Deployment.yaml
- otel-collector/otel-collector.Deployment.yaml
- prometheus/prometheus.Deployment.yaml
- github-proxy/github-proxy.Deployment.yaml
- worker/worker.Deployment.yaml
release:
name: sourcegraph
namespace: sourcegraph
tests:
- it: should render initContainers when it is set
set:
indexedSearch:
initContainers:
- name: init
image: alpine
command: ["echo", "hello"]
asserts:
- equal:
path: spec.template.spec.initContainers
value:
- name: init
image: alpine
command: ["echo", "hello"]
- matchSnapshot:
path: spec.template.spec

- it: should not render initContainers when it is not set
asserts:
- matchSnapshot:
path: spec.template.spec.initContainers