I have this YAML (with the parts in square brackets replaced with the correct content):
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: ty-platform
spec:
template:
spec:
containers:
- image: gcr.io/[project name]/endpoints-runtime-serverless:[site URL]-2020-03-20r8
env:
- name: ESPv2_ARGS
value: ^++^--cors_preset=basic++--cors_allow_origin=[site]++--cors_allow_headers="Authorization"
which I try to upload with this command
gcloud beta run services replace service_replace.yaml --platform managed --region us-central1
(after having already deployed successfully with gcloud run deploy
).
The command runs successfully but upon testing it's clear that the replacement has failed. Namely, the ESPv2_ARGS variable is not created or updated. What could I be doing wrong?
The service in question is an ESPv2 image for a Cloud Endpoint.
I tried adding your ESPv2_ARGS
as-is (using an existing Cloud Run service not Endpoints) and the service's environment is updated. This appears to work-as-intended.
The prior revision of the service had no environment variables defined.
gcloud beta run services describe ${SERVICE} \
--project=${PROJECT} \
--platform=managed \
--region=${REGION} \
--format="yaml(spec.template.spec.containers[0].env)"
null
gcloud beta run services replace service.yaml
--platform=managed \
--region=${REGION} \
--project=${PROJECT}
Deploying container to Cloud Run service [...] in project [...] region [...]
✓ Deploying... Done.
✓ Creating Revision...
✓ Routing traffic...
Done.
gcloud beta run services describe ${SERVICE} \
--project=${PROJECT} \
--platform=managed \
--region=${REGION} \
--format="yaml(spec.template.spec.containers[0].env)"
spec:
template:
spec:
containers:
- env:
- name: ESPv2_ARGS
value: ^++^--cors_preset=basic++--cors_allow_origin=[site]++--cors_allow_headers="Authorization"
using:
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: ...
spec:
template:
metadata:
name: ...
spec:
containers:
- image: ...
env:
- name: ESPv2_ARGS
value: ^++^--cors_preset=basic++--cors_allow_origin=[site]++--cors_allow_headers="Authorization"
I can't attest to whether this environment variable affects ESP but, the replace command appears to work correctly.