# helm_charts_lego-deployment.yaml
{{- if .Values.lego.enabled }}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ template "nginx-lego.fullname" . }}-lego
spec:
  replicas: {{ .Values.lego.replicaCount }}
  template:
    metadata:
      labels:
        app: kube-lego
    spec:
      containers:
      - name: {{ .Chart.Name }}-lego
        image: "{{ .Values.lego.image.repository }}:{{ .Values.lego.image.tag }}"
        imagePullPolicy: {{ .Values.lego.image.pullPolicy }}
        ports:
        - containerPort: 8080
        env:
        - name: LEGO_EMAIL
          valueFrom:
            configMapKeyRef:
              name: {{ template "nginx-lego.fullname" . }}-lego
              key: lego.email
        - name: LEGO_URL
          valueFrom:
            configMapKeyRef:
              name: {{ template "nginx-lego.fullname" . }}-lego
              key: lego.url
        - name: LEGO_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: LEGO_POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        resources:
{{ toYaml .Values.nginx.resources | indent 10 }}
{{- end }}