Skip to content

Commit f7e320d

Browse files
Add optional priority class support for Statefulsets (#277)
* Add optional priority class support for gitserver and indexed-search * fix new line * update test * extend symbols and searcher with priorityClass + add default to values.yaml * fix tests * Update docs * Update charts/sourcegraph/CHANGELOG.md Co-authored-by: Keegan Carruthers-Smith <[email protected]> --------- Co-authored-by: Keegan Carruthers-Smith <[email protected]>
1 parent 016aea8 commit f7e320d

File tree

9 files changed

+142
-0
lines changed

9 files changed

+142
-0
lines changed

charts/sourcegraph/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Use `**BREAKING**:` to denote a breaking change
88

99
## Unreleased
1010

11+
- Add support for PriorityClass in StatefulSets
12+
1113
## 5.0.3
1214

1315
- Add Embeddings service (disabled by default) for Cody embeddings

charts/sourcegraph/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ In addition to the documented values, all services also support the following va
252252
| preciseCodeIntel.resources | object | `{"limits":{"cpu":"2","memory":"4G"},"requests":{"cpu":"500m","memory":"2G"}}` | Resource requests & limits for the `precise-code-intel-worker` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
253253
| preciseCodeIntel.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `precise-code-intel-worker` |
254254
| preciseCodeIntel.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
255+
| priorityClasses | list | `[]` | Additional priorityClasses minimise re-scheduling downtime for StatefulSets. Each StatefulSets might use different priority class. learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) Sample class definition: - name: gitserver-class value: 100 preemptionPolicy: Never description: "gitserver priority class" |
255256
| prometheus.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":false,"runAsGroup":100,"runAsUser":100}` | Security context for the `prometheus` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
256257
| prometheus.enabled | bool | `true` | Enable `prometheus` (recommended) |
257258
| prometheus.existingConfig | string | `""` | Name of existing ConfigMap for `pgsql`. It must contain a `prometheus.yml` key |

charts/sourcegraph/templates/gitserver/gitserver.StatefulSet.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ spec:
108108
{{- if .Values.gitserver.extraVolumes }}
109109
{{- toYaml .Values.gitserver.extraVolumes | nindent 6 }}
110110
{{- end }}
111+
{{- if .Values.gitserver.priorityClassName }}
112+
priorityClassName: {{ .Values.gitserver.priorityClassName }}
113+
{{- end }}
111114
updateStrategy:
112115
type: RollingUpdate
113116
volumeClaimTemplates:

charts/sourcegraph/templates/indexed-search/indexed-search.StatefulSet.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ spec:
130130
{{- if .Values.indexedSearch.extraVolumes }}
131131
{{- toYaml .Values.indexedSearch.extraVolumes | nindent 6 }}
132132
{{- end }}
133+
{{- if .Values.indexedSearch.priorityClassName }}
134+
priorityClassName: {{ .Values.indexedSearch.priorityClassName }}
135+
{{- end }}
133136
updateStrategy:
134137
type: RollingUpdate
135138
volumeClaimTemplates:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- range $class := .Values.priorityClasses }}
2+
apiVersion: scheduling.k8s.io/v1
3+
kind: PriorityClass
4+
metadata:
5+
name: {{ $class.name }}
6+
value: {{ $class.value }}
7+
preemptionPolicy: {{ $class.preemptionPolicy }}
8+
globalDefault: false
9+
description: {{ $class.description | default "missing" }}
10+
---
11+
{{- end }}

charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ spec:
122122
{{- if .Values.searcher.extraVolumes }}
123123
{{- toYaml .Values.searcher.extraVolumes | nindent 6 }}
124124
{{- end }}
125+
{{- if .Values.searcher.priorityClassName }}
126+
priorityClassName: {{ .Values.searcher.priorityClassName }}
127+
{{- end }}
125128
volumeClaimTemplates:
126129
- metadata:
127130
name: cache

charts/sourcegraph/templates/symbols/symbols.StatefulSet.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ spec:
130130
{{- if .Values.symbols.extraVolumes }}
131131
{{- toYaml .Values.symbols.extraVolumes | nindent 6 }}
132132
{{- end }}
133+
{{- if .Values.symbols.priorityClassName }}
134+
priorityClassName: {{ .Values.symbols.priorityClassName }}
135+
{{- end }}
133136
volumeClaimTemplates:
134137
- metadata:
135138
name: cache
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
suite: priorityClass
2+
release:
3+
name: sourcegraph
4+
namespace: sourcegraph
5+
tests:
6+
- it: should render single priority class
7+
template: priorityClass.yaml
8+
set:
9+
priorityClasses:
10+
- name: gitserver-class
11+
value: 100
12+
preemptionPolicy: Never
13+
description: "gitserver priority class"
14+
asserts:
15+
- equal:
16+
path: metadata.name
17+
value: gitserver-class
18+
- equal:
19+
path: value
20+
value: 100
21+
- equal:
22+
path: preemptionPolicy
23+
value: Never
24+
- equal:
25+
path: description
26+
value: "gitserver priority class"
27+
- it: should render two priority classes
28+
template: priorityClass.yaml
29+
set:
30+
priorityClasses:
31+
- name: gitserver-class
32+
value: 100
33+
preemptionPolicy: Never
34+
description: "gitserver priority class"
35+
- name: indexed-search-class
36+
value: 101
37+
preemptionPolicy: PreemptLowerPriority
38+
description: "indexed-search priority class"
39+
asserts:
40+
- equal:
41+
path: metadata.name
42+
value: gitserver-class
43+
documentIndex: 0
44+
- equal:
45+
path: value
46+
value: 100
47+
documentIndex: 0
48+
- equal:
49+
path: preemptionPolicy
50+
value: Never
51+
documentIndex: 0
52+
- equal:
53+
path: description
54+
value: "gitserver priority class"
55+
documentIndex: 0
56+
- equal:
57+
path: metadata.name
58+
value: indexed-search-class
59+
documentIndex: 1
60+
- equal:
61+
path: value
62+
value: 101
63+
documentIndex: 1
64+
- equal:
65+
path: preemptionPolicy
66+
value: PreemptLowerPriority
67+
documentIndex: 1
68+
- equal:
69+
path: description
70+
value: "indexed-search priority class"
71+
documentIndex: 1
72+
- it: set priority class on gitserver
73+
template: gitserver/gitserver.StatefulSet.yaml
74+
set:
75+
gitserver:
76+
priorityClassName: gitserver-class
77+
asserts:
78+
- equal:
79+
path: spec.template.spec.priorityClassName
80+
value: gitserver-class
81+
- it: set priority class on indexed-search
82+
template: indexed-search/indexed-search.StatefulSet.yaml
83+
set:
84+
indexedSearch:
85+
priorityClassName: indexed-search-class
86+
asserts:
87+
- equal:
88+
path: spec.template.spec.priorityClassName
89+
value: indexed-search-class
90+
- it: set priority class on searcher
91+
template: searcher/searcher.StatefulSet.yaml
92+
set:
93+
searcher:
94+
priorityClassName: searcher-class
95+
asserts:
96+
- equal:
97+
path: spec.template.spec.priorityClassName
98+
value: searcher-class
99+
- it: set priority class on symbols
100+
template: symbols/symbols.StatefulSet.yaml
101+
set:
102+
symbols:
103+
priorityClassName: symbols-class
104+
asserts:
105+
- equal:
106+
path: spec.template.spec.priorityClassName
107+
value: symbols-class

charts/sourcegraph/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,3 +1305,12 @@ worker:
13051305

13061306
# -- Additional resources to include in the rendered manifest. Templates are supported.
13071307
extraResources: []
1308+
1309+
# -- Additional priorityClasses minimise re-scheduling downtime for StatefulSets. Each StatefulSets might use different priority class.
1310+
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass)
1311+
# Sample class definition:
1312+
# - name: gitserver-class
1313+
# value: 100
1314+
# preemptionPolicy: Never
1315+
# description: "gitserver priority class"
1316+
priorityClasses: []

0 commit comments

Comments
 (0)