{{- include "perses.validateDatabaseConfig" . }} {{- if .Values.config.database.file }} apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "perses.fullname" . }} labels: {{- include "perses.labels" . | nindent 4 }} app.kubernetes.io/component: workload {{- with .Values.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: replicas: {{ .Values.replicas }} serviceName: {{ include "perses.fullname" . }}-headless selector: matchLabels: {{- include "perses.selectorLabels" . | nindent 6 }} template: metadata: labels: {{- include "perses.selectorLabels" . | nindent 8 }} annotations: {{- if .Values.datasources }} checksum/config: {{ include (print $.Template.BasePath "/datasources.yaml") . | sha256sum }} {{- else }} checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }} {{- end }} spec: serviceAccountName: {{ include "perses.serviceAccountName" . }} securityContext: {{- toYaml .Values.persistence.securityContext | nindent 8 }} containers: {{- if .Values.sidecar.enabled }} {{- $nsConfig := dict "customEnv" false }} {{- range .Values.sidecar.extraEnvVars }} {{- if eq .name "NAMESPACE" }} {{- $_ := set $nsConfig "customEnv" true }} {{- end }} {{- end }} {{- $hasCustomNamespaceEnv := $nsConfig.customEnv }} - name: {{ .Chart.Name }}-provisioning-sidecar image: "{{ .Values.sidecar.image.registry | default .Values.image.registry }}/{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}" {{- with .Values.sidecar.securityContext }} securityContext: {{- toYaml . | nindent 10 }} {{- end }} volumeMounts: - name: provisioning mountPath: {{ .Values.config.provisioning.folders | first }} env: - name: LABEL value: {{ .Values.sidecar.label }} - name: LABEL_VALUE value: {{ .Values.sidecar.labelValue | quote }} - name: FOLDER value: {{ .Values.config.provisioning.folders | first }} - name: HEALTH_PORT value: "{{ .Values.sidecar.healthPort }}" {{- if and (not $hasCustomNamespaceEnv) .Values.sidecar.allNamespaces }} - name: NAMESPACE value: ALL {{- end }} {{- if .Values.sidecar.enableSecretAccess}} - name: RESOURCE value: both {{- end }} {{- with .Values.sidecar.extraEnvVars -}} {{ toYaml . | nindent 10 }} {{- end }} {{- end }} - name: {{ .Chart.Name }} image: "{{ .Values.image.registry }}/{{ .Values.image.name }}:{{ .Values.image.version | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} args: - --config=/etc/perses/config/config.yaml - --web.listen-address=:{{ .Values.service.targetPort }} - --web.hide-port=false - --web.telemetry-path={{ .Values.config.api_prefix }}/metrics - --log.level={{ .Values.logLevel }} - --log.method-trace=true {{- range $key, $value := .Values.extraArgs }} {{- if $value }} - --{{ $key }}={{ tpl ($value | toString) $ }} {{- else }} - --{{ $key }} {{- end }} {{- end }} {{- $mergedEnvVars := include "perses.mergedEnvVars" . | fromYamlArray }} {{- if $mergedEnvVars }} env: {{- range $mergedEnvVars }} {{- if and (kindIs "map" .) (hasKey . "name") }} - name: {{ .name }} valueFrom: secretKeyRef: name: {{ include "perses.envVarsSecretName" $ }} key: {{ .name | kebabcase }} {{- end }} {{- end }} {{- end }} volumeMounts: {{- if .Values.volumeMounts }} {{- tpl (toYaml .Values.volumeMounts | nindent 10) . }} {{- end }} {{- if .Values.ociArtifacts }} - name: {{ .Values.ociArtifacts.name }} mountPath: {{ .Values.ociArtifacts.mountPath }} {{- if .Values.ociArtifacts.subPath }} subPath: {{ .Values.ociArtifacts.subPath }} {{- end }} {{- end }} - name: config mountPath: "/etc/perses/config" {{- if .Values.config.database.file }} - name: data mountPath: {{ .Values.config.database.file.folder }} {{- end }} {{- if .Values.datasources }} - name: datasources mountPath: /etc/perses/datasources {{- end }} {{- if or .Values.sidecar.enabled .Values.provisioningPersistence.enabled }} - name: provisioning mountPath: {{ .Values.config.provisioning.folders | first }} {{- end }} {{- if .Values.tls.enabled }} {{- if .Values.tls.caCert.enabled }} - name: ca-cert mountPath: {{ .Values.tls.caCert.mountPath }} readOnly: true {{- end }} {{- if .Values.tls.clientCert.enabled }} - name: client-cert mountPath: {{ .Values.tls.clientCert.mountPath }} readOnly: true {{- end }} {{- end }} ports: - name: http containerPort: {{ .Values.service.targetPort }} readinessProbe: httpGet: path: {{ .Values.config.api_prefix }}/api/v1/health port: http scheme: HTTP initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.readinessProbe.periodSeconds }} timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} successThreshold: {{ .Values.readinessProbe.successThreshold }} failureThreshold: {{ .Values.readinessProbe.failureThreshold }} livenessProbe: httpGet: path: {{ .Values.config.api_prefix }}/api/v1/health port: http scheme: HTTP initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.livenessProbe.periodSeconds }} timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} successThreshold: {{ .Values.livenessProbe.successThreshold }} failureThreshold: {{ .Values.livenessProbe.failureThreshold }} {{- with .Values.resources }} resources: {{- toYaml . | nindent 10 }} {{- end }} volumes: {{- if .Values.volumes }} {{- tpl (toYaml .Values.volumes | nindent 8) . }} {{- end }} {{- if .Values.ociArtifacts }} - name: {{ .Values.ociArtifacts.name }} image: reference: {{ .Values.ociArtifacts.image.reference }} {{- if .Values.ociArtifacts.image.pullPolicy }} pullPolicy: {{ .Values.ociArtifacts.image.pullPolicy }} {{- end }} {{- end }} {{- if .Values.config.database.file }} - name: data {{- if .Values.persistence.enabled }} persistentVolumeClaim: claimName: {{ include "perses.fullname" . }} {{- else }} emptyDir: {} {{- end }} {{- end }} - name: config configMap: defaultMode: 420 name: {{ include "perses.fullname" . }} {{- if .Values.datasources }} - name: datasources configMap: name: {{ include "perses.fullname" . }}-datasources {{- end }} {{- if and .Values.sidecar.enabled (not .Values.provisioningPersistence.enabled) }} - name: provisioning emptyDir: {} {{- end }} {{- if .Values.tls.enabled }} {{- if .Values.tls.caCert.enabled }} - name: ca-cert secret: secretName: {{ .Values.tls.caCert.secretName | default (printf "%s-tls" (include "perses.fullname" .)) }} defaultMode: 420 {{- end }} {{- if .Values.tls.clientCert.enabled }} - name: client-cert secret: secretName: {{ .Values.tls.clientCert.secretName | default (printf "%s-tls" (include "perses.fullname" .)) }} defaultMode: 420 {{- end }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- if or .Values.affinity .Values.podAntiAffinity }} affinity: {{- end }} {{- with .Values.affinity }} {{- toYaml . | nindent 8 }} {{- end }} {{- if eq .Values.podAntiAffinity "hard" }} podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - topologyKey: {{ .Values.podAntiAffinityTopologyKey }} labelSelector: matchExpressions: - {key: app.kubernetes.io/name, operator: In, values: [{{ template "perses.name" . }}]} {{- else if eq .Values.podAntiAffinity "soft" }} podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 podAffinityTerm: topologyKey: {{ .Values.podAntiAffinityTopologyKey }} labelSelector: matchExpressions: - {key: app.kubernetes.io/name, operator: In, values: [{{ template "perses.name" . }}]} {{- end }} {{- with .Values.topologySpreadConstraints }} topologySpreadConstraints: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} {{- if .Values.provisioningPersistence.enabled }} volumeClaimTemplates: - metadata: name: provisioning {{- with .Values.provisioningPersistence.labels }} labels: {{- toYaml . | nindent 10 }} {{- end }} {{- with .Values.provisioningPersistence.annotations }} annotations: {{- toYaml . | nindent 10 }} {{- end }} spec: accessModes: {{- range .Values.provisioningPersistence.accessModes }} - {{ . | quote }} {{- end }} resources: requests: storage: {{ .Values.provisioningPersistence.size | quote }} {{- if .Values.provisioningPersistence.storageClass }} storageClassName: {{ .Values.provisioningPersistence.storageClass | quote }} {{- end }} {{- end }} {{- end }}