---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kelvin
spec:
  selector:
    matchLabels:
      name: kelvin
  template:
    metadata:
      labels:
        name: kelvin
        plane: data
    spec:
      initContainers:
      - name: qb-wait
        image: gcr.io/pixie-prod/pixie-prod-artifacts/curl:1.0
        # yamllint disable
        command: ['sh', '-c', 'set -x;
          URL="https://${SERVICE_NAME}:${SERVICE_PORT}/healthz";
          until [ $(curl -m 0.5 -s -o /dev/null -w "%{http_code}" -k ${URL}) -eq 200 ]; do
            echo "waiting for ${URL}"
            sleep 2;
          done;
        ']
        env:
          # The name of the service that Kelvin must connect with before becoming available.
        - name: SERVICE_NAME
          value: "vizier-query-broker"
        - name: SERVICE_PORT
          value: "50300"
      containers:
      - name: app
        image: gcr.io/pl-dev-infra/vizier/kelvin_image:latest
        envFrom:
        - configMapRef:
            name: pl-tls-config
        env:
        - name: PL_HOST_PATH
          value: "/host"
        - name: PL_POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: PL_POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: PL_HOST_IP
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
        - name: PL_JWT_SIGNING_KEY
          valueFrom:
            secretKeyRef:
              key: jwt-signing-key
              name: pl-cluster-secrets
        - name: PL_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: TCMALLOC_SAMPLE_PARAMETER
          value: "1048576"
        ports:
        - containerPort: 59300
        volumeMounts:
        - mountPath: /certs
          name: certs
        - name: sys
          mountPath: /sys
          readOnly: true
        resources: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - name: certs
        secret:
          secretName: service-tls-certs
      - name: sys
        hostPath:
          path: /sys
          type: Directory
