-
Notifications
You must be signed in to change notification settings - Fork 140
Added Google Cloud Run tutorial #275
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
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
7a74440
Added Streams tutorial for RedisInsight v2.0
ajeetraina 9f1d29f
A Minor Numbering fix
ajeetraina f453f84
Update docs/explore/redisinsightv2/streams/index-streams.mdx
ajeetraina f848c21
Update docs/explore/redisinsightv2/streams/index-streams.mdx
ajeetraina 2eaf244
Update docs/explore/redisinsightv2/streams/index-streams.mdx
ajeetraina 25bc1e7
Update docs/explore/redisinsightv2/streams/index-streams.mdx
ajeetraina 3acf83a
Update docs/explore/redisinsightv2/streams/index-streams.mdx
ajeetraina d5e22f6
Update docs/explore/redisinsightv2/streams/index-streams.mdx
ajeetraina bead7a9
Update docs/explore/redisinsightv2/streams/index-streams.mdx
ajeetraina 0320f60
Update docs/explore/redisinsightv2/streams/index-streams.mdx
ajeetraina 8c7ec3e
Update docs/explore/redisinsightv2/streams/index-streams.mdx
ajeetraina 0aa52d5
Merge branch 'redis-developer:master' into master
ajeetraina 693fd7c
Minor formatting
ajeetraina a632a68
Added Cloud Run and Redis tutorial
ajeetraina 65e1bd1
Update index.deno.mdx
ajeetraina 2d5009b
Update index.deno.mdx
ajeetraina 0f2ac99
Merge pull request #1 from redis-developer/master
ajeetraina f89269e
Added New Google Cloud Run tutorial
ajeetraina 6ab8198
Removed Streams
ajeetraina f3ce9aa
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina de978b0
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina afe535d
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 817295f
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 06f1744
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 11741de
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 58cc22e
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina f2da416
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 1186044
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 68bd812
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina eea40c9
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 90eae24
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina b3c1a37
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina ade6234
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 7258036
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 016417b
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 6797525
Update docs/create/cloudrun/index-cloudrun.mdx
ajeetraina 9da2e3a
Update index-cloudrun.mdx
ajeetraina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,286 @@ | ||
| --- | ||
| id: index-cloudrun | ||
| title: Getting Started with Google Cloud Run and Redis | ||
| sidebar_label: Getting Started with Google Cloud Run and Redis | ||
| slug: /create/cloudrun | ||
| authors: [ajeet] | ||
| --- | ||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
| If you’re looking for a solution that lets you go from container to URL within seconds, check out Google Cloud Run. [Cloud Run](https://cloud.google.com/run) is Google’s fully managed compute platform for running stateless, HTTP-driven containers. By using a single command (“[gcloud run deploy”](https://cloud.google.com/sdk/gcloud/reference/run/deploy)) you can convert a container image to a fully managed web application and run it in a production environment with auto-scalability, high availability, and security. | ||
|
|
||
| [Google Cloud Run](https://cloud.google.com/run/docs) allows you to deploy and scale serverless HTTP containers without worrying about provisioning servers, scaling servers up and down to meet demands, or overpaying by consuming more resources than necessary. It makes container deployment much easier. It is good for developing software in cloud applications, hence delivering web apps, [APIs](https://cloud.google.com/run/docs/reference/rest), background jobs, etc. | ||
|
|
||
| Cloud Run is [powered and built on Knative](https://cloud.google.com/knative). Knative is an open source community project which adds components for deploying, running, and managing serverless, cloud-native applications to Kubernetes. It allows you to easily run your containers either in your [https://cloud.google.com/kubernetes-engine](https://cloud.google.com/kubernetes-engine/) (GKE) cluster with Cloud Run on GKE or fully managed with Cloud Run. Cloud Run helps developers focus on writing high-value code, regardless of where their organizations are on the path to the cloud. | ||
|
|
||
|
|
||
| ### Compelling features of Google Cloud Run | ||
|
|
||
|
|
||
|
|
||
| - Cloud Run provides you with the option to write your code in your preferred programming languages such as [NodeJS](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/run/helloworld/), [Python](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/run/), [Go](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/run/), and [Java](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/run/). | ||
| - Cloud Run provides you a better ROI as you get charged only for the resources used. | ||
| - Cloud Run offers a[ longer request timeout duration of up to 60 minutes](https://cloud.google.com/run/docs/configuring/request-timeout). | ||
| - Cloud Run is configured to [send multiple concurrent requests on each container instance. ](https://cloud.google.com/run/docs/configuring/concurrency)This is helpful to improve latency and reduce costs if you’re expecting large volumes. | ||
| - Cloud Run lets you [create microservice-based applications that are scalable and extensible](https://cloud.google.com/blog/products/serverless/build-event-driven-applications-in-cloud-run). | ||
|
|
||
| In this tutorial, you will learn how to deploy a simple Redis rate limiting application to Google Cloud Run in just 5 minutes. | ||
|
|
||
| ### Table of Contents | ||
|
|
||
|
|
||
|
|
||
|
|
||
| * Step 1. Set up a free Redis Enterprise Cloud account | ||
| * Step 2. Install Google Cloud CLI | ||
| * Step 3. Authenticate your GCP account | ||
| * Step 4. Enable Google Services | ||
| * Step 5. Deploy to Google Cloud Run from source | ||
| * Step 6. Verify if service is listed | ||
| * Step 7. Set up environment variables | ||
| * Step 8. Access your app | ||
|
|
||
| ### Step 1. Set up a free Redis Enterprise Cloud account | ||
|
|
||
| Visit [developer.redis.com/create/rediscloud/](https://developer.redis.com/create/rediscloud/) and create [a free Redis Enterprise Cloud account](https://redis.com/try-free/). Once you complete the signup tutorial, you will be provided with the database endpoint URL, port and password. Save these for future reference. | ||
|
|
||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
| ### Step 2. Install Google Cloud CLI | ||
|
|
||
| Run the following command to install Google Cloud CLI Core Libraries and dependencies: | ||
|
|
||
|
|
||
| ``` | ||
| brew install --cask google-cloud-sdk | ||
|
|
||
| ``` | ||
|
|
||
|
|
||
| ### Step 3. Authenticate your GCP account | ||
|
|
||
| To deploy your app you must first download, install, and initialize the [gcloud CLI](https://cloud.google.com/sdk/docs). | ||
|
|
||
| Download and install gcloud SDK via [https://cloud.google.com/sdk/docs](https://cloud.google.com/sdk/docs) | ||
|
|
||
|
|
||
| ``` | ||
| gcloud auth login | ||
| ``` | ||
|
|
||
|
|
||
| Allow Google Cloud SDK access to your Google Account: | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
| ### Step 4. Enable Google Services | ||
|
|
||
|
|
||
| ``` | ||
| gcloud services enable \ | ||
| artifactregistry.googleapis.com \ | ||
| cloudbuild.googleapis.com \ | ||
| run.googleapis.com | ||
| Operation "operations/acat.p2-406459833831-88327c08-1fe9-4d9a-a6b9-db8c8b007863" finished successfully. | ||
|
|
||
|
|
||
| ``` | ||
|
|
||
|
|
||
| ### Step 5 . Deploy to Google Cloud Run from source | ||
|
|
||
| Deploying from source automatically builds a container image from source code and deploys it. | ||
|
|
||
|
|
||
| ``` | ||
| gcloud run deploy | ||
| Deploying from source. To deploy a container use [--image]. See https://cloud.google.com/run/docs/deploying-source-code for more details. | ||
| Source code location (/Users/ajeetraina/projects/googlecloud/basic-rate-limiting-demo-python/google-cloud-run): | ||
| Next time, use `gcloud run deploy --source .` to deploy the current directory. | ||
|
|
||
| Service name (google-cloud-run): | ||
| Please specify a region: | ||
| [1] asia-east1 | ||
| [2] asia-east2 | ||
| [3] asia-northeast1 | ||
| [4] asia-northeast2 | ||
| [5] asia-northeast3 | ||
| [6] asia-south1 | ||
| [7] asia-south2 | ||
| [8] asia-southeast1 | ||
| [9] asia-southeast2 | ||
| [10] australia-southeast1 | ||
| [11] australia-southeast2 | ||
| [12] europe-central2 | ||
| [13] europe-north1 | ||
| [14] europe-west1 | ||
| [15] europe-west2 | ||
| [16] europe-west3 | ||
| [17] europe-west4 | ||
| [18] europe-west6 | ||
| [19] northamerica-northeast1 | ||
| [20] northamerica-northeast2 | ||
| [21] southamerica-east1 | ||
| [22] southamerica-west1 | ||
| [23] us-central1 | ||
| [24] us-east1 | ||
| [25] us-east4 | ||
| [26] us-west1 | ||
| [27] us-west2 | ||
| [28] us-west3 | ||
| [29] us-west4 | ||
| [30] cancel | ||
| Please enter your numeric choice: 1 | ||
|
|
||
| To make this the default region, run `gcloud config set run/region asia-east1`. | ||
|
|
||
| Deploying from source requires an Artifact Registry Docker repository to store built containers. A repository named | ||
| [cloud-run-source-deploy] in region [asia-east1] will be created. | ||
|
|
||
| Do you want to continue (Y/n)? Y | ||
|
|
||
| This command is equivalent to running `gcloud builds submit --tag [IMAGE] /Users/ajeetraina/projects/googlecloud/basic-rate-limiting-demo-python/google-cloud-run` and `gcloud run deploy google-cloud-run --image [IMAGE]` | ||
|
|
||
| Allow unauthenticated invocations to [google-cloud-run] (y/N)? y | ||
|
|
||
| Building using Dockerfile and deploying container to Cloud Run service [google-cloud-run] in project [redislabs-marketing-project] region [asia-east1] | ||
| ⠼ Building and deploying new service... Uploading sources. | ||
| ✓ Creating Container Repository... | ||
| ✓ Uploading sources... | ||
| . Building Container... | ||
| . Creating Revision... | ||
| . Routing traffic... | ||
| . Setting IAM Policy… | ||
|
|
||
| Please enter your numeric choice: 1 | ||
|
|
||
| To make this the default region, run `gcloud config set run/region asia-east1`. | ||
|
|
||
| Allow unauthenticated invocations to [django-redis-rate-limiting-example] (y/N)? y | ||
|
|
||
| Deploying container to Cloud Run service [django-redis-rate-limiting-example] in project [redislabs-marketing-project] region [asia-east1] | ||
| ✓ Deploying new service... Done. | ||
| ✓ Creating Revision... Revision deployment finished. Waiting for health check to begin. | ||
| ✓ Routing traffic... | ||
| ✓ Setting IAM Policy... | ||
| Done. | ||
| Service [django-redis-rate-limiting-example] revision [django-redis-rate-limiting-example-00001-mog] has been deployed and is serving 100 percent of traffic. | ||
| Service URL: https://django-redis-rate-limiting-example-opcboau66a-de.a.run.app | ||
|
|
||
|
|
||
| ``` | ||
|
|
||
|
|
||
|
|
||
| ### Step 6. Verify if the service is listed under Cloud Run dashboard | ||
|
|
||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
| #### Verifying the service via terminal UI | ||
|
|
||
|
|
||
| ``` | ||
| $ gcloud run services describe django-redis-rate-limiting-example | ||
|
|
||
| ✔ Service django-redis-rate-limiting-example in region asia-east1 | ||
|
|
||
| URL: https://django-redis-rate-limiting-example-opcboau66a-de.a.run.app | ||
| Ingress: all | ||
| Traffic: | ||
| 100% LATEST (currently django-redis-rate-limiting-example-00001-mog) | ||
|
|
||
| Last updated on 2022-02-19T02:50:03.100357Z by ajeet.raina@redis.com: | ||
| Revision django-redis-rate-limiting-example-00001-mog | ||
| Image: gcr.io/redislabs-marketing-project/django-redis-rate-limiting-example@sha256:95bf8d5705c4ab52d2c9ba07d7dcf0c651431d8d5d38ad8806487aaa8a8a870d at 95bf8d57... | ||
| Port: 8080 | ||
| Memory: 512Mi | ||
| CPU: 1000m | ||
| Service account: 406459833831-compute@developer.gserviceaccount.com | ||
| Concurrency: 80 | ||
| Max Instances: 100 | ||
| Timeout: 300s | ||
|
|
||
| ``` | ||
|
|
||
|
|
||
| ### Step 7. Set up environment variables | ||
|
|
||
|
|
||
|
|
||
| - Adding Redis URL to point to Redis Enterprise Cloud | ||
|
|
||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
|
|
||
|
|
||
| - Enable HTTPS | ||
|
|
||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
|
|
||
| - Ensuring the VPC connector shows as “none” | ||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
|
|
||
| - Allowing all traffic | ||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
| ### Step 8. Access your app | ||
|
|
||
|
|
||
| Wait for the build and deploy to complete. When finished, a message with unique URL will be displayed. | ||
| Please note that the URL shown in your case will be different from the one shown below: | ||
|
|
||
| Open [https://django-redis-rate-limiting-example-opcboau66a-de.a.run.app/](https://django-redis-rate-limiting-example-opcboau66a-de.a.run.app/) and access your app. | ||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
| This app allows you to choose the desired number of requests in each 10 second period. The app blocks connections from a client after surpassing a certain amount of requests (default: 10) in the time window (default: 10 sec). That will let the user know how many requests they have remaining before they run over the limit. On the tenth run, the server should return an HTTP status code of 429 (“Too Many Requests”). | ||
|
|
||
| ### Additional references: | ||
|
|
||
|
|
||
|
|
||
| - [Google Cloud Run](https://cloud.google.com/run) | ||
| - [Features of Google Run](https://cloud.google.com/run#section-13) | ||
| - [Create Redis Database using Google Cloud](https://developer.redis.com/create/gcp) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.