From 3c8d89ca990b593f9302d6b8bb49f4f517bb6ec3 Mon Sep 17 00:00:00 2001 From: camper42 Date: Thu, 14 Sep 2023 11:39:04 +0800 Subject: [PATCH] [CELEBORN-969][HELM] Allow user set priorityClass used by celeborn pods ### What changes were proposed in this pull request? Allow user set priorityClass used by celeborn pods ### Why are the changes needed? Allow user set a proper priorityClass to avoid unwanted evict happens. ### Does this PR introduce _any_ user-facing change? No, default values change nothing. ### How was this patch tested? Run test locally before make a pull request `helm template test charts/celeborn > new_rendered.yaml` && `diff old_rendered.yaml new_rendered.yaml` Closes #1902 from camper42/priority-class. Authored-by: camper42 Signed-off-by: zky.zhoukeyong --- .../templates/master-priorityclass.yaml | 31 +++++++++++++++++++ .../templates/master-statefulset.yaml | 5 ++- .../templates/worker-priorityclass.yaml | 31 +++++++++++++++++++ .../templates/worker-statefulset.yaml | 3 ++ charts/celeborn/values.yaml | 16 ++++++++++ 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 charts/celeborn/templates/master-priorityclass.yaml create mode 100644 charts/celeborn/templates/worker-priorityclass.yaml diff --git a/charts/celeborn/templates/master-priorityclass.yaml b/charts/celeborn/templates/master-priorityclass.yaml new file mode 100644 index 000000000..753fc00b9 --- /dev/null +++ b/charts/celeborn/templates/master-priorityclass.yaml @@ -0,0 +1,31 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +{{- if .Values.priorityClass.master.create }} +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: {{ .Values.priorityClass.master.name | default (printf "%s-master-priority" (.Release.Name)) }} + labels: + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "celeborn.labels" . | nindent 4 }} +value: {{ .Values.priorityClass.master.value }} +{{- end }} diff --git a/charts/celeborn/templates/master-statefulset.yaml b/charts/celeborn/templates/master-statefulset.yaml index 7b83aab67..a69cb83f2 100644 --- a/charts/celeborn/templates/master-statefulset.yaml +++ b/charts/celeborn/templates/master-statefulset.yaml @@ -67,6 +67,9 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- if or .Values.priorityClass.master.name .Values.priorityClass.master.create }} + priorityClassName: {{ .Values.priorityClass.master.name | default (printf "%s-master-priority" (.Release.Name)) }} + {{- end }} {{- with .Values.securityContext }} securityContext: {{- toYaml . | nindent 8 }} @@ -120,7 +123,7 @@ spec: - name: {{ $key }} value: {{ $val | quote }} {{- end}} - terminationGracePeriodSeconds: 30 + terminationGracePeriodSeconds: 30 volumes: - configMap: name: {{ .Release.Name }}-conf diff --git a/charts/celeborn/templates/worker-priorityclass.yaml b/charts/celeborn/templates/worker-priorityclass.yaml new file mode 100644 index 000000000..371f04628 --- /dev/null +++ b/charts/celeborn/templates/worker-priorityclass.yaml @@ -0,0 +1,31 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +{{- if .Values.priorityClass.worker.create }} +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: {{ .Values.priorityClass.worker.name | default (printf "%s-worker-priority" (.Release.Name)) }} + labels: + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "celeborn.labels" . | nindent 4 }} +value: {{ .Values.priorityClass.worker.value }} +{{- end }} diff --git a/charts/celeborn/templates/worker-statefulset.yaml b/charts/celeborn/templates/worker-statefulset.yaml index 7b9f0ad53..19df75577 100644 --- a/charts/celeborn/templates/worker-statefulset.yaml +++ b/charts/celeborn/templates/worker-statefulset.yaml @@ -67,6 +67,9 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- if or .Values.priorityClass.worker.name .Values.priorityClass.worker.create }} + priorityClassName: {{ .Values.priorityClass.worker.name | default (printf "%s-worker-priority" (.Release.Name)) }} + {{- end }} {{- with .Values.securityContext }} securityContext: {{- toYaml . | nindent 8 }} diff --git a/charts/celeborn/values.yaml b/charts/celeborn/values.yaml index 2d754f58a..fe295f84b 100644 --- a/charts/celeborn/values.yaml +++ b/charts/celeborn/values.yaml @@ -138,6 +138,22 @@ resources: {} # cpu: 100m # memory: 128Mi +# priorityClass used for Celeborn pods +priorityClass: + master: + # Specifies whether a priorityClass should be created + create: false + # Specifies priorityClass name to be used (created if `create: true`) + name: ~ + # half of system-cluster-critical by default + value: 1000000000 + + worker: + create: false + name: ~ + # celeborn master minus 1000 + value: 999999000 + podAnnotations: {} affinity: