apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: strongbody-api
  annotations:
    run.googleapis.com/ingress: all
    run.googleapis.com/execution-environment: gen2
spec:
  template:
    metadata:
      annotations:
        run.googleapis.com/execution-environment: gen2
        run.googleapis.com/cpu-throttling: "false"
        run.googleapis.com/vpc-access-connector: strongbody-vpc-connector
        run.googleapis.com/vpc-access-egress: all-traffic
        autoscaling.knative.dev/maxScale: "10"
        autoscaling.knative.dev/minScale: "0"
    spec:
      containerConcurrency: 1000
      timeoutSeconds: 300
      containers:
      - image: gcr.io/strongbody-462009/strongbody-api:latest
        ports:
        - name: http1
          containerPort: 8080
        env:
        - name: SERVER_PORT
          value: "8080"
        - name: SERVER_HOST
          value: "0.0.0.0"
        - name: DB_HOST
          valueFrom:
            secretKeyRef:
              name: strongbody-api-secrets
              key: db-host
        - name: DB_PORT
          valueFrom:
            secretKeyRef:
              name: strongbody-api-secrets
              key: db-port
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              name: strongbody-api-secrets
              key: db-user
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: strongbody-api-secrets
              key: db-password
        - name: DB_NAME
          valueFrom:
            secretKeyRef:
              name: strongbody-api-secrets
              key: db-name
        - name: DB_SSLMODE
          value: "require"
        - name: SECRET_KEY
          valueFrom:
            secretKeyRef:
              name: strongbody-api-secrets
              key: secret-key
        - name: STRIPE_SECRET_KEY
          valueFrom:
            secretKeyRef:
              name: strongbody-api-secrets
              key: stripe-secret-key
        - name: ACCOUNT_EMAIL
          valueFrom:
            secretKeyRef:
              name: strongbody-api-secrets
              key: account-email
        - name: PASSWORD_EMAIL
          valueFrom:
            secretKeyRef:
              name: strongbody-api-secrets
              key: password-email
        - name: GOOGLE_CLOUD_PROJECT
          value: "strongbody-462009"
        - name: BUCKET_NAME
          value: "strongbody-storage"
        resources:
          limits:
            cpu: "2"
            memory: "4Gi"
          requests:
            cpu: "1"
            memory: "2Gi"
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5
          timeoutSeconds: 3
          failureThreshold: 3
  traffic:
  - percent: 100
    latestRevision: true
