Skip to content

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

Merged
merged 4 commits into from
Jul 15, 2020
Merged

Conversation

meteatamel
Copy link
Contributor

…es issue #4231

Description

Fixes #

Note: It's a good idea to open an issue first for discussion.

Checklist

@meteatamel meteatamel requested review from dinagraves and a team as code owners July 2, 2020 10:17
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 2, 2020
@dinagraves
Copy link
Contributor

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.

@meteatamel
Copy link
Contributor Author

@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).

@grant grant self-requested a review July 6, 2020 17:47
Copy link
Contributor

@grant grant left a 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.

Copy link
Contributor

@dinagraves dinagraves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.

Set cluster name, location and platform:

```sh
gcloud config set run/cluster events-cluster
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@meteatamel meteatamel Jul 7, 2020

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.

Copy link
Contributor Author

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.


```sh
gcloud config set run/cluster events-cluster
gcloud config set run/cluster_location europe-west1-b
Copy link
Contributor

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?

Copy link
Contributor

@dinagraves dinagraves Jul 6, 2020

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]?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 \
Copy link
Contributor

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

Copy link
Contributor Author

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 \
Copy link
Contributor

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.

Copy link
Contributor

@dinagraves dinagraves Jul 6, 2020

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@meteatamel
Copy link
Contributor Author

@grant @dinagraves Anything else needed before merging this PR?

@dinagraves
Copy link
Contributor

@meteatamel good to go

@grant
Copy link
Contributor

grant commented Jul 15, 2020

I've already approved the PR.

We have 2 approvers. Merging. Thanks for the PR :)

@grant grant merged commit 6bcf974 into GoogleCloudPlatform:master Jul 15, 2020
@grant grant assigned meteatamel and unassigned crwilcox Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants