apiVersion: apps/v1
kind: Deployment
metadata:
  name: grpc-server-deployment
  labels:
    app: grpc-server
    component: "grpc"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: grpc-server
  template:
    metadata:
      labels:
        app: grpc-server
        component: "grpc"
    spec:
      volumes:
      - name: tls
        secret:
          secretName: tls
      containers:
      - name: grpc-server
        imagePullPolicy: Always
        image: nmercer88/yoshi2:alpha
        ports:
        - containerPort: 50051
          name: grpc-port
          protocol: TCP
        - containerPort: 8081
          name: grpc-http-port
        - containerPort: 8080
          name: healthz
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8080
        volumeMounts:
          - name: tls
            mountPath: /var/secrets/tls
        env:
          # TODO: Why do these not work?
          - name: TLS_KEY
            value: /var/secrets/tls/server.crt
          - name: TLS_CERT
            value: /var/secrets/tls/server.key
      initContainers:
      - name: migrations
        image: nmercer88/yoshi2:migrations
        command: ['/migrate']
        args: ['-source', 'file:///var/migrations/postgres', '-database', 'postgres://test:test@10.105.102.104:5432/telemetry?sslmode=disable', 'up']

