# grafana_charts_deployment-querier.yaml
{{ $dict := dict "ctx" . "component" "querier" "memberlist" true }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "tempo.resourceName" $dict }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "tempo.labels" $dict | nindent 4 }}
  {{- with .Values.querier.annotations }}
  annotations:
  {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  minReadySeconds: {{ .Values.querier.minReadySeconds }}
{{- if not .Values.querier.autoscaling.enabled }}
  replicas: {{ .Values.querier.replicas }}
{{- end }}
  revisionHistoryLimit: {{ .Values.tempo.revisionHistoryLimit }}
  selector:
    matchLabels:
      {{- include "tempo.selectorLabels" $dict | nindent 6 }}
  strategy:
    rollingUpdate:
      maxSurge: {{ .Values.querier.maxSurge }}
      maxUnavailable: {{ .Values.querier.rollingUpdate.maxUnavailable }}
  template:
    metadata:
      labels:
        {{- include "tempo.podLabels" $dict | nindent 8 }}
        {{- with .Values.tempo.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
        {{- with .Values.querier.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/configmap-tempo.yaml") . | sha256sum }}
        {{- with .Values.tempo.podAnnotations }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
        {{- with .Values.querier.podAnnotations }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
    spec:
      {{- if or (.Values.querier.priorityClassName) (.Values.global.priorityClassName) }}
      priorityClassName: {{ default .Values.querier.priorityClassName .Values.global.priorityClassName }}
      {{- end }}
      serviceAccountName: {{ include "tempo.serviceAccountName" . }}
      {{- with .Values.tempo.podSecurityContext }}
      securityContext:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      enableServiceLinks: false
      {{- include "tempo.querierImagePullSecrets" . | nindent 6 -}}
      {{- with .Values.querier.hostAliases }}
      hostAliases:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      initContainers:
        {{- toYaml .Values.querier.initContainers | nindent 8 }}
      containers:
        - args:
            - -target=querier
            - -config.file=/conf/tempo.yaml
            {{- with .Values.querier.extraArgs }}
            {{- toYaml . | nindent 12 }}
            {{- end }}
            {{- with .Values.global.extraArgs }}
            {{- toYaml . | nindent 12 }}
            {{- end }}
          image: {{ include "tempo.imageReference" $dict }}
          imagePullPolicy: {{ .Values.tempo.image.pullPolicy }}
          name: querier
          ports:
            - containerPort: {{ include "tempo.memberlistBindPort" . }}
              name: http-memberlist
              protocol: TCP
            - containerPort: 3200
              name: http-metrics
          {{- if or .Values.global.extraEnv .Values.querier.extraEnv }}
          env:
            {{- with .Values.global.extraEnv }}
              {{- toYaml . | nindent 12 }}
            {{- end }}
            {{- with .Values.querier.extraEnv }}
              {{- toYaml . | nindent 12 }}
            {{- end }}
          {{- end }}
          {{- if or .Values.global.extraEnvFrom .Values.querier.extraEnvFrom }}
          envFrom:
            {{- with .Values.global.extraEnvFrom }}
              {{- toYaml . | nindent 12 }}
            {{- end }}
            {{- with .Values.querier.extraEnvFrom }}
              {{- toYaml . | nindent 12 }}
            {{- end }}
          {{- end }}
          resources:
            {{- toYaml .Values.querier.resources | nindent 12 }}
          {{- with .Values.tempo.securityContext }}
          securityContext:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          {{- with .Values.tempo.livenessProbe }}
          livenessProbe:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          {{- with .Values.tempo.readinessProbe }}
          readinessProbe:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          volumeMounts:
            - mountPath: /conf
              name: config
            - mountPath: /runtime-config
              name: runtime-config
            - mountPath: /var/tempo
              name: tempo-querier-store
            {{- if .Values.enterprise.enabled }}
            - name: license
              mountPath: /license
            {{- end }}
            {{- with .Values.querier.extraVolumeMounts }}
            {{- toYaml . | nindent 12 }}
            {{- end }}
      terminationGracePeriodSeconds: {{ .Values.querier.terminationGracePeriodSeconds }}
      {{- if semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version }}
      {{- with .Values.querier.topologySpreadConstraints }}
      topologySpreadConstraints:
        {{- tpl . $ | nindent 8 }}
      {{- end }}
      {{- end }}
      {{- with .Values.querier.affinity }}
      affinity:
        {{- tpl . $ | nindent 8 }}
      {{- end }}
      {{- with .Values.querier.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.querier.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      volumes:
        - name: config
          {{- include "tempo.configVolume" . | nindent 10 }}
        - name: runtime-config
          {{- include "tempo.runtimeVolume" . | nindent 10 }}
        - name: tempo-querier-store
          emptyDir: {}
        {{- if .Values.enterprise.enabled }}
        - name: license
          secret:
            secretName: {{ tpl .Values.license.secretName . }}
        {{- end }}
        {{- with .Values.querier.extraVolumes }}
        {{- toYaml . | nindent 8 }}
        {{- end }}