Set environment variables from a file in gcloud run deploy command

Viewed 919

I am trying to deploy cloud-run service which demands the passing of around 20 variables. As a result by gcloud command becomes too long and I'd like to store these variables in a file and refer it in the --set-env-vars flag.

current command:

gcloud run deploy gh-gardenia-bp3-carepackage-service-anand --image  gcr.io/$Project_ID/$Environment/$Cloud_function_name:$Cloud_function_version --set-env-vars=KEY1=VALUE1,KEY2=VALUE2,KEY3=VALUE3,KEY4=VALUE4...

gcloud run deploy gh-gardenia-bp3-carepackage-service-anand --image  gcr.io/$Project_ID/$Environment/$Cloud_function_name:$Cloud_function_version --set-env-vars="file"

We are flexible in terms of the format of the file (Json/XML/Txt etc.)

1 Answers

You can use the preview run services replace command:

gcloud beta run services replace myservice.yaml

The YAML file has the format:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: SERVICE
spec:
  template:
    spec:
      containers:
      - image: IMAGE
      - env:
        - name: KEY-1
          value: VALUE-1
        - name: KEY-N
          value: VALUE-N
Related