Skip to content

Commit

Permalink
Merge pull request #306 from redpanda-data/ae/issues/305
Browse files Browse the repository at this point in the history
fix: allow jobs and sts to have the same tolerations and nodeselectors
  • Loading branch information
joejulian authored Feb 3, 2023
2 parents 0909fb7 + 129c4a9 commit 27b3a6a
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/redpanda/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type: application
# The chart version and the app version are not the same and will not track
# together. The chart version is a semver representation of changes to this
# chart.
version: 2.6.5
version: 2.6.6

# The app version is the default version of Redpanda to install.
appVersion: v22.3.10
Expand Down
38 changes: 38 additions & 0 deletions charts/redpanda/templates/_statefulset-helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{/*
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.
*/}}

{{/*
Set tolerations for statefulset, defaults to global tolerations if not defined in statefulset
*/}}
{{- define "statefulset-tolerations" -}}
{{- $tolerations := .Values.tolerations -}}
{{- if not ( empty .Values.statefulset.tolerations ) -}}
{{- $tolerations = .Values.statefulset.tolerations -}}
{{- end -}}
{{- toYaml $tolerations -}}
{{- end -}}

{{/*
Set nodeSelector for statefulset, defaults to global nodeSelector if not defined in statefulset
*/}}
{{- define "statefulset-nodeSelectors" -}}
{{- $nodeSelectors := .Values.nodeSelector -}}
{{- if not ( empty .Values.statefulset.nodeSelector ) -}}
{{- $nodeSelectors = .Values.statefulset.nodeSelector -}}
{{- end -}}
{{- toYaml $nodeSelectors -}}
{{- end -}}
6 changes: 6 additions & 0 deletions charts/redpanda/templates/post-install-upgrade-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.nodeSelector }}
nodeSelector: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations: {{- toYaml . | nindent 8 }}
{{- end }}
restartPolicy: Never
securityContext: {{ include "pod-security-context" . | nindent 8 }}
containers:
Expand Down
6 changes: 6 additions & 0 deletions charts/redpanda/templates/post-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.nodeSelector }}
nodeSelector: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations: {{- toYaml . | nindent 8 }}
{{- end }}
restartPolicy: Never
securityContext: {{ include "pod-security-context" . | nindent 8 }}
containers:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
{{/*
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 gt ( .Values.statefulset.replicas | int64 ) 2 }}
---
apiVersion: v1
Expand Down
8 changes: 4 additions & 4 deletions charts/redpanda/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,14 @@ spec:
whenUnsatisfiable: {{ .whenUnsatisfiable }}
{{- end }}
{{- end }}
{{- with .Values.statefulset.nodeSelector }}
nodeSelector: {{- toYaml . | nindent 8 }}
{{- with ( include "statefulset-nodeSelectors" . ) }}
nodeSelector: {{- . | nindent 8 }}
{{- end }}
{{- if .Values.statefulset.priorityClassName }}
priorityClassName: {{ .Values.statefulset.priorityClassName }}
{{- end }}
{{- with .Values.statefulset.tolerations }}
tolerations: {{- toYaml . | nindent 8 }}
{{- with ( include "statefulset-tolerations" . ) }}
tolerations: {{- . | nindent 8 }}
{{- end }}
{{- if or .Values.storage.persistentVolume.enabled (and (include "is-licensed" . | fromJson).bool .Values.storage.tieredConfig.cloud_storage_enabled .Values.storage.tieredStoragePersistentVolume.enabled) }}
volumeClaimTemplates:
Expand Down
18 changes: 18 additions & 0 deletions charts/redpanda/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
"image"
],
"properties": {
"nameOverride": {
"type": "string"
},
"fullnameOverride": {
"type": "string"
},
"clusterDomain": {
"type": "string"
},
"commonLabels": {
"type": "object"
},
"nodeSelector": {
"type": "object"
},
"tolerations": {
"type": "array"
},
"image": {
"description": "Values used to define the container image to be used for Redpanda",
"type": "object",
Expand Down
9 changes: 9 additions & 0 deletions charts/redpanda/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ clusterDomain: cluster.local
# Additional labels added to all Kubernetes objects
commonLabels: {}

# Node selection constraints for scheduling Pods, can override this for statefulsets.
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
nodeSelector: {}
# Taints to be tolerated by Pods, can override this for statefulsets.
# https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []

# Redpanda parameters
#
image:
Expand Down Expand Up @@ -484,12 +491,14 @@ statefulset:
# Does not apply for other anti-affinity types.
weight: 100
# Node selection constraints for scheduling Pods of this StatefulSet.
# these override the global nodeSelector value
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
nodeSelector: {}
# PriorityClassName given to Pods of this StatefulSet
# https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass
priorityClassName: ""
# Taints to be tolerated by Pods of this StatefulSet.
# these override the global tolerations value
# https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []
# https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
Expand Down

0 comments on commit 27b3a6a

Please sign in to comment.