Skip to content

Commit

Permalink
rungmp: minor tweaks to improve usability
Browse files Browse the repository at this point in the history
These changes come from the docs reviews requested by PM

Change-Id: Id6be43027a0548f00e58c0a645a8153325970786
Signed-off-by: Ridwan Sharif <[email protected]>
  • Loading branch information
ridwanmsharif committed Dec 7, 2023
1 parent 29055f4 commit ea2cad3
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ gcloud builds submit . --config=cloudbuild-simple.yaml --region=${REGION}
After the build, run the following command to check the endpoint URL.

```console
gcloud run services describe run-gmp-sidecar-service --region=${REGION} --format="value(status.url)"
gcloud run services describe my-cloud-run-service --region=${REGION} --format="value(status.url)"
```

### Run sample (manual steps)
Expand Down Expand Up @@ -192,7 +192,7 @@ Finally before you make make the request to the URL, you need to change
the Cloud Run service policy to accept unauthenticated HTTP access.

```
gcloud run services set-iam-policy run-gmp-sidecar-service policy.yaml --region=${REGION}
gcloud run services set-iam-policy my-cloud-run-service policy.yaml --region=${REGION}
```

> **_NOTE:_** If you have an Org policy that prevents unauthenticated access, then this step will fail. But fear not, you can simply curl the endpoint using `curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" <ENDPOINT>` instead.
Expand Down
35 changes: 27 additions & 8 deletions clean-up-cloud-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,33 @@
PROJECT_ID=$(gcloud config get-value project)
SA_NAME="run-gmp-sa"
REGION="${REGION:-us-east1}"
SERVICE_NAME="my-cloud-run-service"
SECRET="run-gmp-config"
REPO="run-gmp"
SA="${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com"

gcloud run services delete run-gmp-sidecar-service --region ${REGION} --quiet
# Delete secret if we created it before
if gcloud secrets list --filter="name ~ .*run-gmp-config.*" | grep run-gmp-config
# Delete the service
if gcloud run services list --project=${PROJECT_ID} --region=${REGION} | grep ${SERVICE_NAME}
then
gcloud secrets delete run-gmp-config
gcloud run services delete ${SERVICE_NAME} --region ${REGION} --quiet
fi

# Delete secret if we created it before.
if gcloud secrets list --filter="name ~ .*${SECRET}.*" | grep ${SECRET}
then
gcloud secrets delete ${SECRET}
fi

# Delete AR repo if it exists.
if gcloud artifacts repositories list --project=${PROJECT_ID} --location=${REGION} | grep ${REPO}
then
gcloud artifacts repositories delete ${REPO} \
--location=${REGION} \
--quiet
fi

# Delete SA if exists.
if gcloud iam service-accounts list --project=${PROJECT_ID} | grep ${SA}
then
gcloud iam service-accounts delete ${SA}
fi
gcloud artifacts repositories delete run-gmp \
--location=${REGION} \
--quiet
gcloud iam service-accounts delete ${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com
2 changes: 1 addition & 1 deletion cloudbuild-simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ steps:
"run",
"services",
"set-iam-policy",
"run-gmp-sidecar-service",
"my-cloud-run-service",
"policy.yaml",
"--region",
"${_REGION}",
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild-single-req.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ steps:
"run",
"services",
"set-iam-policy",
"run-gmp-sidecar-service",
"my-cloud-run-service",
"policy.yaml",
"--region",
"${_REGION}",
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ steps:
"run",
"services",
"set-iam-policy",
"run-gmp-sidecar-service",
"my-cloud-run-service",
"policy.yaml",
"--region",
"${_REGION}",
Expand Down
4 changes: 2 additions & 2 deletions entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (

// Create channel to listen for signals.
var signalChan chan (os.Signal) = make(chan os.Signal, 1)
var userConfigFile = "/etc/rungmp/config.yml"
var otelConfigFile = "/run/rungmp/otel.yml"
var userConfigFile = "/etc/rungmp/config.yaml"
var otelConfigFile = "/run/rungmp/otel.yaml"

func main() {
// SIGINT handles Ctrl+C locally.
Expand Down
3 changes: 2 additions & 1 deletion run-service-simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ kind: Service
metadata:
annotations:
run.googleapis.com/launch-stage: ALPHA
name: run-gmp-sidecar-service
name: my-cloud-run-service
spec:
template:
metadata:
annotations:
run.googleapis.com/execution-environment: gen1
run.googleapis.com/cpu-throttling: 'false'
run.googleapis.com/container-dependencies: '{"collector":["app"]}'
spec:
containers:
Expand Down
5 changes: 3 additions & 2 deletions run-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ kind: Service
metadata:
annotations:
run.googleapis.com/launch-stage: ALPHA
name: run-gmp-sidecar-service
name: my-cloud-run-service
spec:
template:
metadata:
annotations:
run.googleapis.com/execution-environment: gen1
run.googleapis.com/cpu-throttling: 'false'
run.googleapis.com/container-dependencies: '{"collector":["app"]}'
run.googleapis.com/secrets: '%SECRET%:projects/%PROJECT%/secrets/%SECRET%'
spec:
Expand All @@ -49,5 +50,5 @@ spec:
secret:
items:
- key: latest
path: config.yml
path: config.yaml
secretName: '%SECRET%'

0 comments on commit ea2cad3

Please sign in to comment.