123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- {{- if .Values.server.statefulSet.enabled -}}
- apiVersion: apps/v1
- kind: StatefulSet
- metadata:
- {{- if .Values.server.statefulSet.annotations }}
- annotations:
- {{ toYaml .Values.server.statefulSet.annotations | nindent 4 }}
- {{- end }}
- labels:
- {{- include "prometheus.server.labels" . | nindent 4 }}
- {{- if .Values.server.statefulSet.labels}}
- {{ toYaml .Values.server.statefulSet.labels | nindent 4 }}
- {{- end}}
- name: {{ template "prometheus.server.fullname" . }}
- {{ include "prometheus.namespace" . | indent 2 }}
- spec:
- serviceName: {{ template "prometheus.server.fullname" . }}-headless
- selector:
- matchLabels:
- {{- include "prometheus.server.matchLabels" . | nindent 6 }}
- replicas: {{ .Values.server.replicaCount }}
- podManagementPolicy: {{ .Values.server.statefulSet.podManagementPolicy }}
- template:
- metadata:
- {{- if .Values.server.podAnnotations }}
- annotations:
- {{ toYaml .Values.server.podAnnotations | nindent 8 }}
- {{- end }}
- labels:
- {{- include "prometheus.server.labels" . | nindent 8 }}
- {{- if .Values.server.podLabels}}
- {{ toYaml .Values.server.podLabels | nindent 8 }}
- {{- end}}
- spec:
- {{- if .Values.server.priorityClassName }}
- priorityClassName: "{{ .Values.server.priorityClassName }}"
- {{- end }}
- {{- if .Values.server.schedulerName }}
- schedulerName: "{{ .Values.server.schedulerName }}"
- {{- end }}
- {{- if semverCompare ">=1.13-0" .Capabilities.KubeVersion.GitVersion }}
- {{- if or (.Values.server.enableServiceLinks) (eq (.Values.server.enableServiceLinks | toString) "<nil>") }}
- enableServiceLinks: true
- {{- else }}
- enableServiceLinks: false
- {{- end }}
- {{- end }}
- serviceAccountName: {{ template "prometheus.serviceAccountName.server" . }}
- {{- if .Values.server.extraInitContainers }}
- initContainers:
- {{ toYaml .Values.server.extraInitContainers | indent 8 }}
- {{- end }}
- containers:
- {{- if .Values.configmapReload.prometheus.enabled }}
- - name: {{ template "prometheus.name" . }}-{{ .Values.server.name }}-{{ .Values.configmapReload.prometheus.name }}
- {{- if .Values.configmapReload.prometheus.image.digest }}
- image: "{{ .Values.configmapReload.prometheus.image.repository }}@{{ .Values.configmapReload.prometheus.image.digest }}"
- {{- else }}
- image: "{{ .Values.configmapReload.prometheus.image.repository }}:{{ .Values.configmapReload.prometheus.image.tag }}"
- {{- end }}
- imagePullPolicy: "{{ .Values.configmapReload.prometheus.image.pullPolicy }}"
- {{- with .Values.configmapReload.prometheus.containerSecurityContext }}
- securityContext:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- args:
- - --watched-dir=/etc/config
- - --reload-url=http://127.0.0.1:9090{{ .Values.server.prefixURL }}/-/reload
- {{- range $key, $value := .Values.configmapReload.prometheus.extraArgs }}
- - --{{ $key }}={{ $value }}
- {{- end }}
- {{- range .Values.configmapReload.prometheus.extraVolumeDirs }}
- - --watched-dir={{ . }}
- {{- end }}
- {{- if .Values.configmapReload.prometheus.containerPort }}
- ports:
- - containerPort: {{ .Values.configmapReload.prometheus.containerPort }}
- {{- end }}
- resources:
- {{ toYaml .Values.configmapReload.prometheus.resources | indent 12 }}
- volumeMounts:
- - name: config-volume
- mountPath: /etc/config
- readOnly: true
- {{- range .Values.configmapReload.prometheus.extraConfigmapMounts }}
- - name: {{ $.Values.configmapReload.prometheus.name }}-{{ .name }}
- mountPath: {{ .mountPath }}
- subPath: {{ .subPath }}
- readOnly: {{ .readOnly }}
- {{- end }}
- {{- end }}
- - name: {{ template "prometheus.name" . }}-{{ .Values.server.name }}
- {{- if .Values.server.image.digest }}
- image: "{{ .Values.server.image.repository }}@{{ .Values.server.image.digest }}"
- {{- else }}
- image: "{{ .Values.server.image.repository }}:{{ .Values.server.image.tag | default .Chart.AppVersion }}"
- {{- end }}
- imagePullPolicy: "{{ .Values.server.image.pullPolicy }}"
- {{- if .Values.server.env }}
- env:
- {{ toYaml .Values.server.env | indent 12}}
- {{- end }}
- args:
- {{- if .Values.server.defaultFlagsOverride }}
- {{ toYaml .Values.server.defaultFlagsOverride | nindent 12}}
- {{- else }}
- {{- if .Values.server.prefixURL }}
- - --web.route-prefix={{ .Values.server.prefixURL }}
- {{- end }}
- {{- if .Values.server.retention }}
- - --storage.tsdb.retention.time={{ .Values.server.retention }}
- {{- end }}
- - --config.file={{ .Values.server.configPath }}
- {{- if .Values.server.storagePath }}
- - --storage.tsdb.path={{ .Values.server.storagePath }}
- {{- else }}
- - --storage.tsdb.path={{ .Values.server.persistentVolume.mountPath }}
- {{- end }}
- - --web.console.libraries=/etc/prometheus/console_libraries
- - --web.console.templates=/etc/prometheus/consoles
- {{- range .Values.server.extraFlags }}
- - --{{ . }}
- {{- end }}
- {{- range $key, $value := .Values.server.extraArgs }}
- - --{{ $key }}={{ $value }}
- {{- end }}
- {{- if .Values.server.baseURL }}
- - --web.external-url={{ .Values.server.baseURL }}
- {{- end }}
- {{- end }}
- ports:
- - containerPort: 9090
- {{- if .Values.server.hostPort }}
- hostPort: {{ .Values.server.hostPort }}
- {{- end }}
- readinessProbe:
- {{- if not .Values.server.tcpSocketProbeEnabled }}
- httpGet:
- path: {{ .Values.server.prefixURL }}/-/ready
- port: 9090
- scheme: {{ .Values.server.probeScheme }}
- {{- with .Values.server.probeHeaders }}
- httpHeaders:
- {{- toYaml . | nindent 14 }}
- {{- end }}
- {{- else }}
- tcpSocket:
- port: 9090
- {{- end }}
- initialDelaySeconds: {{ .Values.server.readinessProbeInitialDelay }}
- periodSeconds: {{ .Values.server.readinessProbePeriodSeconds }}
- timeoutSeconds: {{ .Values.server.readinessProbeTimeout }}
- failureThreshold: {{ .Values.server.readinessProbeFailureThreshold }}
- successThreshold: {{ .Values.server.readinessProbeSuccessThreshold }}
- livenessProbe:
- {{- if not .Values.server.tcpSocketProbeEnabled }}
- httpGet:
- path: {{ .Values.server.prefixURL }}/-/healthy
- port: 9090
- scheme: {{ .Values.server.probeScheme }}
- {{- with .Values.server.probeHeaders }}
- httpHeaders:
- {{- toYaml . | nindent 14 }}
- {{- end }}
- {{- else }}
- tcpSocket:
- port: 9090
- {{- end }}
- initialDelaySeconds: {{ .Values.server.livenessProbeInitialDelay }}
- periodSeconds: {{ .Values.server.livenessProbePeriodSeconds }}
- timeoutSeconds: {{ .Values.server.livenessProbeTimeout }}
- failureThreshold: {{ .Values.server.livenessProbeFailureThreshold }}
- successThreshold: {{ .Values.server.livenessProbeSuccessThreshold }}
- {{- if .Values.server.startupProbe.enabled }}
- startupProbe:
- {{- if not .Values.server.tcpSocketProbeEnabled }}
- httpGet:
- path: {{ .Values.server.prefixURL }}/-/healthy
- port: 9090
- scheme: {{ .Values.server.probeScheme }}
- {{- if .Values.server.probeHeaders }}
- httpHeaders:
- {{- range .Values.server.probeHeaders}}
- - name: {{ .name }}
- value: {{ .value }}
- {{- end }}
- {{- end }}
- {{- else }}
- tcpSocket:
- port: 9090
- {{- end }}
- failureThreshold: {{ .Values.server.startupProbe.failureThreshold }}
- periodSeconds: {{ .Values.server.startupProbe.periodSeconds }}
- timeoutSeconds: {{ .Values.server.startupProbe.timeoutSeconds }}
- {{- end }}
- resources:
- {{ toYaml .Values.server.resources | indent 12 }}
- volumeMounts:
- - name: config-volume
- mountPath: /etc/config
- - name: storage-volume
- mountPath: {{ .Values.server.persistentVolume.mountPath }}
- subPath: "{{ .Values.server.persistentVolume.subPath }}"
- {{- range .Values.server.extraHostPathMounts }}
- - name: {{ .name }}
- mountPath: {{ .mountPath }}
- subPath: {{ .subPath }}
- readOnly: {{ .readOnly }}
- {{- end }}
- {{- range .Values.server.extraConfigmapMounts }}
- - name: {{ $.Values.server.name }}-{{ .name }}
- mountPath: {{ .mountPath }}
- subPath: {{ .subPath }}
- readOnly: {{ .readOnly }}
- {{- end }}
- {{- range .Values.server.extraSecretMounts }}
- - name: {{ .name }}
- mountPath: {{ .mountPath }}
- subPath: {{ .subPath }}
- readOnly: {{ .readOnly }}
- {{- end }}
- {{- if .Values.server.extraVolumeMounts }}
- {{ toYaml .Values.server.extraVolumeMounts | nindent 12 }}
- {{- end }}
- {{- with .Values.server.containerSecurityContext }}
- securityContext:
- {{- toYaml . | nindent 12 }}
- {{- end }}
- {{- if .Values.server.sidecarContainers }}
- {{- range $name, $spec := .Values.server.sidecarContainers }}
- - name: {{ $name }}
- {{- if kindIs "string" $spec }}
- {{- tpl $spec $ | nindent 10 }}
- {{- else }}
- {{- toYaml $spec | nindent 10 }}
- {{- end }}
- {{- end }}
- {{- end }}
- hostNetwork: {{ .Values.server.hostNetwork }}
- {{- if .Values.server.dnsPolicy }}
- dnsPolicy: {{ .Values.server.dnsPolicy }}
- {{- end }}
- {{- if .Values.imagePullSecrets }}
- imagePullSecrets:
- {{ toYaml .Values.imagePullSecrets | indent 8 }}
- {{- end }}
- {{- if .Values.server.nodeSelector }}
- nodeSelector:
- {{ toYaml .Values.server.nodeSelector | indent 8 }}
- {{- end }}
- {{- if .Values.server.hostAliases }}
- hostAliases:
- {{ toYaml .Values.server.hostAliases | indent 8 }}
- {{- end }}
- {{- if .Values.server.dnsConfig }}
- dnsConfig:
- {{ toYaml .Values.server.dnsConfig | indent 8 }}
- {{- end }}
- {{- with .Values.server.securityContext }}
- securityContext:
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- if .Values.server.tolerations }}
- tolerations:
- {{ toYaml .Values.server.tolerations | indent 8 }}
- {{- end }}
- {{- if .Values.server.affinity }}
- affinity:
- {{ toYaml .Values.server.affinity | indent 8 }}
- {{- end }}
- terminationGracePeriodSeconds: {{ .Values.server.terminationGracePeriodSeconds }}
- volumes:
- - name: config-volume
- {{- if empty .Values.server.configFromSecret }}
- configMap:
- name: {{ if .Values.server.configMapOverrideName }}{{ .Release.Name }}-{{ .Values.server.configMapOverrideName }}{{- else }}{{ template "prometheus.server.fullname" . }}{{- end }}
- {{- else }}
- secret:
- secretName: {{ .Values.server.configFromSecret }}
- {{- end }}
- {{- range .Values.server.extraHostPathMounts }}
- - name: {{ .name }}
- hostPath:
- path: {{ .hostPath }}
- {{- end }}
- {{- range .Values.configmapReload.prometheus.extraConfigmapMounts }}
- - name: {{ $.Values.configmapReload.prometheus.name }}-{{ .name }}
- configMap:
- name: {{ .configMap }}
- {{- end }}
- {{- range .Values.server.extraConfigmapMounts }}
- - name: {{ $.Values.server.name }}-{{ .name }}
- configMap:
- name: {{ .configMap }}
- {{- end }}
- {{- range .Values.server.extraSecretMounts }}
- - name: {{ .name }}
- secret:
- secretName: {{ .secretName }}
- {{- with .optional }}
- optional: {{ . }}
- {{- end }}
- {{- end }}
- {{- range .Values.configmapReload.prometheus.extraConfigmapMounts }}
- - name: {{ .name }}
- configMap:
- name: {{ .configMap }}
- {{- with .optional }}
- optional: {{ . }}
- {{- end }}
- {{- end }}
- {{- if .Values.server.extraVolumes }}
- {{ toYaml .Values.server.extraVolumes | indent 8}}
- {{- end }}
- {{- if .Values.server.persistentVolume.enabled }}
- volumeClaimTemplates:
- - metadata:
- name: storage-volume
- {{- if .Values.server.persistentVolume.annotations }}
- annotations:
- {{ toYaml .Values.server.persistentVolume.annotations | indent 10 }}
- {{- end }}
- {{- if .Values.server.persistentVolume.labels }}
- labels:
- {{ toYaml .Values.server.persistentVolume.labels | indent 10 }}
- {{- end }}
- spec:
- accessModes:
- {{ toYaml .Values.server.persistentVolume.accessModes | indent 10 }}
- resources:
- requests:
- storage: "{{ .Values.server.persistentVolume.size }}"
- {{- if .Values.server.persistentVolume.storageClass }}
- {{- if (eq "-" .Values.server.persistentVolume.storageClass) }}
- storageClassName: ""
- {{- else }}
- storageClassName: "{{ .Values.server.persistentVolume.storageClass }}"
- {{- end }}
- {{- end }}
- {{- else }}
- - name: storage-volume
- emptyDir:
- {{- if .Values.server.emptyDir.sizeLimit }}
- sizeLimit: {{ .Values.server.emptyDir.sizeLimit }}
- {{- else }}
- {}
- {{- end -}}
- {{- end }}
- {{- end }}
|