Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no longer works on Cloud Run on GKE #42

Closed
samos123 opened this issue May 11, 2021 · 5 comments · Fixed by #43
Closed

no longer works on Cloud Run on GKE #42

samos123 opened this issue May 11, 2021 · 5 comments · Fixed by #43

Comments

@samos123
Copy link

samos123 commented May 11, 2021

Steps to reproduce:

gcloud container clusters create cluster-1 \
  --addons=HttpLoadBalancing,CloudRun \
  --machine-type=n1-standard-2 \
  --enable-stackdriver-kubernetes \
  --region=us-central1 \
  --node-locations=us-central1-a

gcloud config set run/cluster cluster-1
gcloud config set run/cluster_location us-central1

gcloud run deploy hello --image gcr.io/cloudrun/hello --platform gke

export GW_IP=$(kubectl get svc -n gke-system istio-ingress | grep istio-ingress | awk '{ print $4}')

curl -s -H "Host: hello.default.example.com" $GW_IP

That curl returns the following:

                        <p>

                                        This container <strong>does not</strong> seem to be running
                                        on Cloud Run.

                        </p>
                   

In previous versions of this image ~6 months ago, the exact same steps did not return This container does not seem to be running on cloud run. So something must have changed on the Cloud Run side or in this image.

@ahmetb
Copy link
Contributor

ahmetb commented May 12, 2021

My suspicion is that our Region detection causes this.
On a VM, this returns 404:

curl -H "metadata-flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/region

as there's /zone on VMs.

@samos123
Copy link
Author

I'm not sure why it worked before though, but looking at the code it must be something related to metadata. I will investigate further later tonight and report back.

@ahmetb
Copy link
Contributor

ahmetb commented May 12, 2021

I mean my comment alone explains at least why it doesn't work. Other variables that trigger this situation seem like they work fine on a VM environment.

@samos123
Copy link
Author

Yeah you were spot on. I verified by doing another test this time with GKE_METADATA and workload identity enabled. These commands were run from the application pod:

/ # wget --header "metadata-flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/region
Connecting to metadata.google.internal (169.254.169.254:80)
wget: server returned error: HTTP/1.1 404 Not Found
/ # wget --header "metadata-flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/zone
Connecting to metadata.google.internal (169.254.169.254:80)
saving to 'zone'
zone                 100% |************************************************************************************************|    41  0:00:00 ETA
'zone' saved

I'm going to try create a quick fork that doesn't get the region and see if the rest still works as is. Thanks so much for the pointers saved me a lot of time debuggin this.

@samos123
Copy link
Author

This samos123/cloud-run-hello@5584ed7 fixed the issue for Cloud Run on GKE as hacky workaround. I will provide a cleaner fix and submit PR later this week.

ahmetb added a commit to ahmetb/cloud-run-hello that referenced this issue Jul 19, 2021
Needed to query /zone (because VMs run in zones).
Fixes GoogleCloudPlatform#42.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
ahmetb added a commit to ahmetb/cloud-run-hello that referenced this issue Jul 19, 2021
Needed to query /zone (because VMs run in zones).
Fixes GoogleCloudPlatform#42.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
@ahmetb ahmetb mentioned this issue Jul 19, 2021
steren pushed a commit that referenced this issue Jul 19, 2021
make Cloud RUn for Anthos work
Fixes #42.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants