google-cloud-platformgoogle-cloud-run

Increase gcloud run deploy timeout (NOT request timeout)


How to increase gcloud run deploy timeout (NOT request timeout)?

I know that I can do this FOR cloud build gcloud config set app/cloud_build_timeout 900

But my build takes a very long time, the cloud build keeps running but "gcloud run deploy" time out.


Solution

  • You can increase the duration for the startup probe up to 240s (4 minutes). For that, you need to create a YAML file that you will deploy with the following command

    gcloud run services replace <yaml file>
    
    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: long-starts
      namespace: '<YOUR PEOJECT ID>'
    spec:
      template:
        metadata:
          name: long-starts-0005
        spec:
          containerConcurrency: 80
          containers:
            - image: <YOUR CONTAINER IMAGE>
              ports:
                - name: http1
                  containerPort: 8080
              resources:
                limits:
                  cpu: 1000m
                  memory: 512Mi
              startupProbe:
                initialDelaySeconds: 30
                timeoutSeconds: 240
                periodSeconds: 240
                failureThreshold: 1
                tcpSocket:
                  port: 8080
    
    

    If you need more, you need to redesign your service: add more CPU/memory, load heavy components in background, split you service in multiple microservice, pre-load your component at container build time,...