---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cloud-proxy
spec:
  selector:
    matchLabels:
      name: cloud-proxy-server
  template:
    metadata:
      labels:
        name: cloud-proxy-server
    spec:
      containers:
      - name: cloud-proxy-server
        image: gcr.io/pixie-oss/pixie-dev/cloud/proxy_server_image
        ports:
        - containerPort: 56000
          name: http2
        - containerPort: 56001
          name: metrics-http
        readinessProbe:
          httpGet:
            scheme: HTTPS
            path: /healthz
            port: 56000
        livenessProbe:
          httpGet:
            scheme: HTTPS
            path: /healthz
            port: 56000
        envFrom:
        - configMapRef:
            name: pl-oauth-config
        - configMapRef:
            name: pl-domain-config
        - configMapRef:
            name: pl-service-config
        - configMapRef:
            name: pl-ory-service-config
        - configMapRef:
            name: pl-ld-config
        - configMapRef:
            name: pl-analytics-config
        - configMapRef:
            name: pl-announcement-config
        - configMapRef:
            name: pl-contact-config
        env:
        - name: PL_JWT_SIGNING_KEY
          valueFrom:
            secretKeyRef:
              name: cloud-auth-secrets
              key: jwt-signing-key
        - name: PL_TLS_CERT
          value: /certs/tls.crt
        - name: PL_TLS_KEY
          value: /certs/tls.key
        - name: PL_API_SERVICE_HTTP
          valueFrom:
            configMapKeyRef:
              name: pl-service-config
              key: PL_API_SERVICE_HTTP
        - name: PL_SEGMENT_UI_WRITE_KEY
          valueFrom:
            configMapKeyRef:
              name: segment-config
              key: ui-write-key
        - name: PL_SEGMENT_CLI_WRITE_KEY
          valueFrom:
            configMapKeyRef:
              name: segment-config
              key: cli-write-key
        volumeMounts:
        - name: certs
          mountPath: /certs
      - name: envoy
        image: envoyproxy/envoy:v1.12.2
        command: ["envoy"]
        args: ["-c", "/etc/envoy.yaml", "--service-cluster", "$(POD_NAME)"]
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        readinessProbe:
          httpGet:
            scheme: HTTPS
            path: /healthz
            port: 56004
        livenessProbe:
          httpGet:
            scheme: HTTPS
            path: /healthz
            port: 56004
        ports:
        - containerPort: 56004
        volumeMounts:
        - name: certs
          mountPath: /certs
        - name: envoy-yaml
          mountPath: /etc/envoy.yaml
          subPath: envoy.yaml
        - mountPath: /service-certs
          name: service-certs
      volumes:
      - name: service-certs
        secret:
          secretName: service-tls-certs
      - name: envoy-yaml
        configMap:
          name: proxy-envoy-config
      - name: certs
        secret:
          secretName: cloud-proxy-tls-certs
