Search code examples
google-cloud-platformgoogle-cloud-runknative

Google Cloud Run deployment not working using `gcloud` SDK CLI


I have a service created on Google Cloud run that I am able to deploy manually through the Google Cloud Console UI using an image on Container registry. But deployment from CLI is failing. Here is the command I am using and the error I get. I am not able to understand what I am missing:

$ gcloud beta run deploy service-name --platform managed --region region-name --image image-url
Deploying container to Cloud Run service [service-name] in project [project-name] region [region-name]
X Deploying...
  . Creating Revision...
  . Routing traffic...
Deployment failed
ERROR: (gcloud.beta.run.deploy) INVALID_ARGUMENT: The request has errors
- '@type': type.googleapis.com/google.rpc.BadRequest
  fieldViolations:
  - description: spec.revisionTemplate.spec.container.ports should be empty
    field: spec.revisionTemplate.spec.container.ports

Update 1: I have updated the SDK using gcloud components update, but I still have the same issue

Here's my SDK Version

$gcloud version
Google Cloud SDK 270.0.0
beta 2019.05.17
bq 2.0.49
core 2019.11.04
gsutil 4.46

I am using a multistage docker build. Here's my Dockerfile:

FROM custom-dev-image

COPY . /project_dir
WORKDIR /project_dir
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
  /usr/local/bin/go build -a \
  -ldflags '-w -extldflags "-static"' \
  -o /root/go/bin/executable ./cmds/project/main.go

FROM alpine:3.10
ENV GIN_MODE=release APP_NAME=project_name
COPY --from=0 /root/go/bin/executable /usr/local/bin/
CMD executable


Solution

  • This was a bug in Cloud Run. It has been fixed and deploying with CLI is working for me now. Here's the link to the issue I had raised with Google Cloud which has a response from them https://issuetracker.google.com/issues/144069696.