{{- if and .Values.server.enabled -}} {{- if not .Values.server.extraArgs.rule }} {{- if and (eq .Values.server.configMap "") (eq (len .Values.server.config.alerts.groups) 0) -}} {{- fail "at least one item in `.server.config.alerts.groups` or `.server.extraArgs.rule` must be set " -}} {{- end -}} {{- end -}} {{- if (eq (include "vmalert.alertmanager.urls" . ) "") -}} {{- fail "alert manager URL must be specified. Please fill server.notifier.alertmanager.url or server.notifiers or enable Alertmanager in values file" -}} {{- end -}} {{- if eq .Values.server.datasource.url "" -}} {{- fail "server.datasource.url datasource URL must be specified" -}} {{- end -}} apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "vmalert.server.fullname" . }} namespace: {{ .Release.Namespace }} labels: {{- include "vmalert.server.labels" . | nindent 4 }} {{- with .Values.server.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: minReadySeconds: {{ .Values.server.minReadySeconds }} replicas: {{ .Values.server.replicaCount }} selector: matchLabels: {{- include "vmalert.server.matchLabels" . | nindent 6 }} {{- with .Values.server.strategy }} strategy: {{- toYaml . | nindent 4 }} {{- end }} template: metadata: labels: {{- include "vmalert.server.labels" . | nindent 8 }} {{- range $key, $value := .Values.server.podLabels }} {{ $key }}: {{ $value | quote }} {{- end }} annotations: checksum/config: {{ include (print $.Template.BasePath "/server-alerts-configmap.yaml") . | sha256sum }} {{- range $key, $value := .Values.server.podAnnotations }} {{ $key }}: {{ $value | quote }} {{- end }} spec: {{- if .Values.topologySpreadConstraints }} topologySpreadConstraints: {{ toYaml .Values.topologySpreadConstraints | indent 8 }} {{- end }} {{- with .Values.server.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ template "vmalert.serviceAccountName" . }} securityContext: {{- toYaml .Values.server.securityContext | nindent 8 }} automountServiceAccountToken: {{ .Values.serviceAccount.automountToken }} containers: - name: {{ template "vmalert.name" . }}-{{ .Values.server.name }} securityContext: {{- toYaml .Values.server.podSecurityContext | nindent 12 }} image: "{{ .Values.server.image.repository }}:{{ default .Chart.AppVersion .Values.server.image.tag }}" args: - -rule=/config/alert-rules.yaml - -datasource.url={{ .Values.server.datasource.url}} {{- if or .Values.server.datasource.basicAuth.password .Values.server.datasource.basicAuth.username }} - -datasource.basicAuth.password={{ .Values.server.datasource.basicAuth.password}} - -datasource.basicAuth.username={{ .Values.server.datasource.basicAuth.username}} {{- end }} {{- with .Values.server.datasource.bearer.token }} - -datasource.bearerToken={{ . }} {{- end }} {{- with .Values.server.datasource.bearer.tokenFile }} - -datasource.bearerTokenFile={{ . }} {{- end }} - -notifier.url={{ include "vmalert.alertmanager.urls" . }} {{- with (include "vmalert.alertmanager.passwords" .) }} - -notifier.basicAuth.password={{ . }} {{- end }} {{- with (include "vmalert.alertmanager.usernames" .) }} - -notifier.basicAuth.username={{ . }} {{- end }} {{- with (include "vmalert.alertmanager.bearerTokens" .) }} - -notifier.bearerToken={{ . }} {{- end }} {{- with (include "vmalert.alertmanager.bearerTokenFiles" .) }} - -notifier.bearerTokenFile={{ . }} {{- end }} - -remoteRead.url={{ .Values.server.remote.read.url }} {{- if or .Values.server.remote.read.basicAuth.password .Values.server.remote.read.basicAuth.username }} - -remoteRead.basicAuth.password={{ .Values.server.remote.read.basicAuth.password }} - -remoteRead.basicAuth.username={{ .Values.server.remote.read.basicAuth.username }} {{- end }} {{- with .Values.server.remote.read.bearer.token }} - -remoteRead.bearerToken={{ . }} {{- end }} {{- with .Values.server.remote.read.bearer.tokenFile }} - -remoteRead.bearerTokenFile={{ . }} {{- end }} - -remoteWrite.url={{ .Values.server.remote.write.url }} {{- if or .Values.server.remote.write.basicAuth.password .Values.server.remote.write.basicAuth.username }} - -remoteWrite.basicAuth.password={{ .Values.server.remote.write.basicAuth.password }} - -remoteWrite.basicAuth.username={{ .Values.server.remote.write.basicAuth.username }} {{- end }} {{- with .Values.server.remote.write.bearer.token }} - -remoteWrite.bearerToken={{ . }} {{- end }} {{- with .Values.server.remote.write.bearer.tokenFile }} - -remoteWrite.bearerTokenFile={{ . }} {{- end }} {{- range $key, $value := .Values.server.extraArgs }} {{- if eq $key "rule" }} - -{{ $key }}={{ $value | quote}} {{- else }} - -{{ $key }}={{ $value }} {{- end }} {{- end }} imagePullPolicy: {{ .Values.server.image.pullPolicy }} env: - name: TZ value: Asia/Kolkata {{- with .Values.server.env }} {{ toYaml . | nindent 12 }} {{- end }} ports: - name: http containerPort: 8880 readinessProbe: httpGet: {{- if index .Values.server.extraArgs "http.pathPrefix" }} path: {{ trimSuffix "/" (index .Values.server.extraArgs "http.pathPrefix") }}/health {{- else }} path: /health {{- end }} port: http initialDelaySeconds: 5 periodSeconds: 15 livenessProbe: tcpSocket: port: http initialDelaySeconds: 5 periodSeconds: 15 timeoutSeconds: 5 volumeMounts: - name: alerts-config mountPath: /config {{- if .Values.server.persistentVolume.enabled }} - name: alert-rules-pv mountPath: {{ .Values.server.persistentVolume.mountPath | default "/alert-rules" }} {{- with .Values.server.persistentVolume.subPath }} subPath: {{ . }} {{- end }} {{- end }} {{- range .Values.server.extraHostPathMounts }} - name: {{ .name }} mountPath: {{ .mountPath }} subPath: {{ .subPath }} readOnly: {{ .readOnly }} {{- end }} {{- with .Values.server.extraVolumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} resources: {{- toYaml .Values.server.resources | nindent 12 }} {{- with .Values.server.extraContainers }} {{- toYaml . | nindent 8 }} {{- end }} {{- if .Values.server.priorityClassName }} priorityClassName: {{ .Values.server.priorityClassName | quote }} {{- end }} {{- with .Values.server.affinity }} affinity: {{ toYaml . | nindent 8 }} {{- end }} {{- if .Values.schedulerName }} schedulerName: "{{ .Values.schedulerName }}" {{- end }} nodeSelector: {{- if .Values.dedicatedValue }} dedicated: {{ include "meesho.server.dedicatedValue" . }} {{- else }} {{- with .Values.server.nodeSelector }} {{ toYaml . | nindent 8 }} {{- end }} {{- end }} tolerations: {{- if .Values.dedicatedValue }} - key: "dedicated" operator: "Equal" value: {{ include "meesho.server.dedicatedValue" . }} effect: "NoSchedule" {{- else }} {{- with .Values.server.tolerations }} {{ toYaml . | nindent 8 }} {{- end }} {{- end }} volumes: - name: alerts-config configMap: name: {{ include "vmalert.server.configname" . }} {{- if .Values.server.persistentVolume.enabled }} - name: alert-rules-pv persistentVolumeClaim: claimName: {{ .Values.server.persistentVolume.existingClaim | default (.Values.server.persistentVolume.name | default (printf "%s-alert-rules-pvc" (include "vmalert.server.fullname" .))) }} {{- end }} {{- range .Values.server.extraHostPathMounts }} - name: {{ .name }} hostPath: path: {{ .hostPath }} {{- end }} {{- with .Values.server.extraVolumes }} {{- toYaml . | nindent 8 }} {{- end }} {{- end -}}