Skip to content

Commit 8bde04f

Browse files
authored
feat(chart): add flags for podPriorityClassName (#2499)
Signed-off-by: Arthur Le Roux <[email protected]>
1 parent 473a203 commit 8bde04f

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

charts/postgres-operator/templates/_helpers.tpl

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ Create a pod service account name.
3838
{{ default (printf "%s-%v" (include "postgres-operator.fullname" .) "pod") .Values.podServiceAccount.name }}
3939
{{- end -}}
4040

41+
{{/*
42+
Create a pod priority class name.
43+
*/}}
44+
{{- define "postgres-pod.priorityClassName" -}}
45+
{{ default (printf "%s-%v" (include "postgres-operator.fullname" .) "pod") .Values.podPriorityClassName.name }}
46+
{{- end -}}
47+
4148
{{/*
4249
Create a controller ID.
4350
*/}}

charts/postgres-operator/templates/configmap.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ metadata:
1010
app.kubernetes.io/managed-by: {{ .Release.Service }}
1111
app.kubernetes.io/instance: {{ .Release.Name }}
1212
data:
13-
{{- if .Values.podPriorityClassName }}
14-
pod_priority_class_name: {{ .Values.podPriorityClassName }}
15-
{{- end }}
13+
{{- if or .Values.podPriorityClassName.create .Values.podPriorityClassName.name }}
14+
pod_priority_class_name: {{ include "postgres-pod.priorityClassName" . }}
15+
{{- end }}
1616
pod_service_account_name: {{ include "postgres-pod.serviceAccountName" . }}
1717
{{- include "flattenValuesForConfigMap" .Values.configGeneral | indent 2 }}
1818
{{- include "flattenValuesForConfigMap" .Values.configUsers | indent 2 }}

charts/postgres-operator/templates/operatorconfiguration.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ configuration:
1616
major_version_upgrade:
1717
{{ toYaml .Values.configMajorVersionUpgrade | indent 4 }}
1818
kubernetes:
19-
{{- if .Values.podPriorityClassName }}
20-
pod_priority_class_name: {{ .Values.podPriorityClassName }}
19+
{{- if .Values.podPriorityClassName.name }}
20+
pod_priority_class_name: {{ .Values.podPriorityClassName.name }}
2121
{{- end }}
2222
pod_service_account_name: {{ include "postgres-pod.serviceAccountName" . }}
2323
oauth_token_secret_name: {{ template "postgres-operator.fullname" . }}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.podPriorityClassName }}
1+
{{- if .Values.podPriorityClassName.create }}
22
apiVersion: scheduling.k8s.io/v1
33
description: 'Use only for databases controlled by Postgres operator'
44
kind: PriorityClass
@@ -8,9 +8,9 @@ metadata:
88
helm.sh/chart: {{ template "postgres-operator.chart" . }}
99
app.kubernetes.io/managed-by: {{ .Release.Service }}
1010
app.kubernetes.io/instance: {{ .Release.Name }}
11-
name: {{ .Values.podPriorityClassName }}
11+
name: {{ include "postgres-pod.priorityClassName" . }}
1212
namespace: {{ .Release.Namespace }}
1313
preemptionPolicy: PreemptLowerPriority
1414
globalDefault: false
15-
value: 1000000
15+
value: {{ .Values.podPriorityClassName.priority }}
1616
{{- end }}

charts/postgres-operator/values.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,14 @@ podServiceAccount:
468468
priorityClassName: ""
469469

470470
# priority class for database pods
471-
podPriorityClassName: ""
471+
podPriorityClassName:
472+
# If create is false with no name set, no podPriorityClassName is specified.
473+
# Hence, the pod priorityClass is the one with globalDefault set.
474+
# If there is no PriorityClass with globalDefault set, the priority of Pods with no priorityClassName is zero.
475+
create: true
476+
# If not set a name is generated using the fullname template and "-pod" suffix
477+
name: ""
478+
priority: 1000000
472479

473480
resources:
474481
limits:

0 commit comments

Comments
 (0)