---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kong-deployment
  labels:
    app: kong
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kong
  template:
    metadata:
      labels:
        app: kong
    spec:
      containers:
        - name: kong
          image: kong:k8s-test
          env:
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: KONG_ADMIN_LISTEN
              value: "0.0.0.0:8001"
            - name: KONG_PG_PASSWORD
              value: kong
            - name: KONG_PG_HOST
              value: $(POD_IP)
          ports:
            - containerPort: 8001
          command: ["/bin/sh"]
          args: ["-c", "while [ 0 ]; do (kong migrations bootstrap || kong migrations up) && break; sleep 1; done && /docker-entrypoint.sh kong docker-start"]
          readinessProbe:
            httpGet:
              path: /signalfx
              port: 8001
            initialDelaySeconds: 5
            periodSeconds: 5
            timeoutSeconds: 5
        - name: postgres
          image: postgres:9.6
          env:
            - name: POSTGRES_USER
              value: kong
            - name: POSTGRES_PASSWORD
              value: kong
            - name: POSTGRES_DB
              value: kong
          ports:
            - containerPort: 5432
          readinessProbe:
            tcpSocket:
              port: 5432
            initialDelaySeconds: 5
            periodSeconds: 5
            timeoutSeconds: 5
