{{- if $.Values.admintools.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "temporal.componentname" (list . "admintools") }}
  labels:
    app.kubernetes.io/name: {{ include "temporal.name" . }}
    helm.sh/chart: {{ include "temporal.chart" . }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
    app.kubernetes.io/component: admintools
    app.kubernetes.io/part-of: {{ .Chart.Name }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "temporal.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
      app.kubernetes.io/component: admintools
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "temporal.name" . }}
        helm.sh/chart: {{ include "temporal.chart" . }}
        app.kubernetes.io/managed-by: {{ .Release.Service }}
        app.kubernetes.io/instance: {{ .Release.Name }}
        app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
        app.kubernetes.io/component: admintools
        app.kubernetes.io/part-of: {{ .Chart.Name }}
    spec:
      {{ include "temporal.serviceAccount" . }}
      containers:
        - name: admin-tools
          image: "{{ .Values.admintools.image.repository }}:{{ .Values.admintools.image.tag }}"
          imagePullPolicy: {{ .Values.admintools.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 22
              protocol: TCP
          env:
            - name: TEMPORAL_CLI_ADDRESS
              value: {{ include "temporal.fullname" . }}-frontend:{{ include "temporal.frontend.grpcPort" . }}
          livenessProbe:
              exec:
                command:
                - ls
                - /
              initialDelaySeconds: 5
              periodSeconds: 5
      {{- with $.Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.admintools.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
    {{- with .Values.admintools.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.admintools.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
    {{- end }}
{{- end }}