kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    app.kubernetes.io/name: saver
  name: saver
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: saver
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: saver
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "8000"
    spec:
      securityContext:
        fsGroup: 65534
        runAsGroup: 65534
        runAsNonRoot: true
        runAsUser: 65534
      terminationGracePeriodSeconds: 10
      imagePullSecrets:
        - name: regcred
      containers:
        - name: saver
          image: us.gcr.io/com-seankhliao/saver:latest
          args:
            - -db=postgresql://saver@cockroachdb.datastore.svc.cluster.local:26257/saver?sslmode=verify-full&sslrootcert=/var/secret/cockroachdb/ca.crt&sslcert=/var/secret/cockroachdb/tls.crt&sslkey=/var/secret/cockroachdb/tls.key
          ports:
            - name: grpc
              containerPort: 8080
            - name: metrics
              containerPort: 8000
          # env:
          #   - name: JAEGER_SERVICE_NAME
          #     value: saver
          livenessProbe:
            httpGet:
              path: /liveness
              port: 8000
          readinessProbe:
            httpGet:
              path: /readiness
              port: 8000
          volumeMounts:
            - name: certs
              mountPath: /var/secret/tls
            - name: client
              mountPath: /var/secret/cockroachdb
      volumes:
        - name: certs
          secret:
            secretName: saver-cert
        - name: client
          secret:
            secretName: cockroachdb-client-saver
