apiVersion: apps/v1
kind: Deployment
metadata:
  name: kong-deployment
  labels:
    app: kong
spec:
  selector:
    matchLabels:
      app: kong
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: kong
        tier: frontend
    spec:
      containers:
        - name: kong
          image: kong:alpine
          env:
            - name: KONG_DATABASE
              valueFrom:
                configMapKeyRef:
                  name: kong-config
                  key: KONG_DATABASE_KEY
            - name: KONG_PROXY_ACCESS_LOG
              valueFrom:
                configMapKeyRef:
                  name: kong-config
                  key: KONG_PROXY_ACCESS_LOG_KEY                  
            - name: KONG_ADMIN_ACCESS_LOG
              valueFrom:
                configMapKeyRef:
                  name: kong-config
                  key: KONG_ADMIN_ACCESS_LOG_KEY
            - name: KONG_PROXY_ERROR_LOG
              valueFrom:
                configMapKeyRef:
                  name: kong-config
                  key: KONG_PROXY_ERROR_LOG_KEY
            - name: KONG_ADMIN_ERROR_LOG
              valueFrom:
                configMapKeyRef:
                  name: kong-config
                  key: KONG_ADMIN_ERROR_LOG_KEY
            - name: KONG_PROXY_LISTEN
              valueFrom:
                configMapKeyRef:
                  name: kong-config
                  key: KONG_PROXY_LISTEN_KEY
            - name: KONG_ADMIN_LISTEN
              valueFrom:
                configMapKeyRef:
                  name: kong-config
                  key: KONG_ADMIN_LISTEN_KEY
            - name: KONG_DECLARATIVE_CONFIG
              valueFrom:
                configMapKeyRef:
                  name: kong-config
                  key: KONG_DECLARATIVE_CONFIG_KEY
          ports:
            - containerPort: 8000
              name: proxy
            - containerPort: 8443
              name: proxy-ssl
            - containerPort: 8001
              name: admin-api                                  
            - containerPort: 8444
              name: admin-api-ssl
          volumeMounts:
            - name: kong-config
              mountPath: /etc/config
      volumes:
        - name: kong-config
          configMap:
            name: kong-config