-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Added Events for Cloud Run for Anthos – GCS and PubSub tutorials. Fix… #4232
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
Conversation
Hi Mete - these look like tutorials rather than code samples. Unless you're going to add code samples to go with it, I think the Cloud Run docs would be a better home for these. |
@dinagraves There are 2 samples already for Cloud Run Events (Managed) written by @grant. I simply added instructions for those same 2 samples for Cloud Run Events (Anthos). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @meteatamel. This matches what we talked about.
I did not test the instructions but I verified the README looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
run/events-storage/anthos.md
Outdated
Set cluster name, location and platform: | ||
|
||
```sh | ||
gcloud config set run/cluster events-cluster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later I get an error saying: No cluster named 'events-cluster' in {project_name}
. Can you add a step for creating the clusters? https://cloud.google.com/run/docs/gke/setup#create_cluster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Pub/Sub tutorial, I say at the beginning "It is assumed that you already created a GKE cluster with Events for Cloud Run already installed." but it looks like I forgot to add a similar note to GCS tutorial. I'll do that tomorrow.
I deliberately left out instructions on creating a GKE cluster with Cloud Run Events because the steps are extremely long and error-prone right now (see steps 6, 7 and 8 of this codelab for details) and they'll get much easier very soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you include the link to the docs for both notes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs are not ready yet. There's Alpha User Guide but they'll be somewhat irrelevant soon. I can link to that, if you think it'll be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed this: https://cloud.google.com/run/docs/gke/setup#create_cluster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That creates a GKE cluster with Cloud Run but it doesn't install eventing..You really need to go through that codelab I linked to set things up with Cloud Run Eventing on Anthos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a note to GCS tutorial that a GKE cluster with Events for Cloud Run is needed for the sample. Again, I feel like we shouldn't link to Alpha User Guide and wait for official docs for installation instructions to link to. Feel free to open a tracking bug and assign to me, if needed.
run/events-storage/anthos.md
Outdated
|
||
```sh | ||
gcloud config set run/cluster events-cluster | ||
gcloud config set run/cluster_location europe-west1-b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be eu? Should we give an option to use other locations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran into this error since my cluster was in the US:
Could not find [events-cluster] in [europe-west1-b].
Did you mean [events-cluster] in [us-central1-c]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be EU or US..This is meant to be just an example of a cluster name and location. We can externalize them into env vars, if you think it's better that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to put it into env vars given the creation of the clusters is outside this tutorial and could easily be in another region.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commited a change to externalize these into env variables
```sh | ||
gcloud builds submit \ | ||
--tag gcr.io/$(gcloud config get-value project)/$MY_RUN_CONTAINER | ||
gcloud run deploy $MY_RUN_SERVICE \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially got ERROR: (gcloud.run.deploy) [Errno 61] Connection refused
Successfully connected with gcloud container clusters get-credentials events-cluster --zone us-central1-c --project {PROJECT_ID}
and ran the deploy command without issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the two are related. get-credentials
sets up kubectl to talk to the cluster but it should not affect gcloud run deploy
. The only thing that can affect deploy is the run/platform gke
setting. Make sure it's set to gke
to deploy to GKE/Anthos.
```sh | ||
gcloud alpha events triggers create $MY_GCS_TRIGGER \ | ||
--target-service $MY_RUN_SERVICE \ | ||
--type=com.google.cloud.storage.object.finalize \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran into this error
ERROR: (gcloud.alpha.events.triggers.create) Unknown event type: com.google.cloud.storage.object.finalize. If you're trying to use a custom event type, add the "--custom-type" flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, when I run the gcloud alpha events types list
, it responds with
Listed 0 items.
I did run gcloud components update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is that you don't have run/platform
variable set to gke
. So, it's trying to deploy to managed
and managed
does not support com.google.cloud.storage.object.finalize
yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gcloud config list
shows platform = gke
Looks like this person had the same problem: #4228
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's similar but not the same problem. #4228 is with Cloud Run Managed, whereas this PR is with Cloud Run for Anthos. Both features are in alpha and projects need to be whitelisted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! Should that be noted somewhere? Or are you going wait until it's publicly available to merge this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grant already submitted samples for Managed in preparation for upcoming Beta. I'm merely mirroring it for Anthos. I think we can merge this as is and if we need to note anything before Beta, this can be done holistically for Managed and Anthos.
@grant @dinagraves Anything else needed before merging this PR? |
@meteatamel good to go |
I've already approved the PR. We have 2 approvers. Merging. Thanks for the PR :) |
…es issue #4231
Description
Fixes #
Note: It's a good idea to open an issue first for discussion.
Checklist
nox -s py-3.6
(see Test Enviroment Setup)nox -s lint
(see Test Enviroment Setup)