-
Notifications
You must be signed in to change notification settings - Fork 39
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
Remove MR mapping for cloud run and cloud functions #250
Changes from 6 commits
6e9e41e
01abb0a
805f917
d78c789
2a6baea
c515993
3a165ae
ede8f80
13350d1
5580d40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,42 @@ Or, if you'd like to synthesize a parent trace: | |
curl -H "traceparent: 00-ff000000000000000000000000000041-ff00000000000041-01" ${cluster_ip} | ||
``` | ||
|
||
## Running in Google Cloud Run | ||
|
||
To run this example in Google Cloud Run, you need to run the convenience script provided. After following the prerequisites, | ||
|
||
First, export the Google Cloud Region for cloud run to `GOOGLE_CLOUD_RUN_REGION` environment variable: | ||
|
||
```shell | ||
# This can be any supported Google cloud region | ||
export GOOGLE_CLOUD_RUN_REGION=us-central1 | ||
``` | ||
|
||
Then, from the root of the repository, | ||
```shell | ||
cd examples/autoinstrument && ./run_in_cloud-run.sh | ||
``` | ||
This will deploy the containerized application to Cloud Run and you will be presented with a service URL which would look something like - | ||
psx95 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```text | ||
Service URL: https://hello-autoinstrument-cloud-run-m43qtxry5q-uc.a.run.app | ||
``` | ||
|
||
Comment on lines
+71
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we're using the proxy, the service URL should no longer matter right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is just to clarify what to expect in case of a successful deployment. Also, I believe now we are adding the cURL instructions back, so this would be useful there. |
||
Once you have the service URL to the application, you can make **authenticated** requests to it. Authenticated requests can be made from the command line by passing an auth token in a cURL request - | ||
|
||
```shell | ||
# Make sure to replace the SERVICE_URL with the one that was generated for your deployment | ||
|
||
# Making a request to / | ||
curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" ${SERVICE_URL}/ | ||
|
||
# Making a request to /greeting | ||
curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" ${SERVICE_URL}/greeting | ||
``` | ||
|
||
You can also allow public access to your cloud-run service, details for which can be found [here](https://cloud.google.com/run/docs/authenticating/public#console-ui). | ||
With public access enabled, you would no longer need to provide the auth token within your requests. | ||
|
||
## Running locally in a docker container | ||
|
||
In case you do not want to spin up your own GKE cluster, but still want telemetry to be published to Google Cloud, you can run the example in a docker container. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
CONTAINER_REGISTRY=cloud-run-applications | ||
REGISTRY_LOCATION=us-central1 | ||
|
||
if [[ -z "${GOOGLE_CLOUD_PROJECT}" ]]; then | ||
echo "GOOGLE_CLOUD_PROJECT environment variable not set" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${GOOGLE_APPLICATION_CREDENTIALS}" ]]; then | ||
echo "GOOGLE_APPLICATION_CREDENTIALS environment variable not set" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${GOOGLE_CLOUD_RUN_REGION}" ]]; then | ||
echo "GOOGLE_CLOUD_RUN_REGION environment variable not set" | ||
exit 1 | ||
fi | ||
|
||
echo "ENVIRONMENT VARIABLES VERIFIED" | ||
|
||
echo "CREATING CLOUD ARTIFACT REPOSITORY" | ||
gcloud artifacts repositories create ${CONTAINER_REGISTRY} --repository-format=docker --location=${REGISTRY_LOCATION} --description="Sample applications to run on Google Cloud Run" | ||
psx95 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "CREATED ${CONTAINER_REGISTRY} in ${REGISTRY_LOCATION}" | ||
|
||
echo "BUILDING SAMPLE APP IMAGE" | ||
gradle clean jib --image "${REGISTRY_LOCATION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/${CONTAINER_REGISTRY}/hello-autoinstrument-java" | ||
psx95 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
echo "RUNNING SAMPLE APP ON PORT 8080" | ||
gcloud run deploy hello-autoinstrument-cloud-run \ | ||
--image="${REGISTRY_LOCATION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/${CONTAINER_REGISTRY}/hello-autoinstrument-java" \ | ||
--region="${GOOGLE_CLOUD_RUN_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.
In future, please keep unrelated changes (such as examples) in separate PRs.