# helm_charts_metrics-server-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "metrics-server.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ template "metrics-server.name" . }}
    chart: {{ template "metrics-server.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  selector:
    matchLabels:
      app: {{ template "metrics-server.name" . }}
      release: {{ .Release.Name }}
  replicas: {{ .Values.replicas }}
  template:
    metadata:
      labels:
        app: {{ template "metrics-server.name" . }}
        release: {{ .Release.Name }}
        {{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
        {{- end }}
      {{- with .Values.podAnnotations }}
      annotations:
      {{- range $key, $value := . }}
        {{ $key }}: {{ $value | quote }}
      {{- end }}
      {{- end }}
    spec:
    {{- if .Values.priorityClassName }}
      priorityClassName: "{{ .Values.priorityClassName }}"
    {{- end }}
    {{- if .Values.imagePullSecrets }}
      imagePullSecrets:
      {{- range .Values.imagePullSecrets }}
        - name: {{ . }}
      {{- end }}
    {{- end }}
      serviceAccountName: {{ template "metrics-server.serviceAccountName" . }}
{{- if .Values.hostNetwork.enabled }}
      hostNetwork: true
{{- end }}
      containers:
        {{- if .Values.extraContainers }}
        {{- ( tpl (toYaml .Values.extraContainers) . ) | nindent 8 }}
        {{- end }}
        - name: metrics-server
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          command:
            - /metrics-server
            - --cert-dir=/tmp
            - --logtostderr
            - --secure-port=8443
            {{- range .Values.args }}
            - {{ . }}
            {{- end }}
          ports:
          - containerPort: 8443
            name: https
          livenessProbe:
            {{- toYaml .Values.livenessProbe | trim | nindent 12 }}
          readinessProbe:
            {{- toYaml .Values.readinessProbe | trim | nindent 12 }}
          resources:
            {{- toYaml .Values.resources | trim | nindent 12 }}
          securityContext:
            {{- toYaml .Values.securityContext | trim | nindent 12 }}
          volumeMounts:
          - name: tmp
            mountPath: /tmp
          {{- with .Values.extraVolumeMounts }}
          {{- toYaml . | nindent 10 }}
          {{- end }}
      nodeSelector:
        {{- toYaml .Values.nodeSelector | trim | nindent 8 }}
      affinity:
        {{- toYaml .Values.affinity | trim | nindent 8 }}
      tolerations:
        {{- toYaml .Values.tolerations | trim | nindent 8 }}
      volumes:
      - name: tmp
        emptyDir: {}
      {{- with .Values.extraVolumes }}
      {{- toYaml . | nindent 6}}
      {{- end }}