apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "xxl-job-admin.fullname" . }}
  labels:
    {{- include "xxl-job-admin.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
{{- end }}
  selector:
    matchLabels:
      {{- include "xxl-job-admin.selectorLabels" . | nindent 6 }}
  template:
    metadata:
    {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      labels:
        {{- include "xxl-job-admin.labels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "xxl-job-admin.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env:
          - name: TZ
            value: Asia/Shanghai
          - name: JAVA_OPTS
            value: -Xms256m -Xmx2000m  -XX:PermSize=512m -XX:MaxPermSize=1024m
          ports:
            - containerPort: 9999
            - containerPort: 8080
          env:
            - name: PARAMS
              value: {{ .Values.PARAMS_VALUE | default "--spring.datasource.url=jdbc:mysql://mysql:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai --spring.datasource.username=root --spring.datasource.password=mysql" }}
          {{- if not .Values.healthChk.enabled }}
          {{- with .Values.healthChk.content }}
          {{- toYaml . | nindent 10 }}
          {{- end }}
          {{- end }}
        
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      
