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
1 change: 1 addition & 0 deletions charts/sourcegraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Use `**BREAKING**:` to denote a breaking change

## Unreleased

- Added support for overriding `replicaCount` per dedicated `worker` replica via `worker.replicas[].replicaCount`, falling back to `worker.replicaCount` when unset
- Added support for overriding the image repository on a per-service basis via `<serviceName>.image.repository`, falling back to the global `sourcegraph.image.repository` when unset
- Added livenessProbe to zoekt-webserver in indexed-search to detect and restart hung pods
- Fix Pod Disruption Budget for sourcegraph-frontend
Expand Down
3 changes: 2 additions & 1 deletion charts/sourcegraph/templates/_worker.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{{- $allowlist := index . 2 -}}
{{- $blocklist := index . 3 -}}
{{- $resources := index . 4 -}}
{{- $replicaCount := index . 5 -}}

{{- $name := $top.Values.worker.name -}}
{{- if $suffix -}}
Expand All @@ -24,7 +25,7 @@ metadata:
name: {{ $name }}
spec:
minReadySeconds: 10
replicas: {{ $top.Values.worker.replicaCount }}
replicas: {{ $replicaCount }}
revisionHistoryLimit: {{ $top.Values.sourcegraph.revisionHistoryLimit }}
selector:
matchLabels:
Expand Down
10 changes: 7 additions & 3 deletions charts/sourcegraph/templates/worker/worker.Deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{- end }}

{{- if not .Values.worker.replicas }}
{{- include "sourcegraph.worker" (list . "" "" $globalBlocklist .Values.worker.resources ) | nindent 0 }}
{{- include "sourcegraph.worker" (list . "" "" $globalBlocklist .Values.worker.resources .Values.worker.replicaCount ) | nindent 0 }}
{{- else }}
{{- $dedicatedJobs := list }}
{{- $dedicatedJobs = $dedicatedJobs | concat .Values.worker.blocklist }}
Expand All @@ -13,7 +13,7 @@
{{- end }}
{{- $primaryBlocklist := join "," ($dedicatedJobs | uniq | sortAlpha) }}
---
{{- include "sourcegraph.worker" (list . "" "all" $primaryBlocklist $.Values.worker.resources) | nindent 0 }}
{{- include "sourcegraph.worker" (list . "" "all" $primaryBlocklist $.Values.worker.resources $.Values.worker.replicaCount) | nindent 0 }}

{{- range $idx, $item := .Values.worker.replicas }}
---
Expand All @@ -23,6 +23,10 @@
{{- if $item.resources -}}
{{- $resources = $item.resources -}}
{{- end -}}
{{- include "sourcegraph.worker" (list $ $replicaName $allowlist "" $resources) | nindent 0 }}
{{- $replicaCount := $.Values.worker.replicaCount -}}
{{- if $item.replicaCount -}}
{{- $replicaCount = $item.replicaCount -}}
{{- end -}}
{{- include "sourcegraph.worker" (list $ $replicaName $allowlist "" $resources $replicaCount) | nindent 0 }}
{{- end }}
{{- end }}
58 changes: 58 additions & 0 deletions charts/sourcegraph/tests/worker_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,61 @@ tests:
requests:
cpu: 2000m
memory: 4Gi
- it: should default each replica deployment to worker.replicaCount when replicaCount is not overridden
template: worker/worker.Deployment.yaml
set:
worker:
replicaCount: 2
replicas:
- jobs: ["job1", "job2"]
- jobs: ["job3", "job4"]
asserts:
- equal:
path: spec.replicas
value: 2
documentIndex: 0
- equal:
path: spec.replicas
value: 2
documentIndex: 1
- equal:
path: spec.replicas
value: 2
documentIndex: 2
- it: should override replicaCount per replica deployment
template: worker/worker.Deployment.yaml
set:
worker:
replicaCount: 1
replicas:
- jobs: ["job1", "job2"]
replicaCount: 3
- jobs: ["job3", "job4"]
asserts:
- containsDocument:
kind: Deployment
apiVersion: apps/v1
name: worker
documentIndex: 0
- equal:
path: spec.replicas
value: 1
documentIndex: 0
- containsDocument:
kind: Deployment
apiVersion: apps/v1
name: worker-0
documentIndex: 1
- equal:
path: spec.replicas
value: 3
documentIndex: 1
- containsDocument:
kind: Deployment
apiVersion: apps/v1
name: worker-1
documentIndex: 2
- equal:
path: spec.replicas
value: 1
documentIndex: 2
3 changes: 3 additions & 0 deletions charts/sourcegraph/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,9 @@ worker:
replicas:
[]
# - jobs: []
# # -- Number of pods for this dedicated worker replica. Defaults to worker.replicaCount.
# # Only increase this for replicas whose jobs are safe to scale horizontally.
# replicaCount: 1
# resources:
# limits:
# cpu: "2"
Expand Down
Loading