Skip to content

Commit

Permalink
Merge pull request #95 from LaloLoop/add-tolerations-support
Browse files Browse the repository at this point in the history
Add support for tolerations in all deployments and pods
  • Loading branch information
debdutdeb authored May 8, 2024
2 parents 0070264 + 7bef5fa commit c494c79
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 0 deletions.
18 changes: 18 additions & 0 deletions rocketchat/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,21 @@ Usage:
{{- printf "mongodb://%s:%s@%s:%0.f/local?replicaSet=%s&authSource=admin" $user $password $service $port $rs }}
{{- end }}
{{- end }}

{{/* Get correct tolerations */}}
{{- define "rocketchat.tolerations" -}}
{{- $name := .name -}}
{{- $tolerations := list -}}
{{- with .context }}
{{- if eq $name "meteor" }}
{{ $tolerations = .Values.tolerations }}
{{- else }}
{{ $tolerations = get (get .Values.microservices $name) "tolerations" }}
{{- end }}
{{- if (and (kindIs "slice" $tolerations) (gt (len $tolerations) 0)) }}
{{- toYaml $tolerations }}
{{- else }}
{{- toYaml .Values.global.tolerations }}
{{- end }}
{{- end }}
{{- end -}}
2 changes: 2 additions & 0 deletions rocketchat/templates/chat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ spec:
{{- if .Values.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 6 }}
{{- end }}
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "meteor" "context" $) | indent 8 }}
{{- if or .Values.podAntiAffinity .Values.affinity }}
affinity:
{{- if .Values.affinity }}
Expand Down
5 changes: 5 additions & 0 deletions rocketchat/templates/hook-verify-mongodb-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ spec:
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
restartPolicy: OnFailure
{{- if $.Values.tolerations }}
tolerations:
{{ toYaml $.Values.tolerations | indent 8 }}
{{- end }}

containers:
- name: '{{ include "rocketchat.fullname" . }}-pre-upgrade'
{{- $registry := .Values.mongodb.image.registry }}
Expand Down
2 changes: 2 additions & 0 deletions rocketchat/templates/microservices-account-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ spec:
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "account" "context" $) | indent 8 }}
containers:
- name: account-service
image: "{{ .Values.microservices.account.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spec:
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "authorization" "context" $) | indent 8 }}
containers:
- name: authorization-service
image: "{{ .Values.microservices.authorization.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ spec:
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "ddpStreamer" "context" $) | indent 8 }}
containers:
- name: ddp-streamer
image: "{{ .Values.microservices.ddpStreamer.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand Down
2 changes: 2 additions & 0 deletions rocketchat/templates/microservices-presence-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spec:
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "presence" "context" $) | indent 8 }}
containers:
- name: presence-service
image: "{{ .Values.microservices.presence.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand Down
2 changes: 2 additions & 0 deletions rocketchat/templates/microservices-stream-hub-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spec:
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
spec:
tolerations:
{{ include "rocketchat.tolerations" (dict "name" "streamHub" "context" $) | indent 8 }}
containers:
- name: stream-hub
image: "{{ .Values.microservices.streamHub.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand Down
30 changes: 30 additions & 0 deletions rocketchat/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## common configuration across all deployments
global:
# Tolerations for pod assignment
# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []

## Rocket Chat image version
## ref: https://hub.docker.com/r/rocketchat/rocket.chat/tags
##
Expand Down Expand Up @@ -297,34 +303,54 @@ microservices:
pullPolicy: IfNotPresent
securityContext: {}
resources: {}
# Tolerations for pod assignment
# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []

ddpStreamer:
replicas: 1
image:
repository: rocketchat/ddp-streamer-service
pullPolicy: IfNotPresent
securityContext: {}
resources: {}
# Tolerations for pod assignment
# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []

account:
replicas: 1
image:
repository: rocketchat/account-service
pullPolicy: IfNotPresent
securityContext: {}
resources: {}
# Tolerations for pod assignment
# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []

authorization:
replicas: 1
image:
repository: rocketchat/authorization-service
pullPolicy: IfNotPresent
securityContext: {}
resources: {}
# Tolerations for pod assignment
# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []

streamHub:
replicas: 1
image:
repository: rocketchat/stream-hub-service
pullPolicy: IfNotPresent
securityContext: {}
resources: {}
# Tolerations for pod assignment
# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []

nats:
replicas: 1

Expand Down Expand Up @@ -366,3 +392,7 @@ postgresql:
extraEnvVars:
- name: POSTGRES_INITDB_ARGS
value: "--lc-collate=C --lc-ctype=C"

# Tolerations for pod assignment
# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []

0 comments on commit c494c79

Please sign in to comment.