# uncomment the config map below
# if configuring caddy with a config map
# ensure that you update ./configmap.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: caddy-ingress-controller
  namespace: caddy-system
  labels:
    app: caddy-ingress-controller
    chart: "caddy-ingress-controller-v0.1.0"
    release: "release-name"
    heritage: "Tiller"
    version: v0.1.0

spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: caddy-ingress-controller
      release: "release-name"
  template:
    metadata:
      labels:
        app: caddy-ingress-controller
        chart: "caddy-ingress-controller-v0.1.2"
        release: "release-name"
        heritage: "Tiller"
        version: v0.1.0

    spec:
      serviceAccountName: caddy-ingress-controller
      volumes:
      - name: tmp
        emptyDir: {}
      # - name: config-volume
      #   configMap:
      #     name: caddy-config
      containers:
      - name: caddy-ingress-controller
        image: docker.io/MYACCOUNT/caddy-ingress-controller
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: tmp
          mountPath: /tmp
        # - name: config-volume
        #   mountPath: /etc/caddy/config.json
        #   subPath: config.json
        securityContext:
          allowPrivilegeEscalation: true
          capabilities:
            drop:
              - ALL
            add:
              - NET_BIND_SERVICE
          # www-data -> 33
          runAsUser: 0
          runAsGroup: 0
        ports:
          - name: http
            containerPort: 80
          - name: https
            containerPort: 443
          - name: metrics
            containerPort: 9090
        env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
        # args:
        #   - -tls
        #   - -tls-use-staging
        #   - -email=test@test.com
