# Copyright (c) 2021 SIGHUP s.r.l All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: ingress-kong-dp
  name: ingress-kong-dp
  namespace: kong
spec:
  selector:
    matchLabels:
      app: ingress-kong-dp
  template:
    metadata:
      annotations:
        prometheus.io/port: "8100"
        prometheus.io/scrape: "true"
        traffic.sidecar.istio.io/includeInboundPorts: ""
        kuma.io/gateway: enabled
      labels:
        app: ingress-kong-dp
    spec:
      serviceAccountName: kong-serviceaccount
      containers:
        - name: proxy
          image: kong
          securityContext:
            runAsUser: 1000
          envFrom:
            - secretRef:
                name: kong-settings
          lifecycle:
            preStop:
              exec:
                command: [ "/bin/sh", "-c", "kong quit" ]
          ports:
            - name: proxy
              containerPort: 8000
              protocol: TCP
            - name: proxy-ssl
              containerPort: 8443
              protocol: TCP
            - name: metrics
              containerPort: 8100
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /status
              port: 8100
              scheme: HTTP
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /status
              port: 8100
              scheme: HTTP
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
        - name: ingress-controller
          env:
            - name: CONTROLLER_KONG_ADMIN_URL
              value: "https://127.0.0.1:8444"
            - name: CONTROLLER_KONG_ADMIN_TLS_SKIP_VERIFY
              value: "true"
            - name: CONTROLLER_PUBLISH_SERVICE
              value: "kong/kong-proxy"
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.namespace
          image: kong/kubernetes-ingress-controller
          imagePullPolicy: IfNotPresent
          ports:
            - name: webhook
              containerPort: 8080
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3