Skip to content

Commit

Permalink
chore: cleanup dirty syntax
Browse files Browse the repository at this point in the history
- replace range with toYaml
- replace if with with
- use quote filter on password (it could contains an ' or ")
- remove strange tpl and trim
- use default filter
- nicer indent
- remove invalid checks (if something invalid, the chart install should failed)
  • Loading branch information
WrenIX committed Aug 11, 2023
1 parent c8aef6f commit c2dbf34
Show file tree
Hide file tree
Showing 22 changed files with 261 additions and 295 deletions.
13 changes: 0 additions & 13 deletions charts/prosody/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,7 @@ apiVersion: v2
name: prosody
description: Prosody XMPP server for Jitsi Meet on Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 1.3.6

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: stable-8719
6 changes: 1 addition & 5 deletions charts/prosody/templates/envs-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ metadata:
labels:
{{- include "prosody.labels" . | nindent 4 }}
data:
{{- range $key, $value := .Values.env }}
{{- if not (kindIs "invalid" $value) }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
{{- toYaml .Values.env | nindent 2 }}
8 changes: 2 additions & 6 deletions charts/prosody/templates/envs-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ metadata:
labels:
{{- include "prosody.labels" . | nindent 4 }}
type: Opaque
data:
{{- range $key, $value := .Values.secretEnvs }}
{{- if not (kindIs "invalid" $value) }}
{{ $key }}: {{ tpl $value $ | b64enc }}
{{- end }}
{{- end }}
stringData:
{{- toYaml .Values.secretEnvs | nindent 2 }}
114 changes: 56 additions & 58 deletions charts/prosody/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,40 @@ spec:
metadata:
labels:
{{- include "prosody.selectorLabels" . | nindent 8 }}
{{- range $label, $value := mergeOverwrite .Values.global.podLabels .Values.podLabels }}
{{ $label }}: {{ $value }}
{{- end }}
{{- with (mergeOverwrite .Values.global.podLabels .Values.podLabels) }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
hash-secret: "{{ toYaml .Values.secretEnvs | sha256sum | trunc 32 }}"
hash-configmap: "{{ toYaml .Values.env | sha256sum | trunc 32 }}"
{{- range $annotation, $value := mergeOverwrite .Values.global.podAnnotations .Values.podAnnotations }}
{{ $annotation }}: {{ $value }}
{{- end }}
{{- with (mergeOverwrite .Values.global.podAnnotations .Values.podAnnotations) }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "prosody.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ tpl (default .Chart.AppVersion .Values.image.tag ) . }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "prosody.fullname" . }}
- secretRef:
name: {{ include "prosody.fullname" . }}
{{- range .Values.extraEnvFrom }}
- {{ tpl (toYaml . ) $ | indent 12 | trim }}
{{- end }}
{{- if .Values.extraEnvs }}
- configMapRef:
name: {{ include "prosody.fullname" . }}
- secretRef:
name: {{ include "prosody.fullname" . }}
{{- with .Values.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraEnvs }}
env:
{{- range .Values.extraEnvs }}
- {{ tpl (toYaml . ) $ | indent 12 | trim }}
{{- end }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: xmpp-c2s
Expand All @@ -73,58 +71,58 @@ spec:
protocol: TCP
{{- with .Values.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: prosody-data
mountPath: {{ .Values.dataDir }}
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 10 }}
{{- end }}
- name: prosody-data
mountPath: {{ .Values.dataDir }}
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: prosody-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: prosody-data
{{- else }}
emptyDir: {}
- name: prosody-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: prosody-data
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.nodeSelector }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or .Values.persistence.enabled .Values.extraVolumeClaimTemplates }}
volumeClaimTemplates:
- metadata:
name: prosody-data
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- with .Values.persistence.storageClassName }}
storageClassName: {{ . | quote }}
{{- end }}
{{- with .Values.extraVolumeClaimTemplates }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- if or .Values.persistence.enabled .Values.extraVolumeClaimTemplates }}
volumeClaimTemplates:
- metadata:
name: prosody-data
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- with .Values.persistence.storageClassName }}
storageClassName: {{ . | quote }}
{{- end }}
{{- with .Values.extraVolumeClaimTemplates }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion charts/prosody/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# Declare variables to be passed into your templates.

image:
repository: nginx
repository: jitsi/prosody
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

imagePullSecrets: []
nameOverride: ""
Expand Down
14 changes: 6 additions & 8 deletions templates/common-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
labels:
{{- include "jitsi-meet.labels" . | nindent 4 }}
data:
ENABLE_AUTH: {{ ternary "1" "0" .Values.enableAuth | quote }}
ENABLE_GUESTS: {{ ternary "1" "0" .Values.enableGuests | quote }}
ENABLE_AUTH: {{ .Values.enableAuth | ternary "1" "0" | quote }}
ENABLE_GUESTS: {{ .Values.enableGuests | ternary "1" "0" | quote }}
PUBLIC_URL: {{ include "jitsi-meet.publicURL" . }}
XMPP_DOMAIN: {{ include "jitsi-meet.xmpp.domain" . }}
XMPP_MUC_DOMAIN: {{ .Values.xmpp.mucDomain | default (printf "muc.%s" (include "jitsi-meet.xmpp.domain" .)) }}
Expand All @@ -33,15 +33,13 @@ data:
ENABLE_LIVESTREAMING: "true"
{{- end }}
{{- end }}
TZ: '{{ .Values.tz }}'
{{- range $key, $value := .Values.extraCommonEnvs }}
{{- if not (kindIs "invalid" $value) }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
TZ: {{ .Values.tz | quote }}
{{- if .Values.octo.enabled }}
ENABLE_OCTO: "1"
TESTING_OCTO_PROBABILITY: "1"
DEPLOYMENTINFO_REGION: "all"
DEPLOYMENTINFO_USERREGION: "all"
{{- end }}
{{- with .Values.extraCommonEnvs }}
{{- toYaml . | nindent 2 }}
{{- end }}
6 changes: 2 additions & 4 deletions templates/jibri/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ data:
JIBRI_STRIP_DOMAIN_JID: muc
DISPLAY: ":0"
JIBRI_SINGLE_USE_MODE: {{ .Values.jibri.singleUseMode | default false | quote }}
{{- range $key, $value := .Values.jibri.extraEnvs }}
{{- if not (kindIs "invalid" $value) }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- with .Values.jibri.extraEnvs }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
76 changes: 38 additions & 38 deletions templates/jibri/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ spec:
metadata:
labels:
{{- include "jitsi-meet.jibri.selectorLabels" . | nindent 8 }}
{{- range $label, $value := mergeOverwrite .Values.global.podLabels .Values.jibri.podLabels }}
{{ $label }}: {{ $value }}
{{- end }}
{{- with (mergeOverwrite .Values.global.podLabels .Values.jibri.podLabels) }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/jibri/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/jibri/xmpp-secret.yaml") . | sha256sum }}
{{- range $annotation, $value := mergeOverwrite .Values.global.podAnnotations .Values.jibri.podAnnotations }}
{{ $annotation }}: {{ $value|quote }}
{{- end }}
{{- with (mergeOverwrite .Values.global.podAnnotations .Values.jibri.podAnnotations) }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "jitsi-meet.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
Expand All @@ -50,20 +50,20 @@ spec:
containerPort: 2222
{{- with default .Values.jibri.livenessProbe .Values.jibri.livenessProbeOverride }}
livenessProbe:
{{- toYaml . | nindent 10 }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with default .Values.jibri.readinessProbe .Values.jibri.readinessProbeOverride }}
readinessProbe:
{{- toYaml . | nindent 10 }}
{{- toYaml . | nindent 10 }}
{{- end }}

envFrom:
- secretRef:
name: {{ include "call-nested" (list . "prosody" "prosody.fullname") }}-jibri
- configMapRef:
name: {{ include "call-nested" (list . "prosody" "prosody.fullname") }}-common
- configMapRef:
name: {{ include "jitsi-meet.jibri.fullname" . }}
- secretRef:
name: {{ include "call-nested" (list . "prosody" "prosody.fullname") }}-jibri
- configMapRef:
name: {{ include "call-nested" (list . "prosody" "prosody.fullname") }}-common
- configMapRef:
name: {{ include "jitsi-meet.jibri.fullname" . }}

{{- if (gt (int .Values.jibri.replicaCount) 1) }}
# Set Jibri Instance ID based on pod name:
Expand All @@ -78,30 +78,30 @@ spec:
{{- toYaml .Values.jibri.resources | nindent 12 }}

volumeMounts:
- name: jibri-data
mountPath: /data
{{- if .Values.jibri.shm.enabled }}
- name: dev-shm
mountPath: /dev/shm
{{- end }}

volumes:
- name: jibri-data
mountPath: /data
{{- if .Values.jibri.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.jibri.persistence.existingClaim | default (include "jitsi-meet.jibri.fullname" .) }}
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.jibri.shm.enabled }}
- name: dev-shm
mountPath: /dev/shm
{{- end }}

volumes:
- name: jibri-data
{{- if .Values.jibri.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.jibri.persistence.existingClaim | default (include "jitsi-meet.jibri.fullname" .) }}
{{- else }}
emptyDir: {}
{{- if .Values.jibri.shm.useHost }}
hostPath:
path: /dev/shm
{{- else }}
emptyDir:
medium: Memory
sizeLimit: {{ .Values.jibri.shm.size | default "256Mi" | quote }}
{{- end }}
{{- end }}
{{- if .Values.jibri.shm.enabled }}
- name: dev-shm
{{- if .Values.jibri.shm.useHost }}
hostPath:
path: /dev/shm
{{- else }}
emptyDir:
medium: Memory
sizeLimit: {{ .Values.jibri.shm.size | default "256Mi" | quote }}
{{- end }}
{{- end }}
{{- end }}
10 changes: 5 additions & 5 deletions templates/jibri/xmpp-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ metadata:
labels:
{{- include "jitsi-meet.jibri.labels" . | nindent 4 }}
type: Opaque
data:
JIBRI_XMPP_USER: '{{ .Values.jibri.xmpp.user | b64enc }}'
JIBRI_XMPP_PASSWORD: '{{ default (randAlphaNum 10) .Values.jibri.xmpp.password | b64enc }}'
JIBRI_RECORDER_USER: '{{ .Values.jibri.recorder.user | b64enc }}'
JIBRI_RECORDER_PASSWORD: '{{ default (randAlphaNum 10) .Values.jibri.recorder.password | b64enc }}'
stringData:
JIBRI_XMPP_USER: {{ .Values.jibri.xmpp.user | quote }}
JIBRI_XMPP_PASSWORD: {{ .Values.jibri.xmpp.password | default (randAlphaNum 10) | quote }}
JIBRI_RECORDER_USER: {{ .Values.jibri.recorder.user | quote }}'
JIBRI_RECORDER_PASSWORD: {{ .Values.jibri.recorder.password | default (randAlphaNum 10) | quote }}
{{- end }}
10 changes: 4 additions & 6 deletions templates/jicofo/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ data:
JIBRI_BREWERY_MUC: '{{ .Values.jibri.breweryMuc }}'
JIBRI_PENDING_TIMEOUT: '{{ .Values.jibri.timeout }}'
{{- end }}
{{- range $key, $value := .Values.jicofo.extraEnvs }}
{{- if not (kindIs "invalid" $value) }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
{{- if .Values.octo.enabled }}
ENABLE_OCTO: "1"
OCTO_BRIDGE_SELECTION_STRATEGY: "SplitBridgeSelectionStrategy"
{{- end }}
{{- end }}
{{- with .Values.jicofo.extraEnvs }}
{{- toYaml . | nindent 2 }}
{{- end }}
Loading

0 comments on commit c2dbf34

Please sign in to comment.