apiVersion: apps/v1
kind: Deployment
metadata:
  name: $APP
  labels:
    app: $APP
spec:
  selector:
    matchLabels:
      app: $APP
  replicas: 1
  template:
    metadata:
      labels:
        app: $APP
      annotations:
        prometheus.io/scrape: "true"
        promethus.io/port: "10254"
    spec:
      #      nodeSelector:
      #        role: services
      # hostNetwork makes it possible to use ipv6 and to preserve the source IP correctly regardless of docker configuration
      # however, it is not a hard dependency of the nginx-ingress-monitoring itself and it may cause issues if port 10254 already is taken on the host
      # that said, since hostPort is broken on CNI (https://github.com/kubernetes/kubernetes/issues/31307) we have to use hostNetwork where CNI is used
      # like with kubeadm
      # hostNetwork: true
      #      nodeSelector:
      #        role: services
      serviceAccountName: nginx-ingress-serviceaccount
      terminationGracePeriodSeconds: 1
      hostNetwork: true
      nodeSelector:
        role: services
      containers:
        - name: $APP
          image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.33.0
          readinessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 15
          livenessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 15
            timeoutSeconds: 1
          ports:
            - containerPort: 80
              hostPort: 80
            - containerPort: 443
              hostPort: 443
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          args:
            - /nginx-ingress-controller
            - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
            # - --publish-service=$(POD_NAMESPACE)/ingress-controller
            - --configmap=$(POD_NAMESPACE)/nginx-configuration
            #            - --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
            #        - --udp-services-configmap=$(POD_NAMESPACE)/udp-services
            - --annotations-prefix=nginx.ingress.kubernetes.io
