Stay organized with collections Save and categorize content based on your preferences.
This guide shows you how to set up Binary Authorization to enforce policy-based deployment of Cloud Run services and jobs.
Note: After Binary Authorization is enabled, it enforces any update to the Cloud Run service. When you implement a change that affects traffic, Binary Authorization enforces deployment on any Cloud Run revision receiving traffic. Before you beginSet up Cloud Run and enable APIs, by doing the following:
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Run, Artifact Registry, Binary Authorization APIs.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
You can enable Binary Authorization enforcement on an existing service. To activate enforcement after enabling it, you might need to deploy a revision or update service traffic.
You can enable Binary Authorization enforcement on an existing service using the Google Cloud console or Google Cloud CLI:
ConsoleGo to the Cloud Run page in the Google Cloud console.
Click the service.
Click the Security tab.
To enable Binary Authorization enforcement on the service, click Enable.
Optional: To configure the Binary Authorization policy, click Configure Policy.
Enable Binary Authorization on the service and deploy it:
gcloud run services update SERVICE_NAME --binary-authorization=default
Replace SERVICE_NAME
with a name for your service.
If you are creating a new service, skip this step. If you are updating an existing service, download its YAML configuration:
gcloud run services describe SERVICE --format export > service.yaml
Update the run.googleapis.com/binary-authorization:
annotation as follows:
apiVersion: serving.knative.dev/v1 kind: Service metadata: annotations: run.googleapis.com/binary-authorization: POLICY name: SERVICE spec: template:
Replace the following:
default
Replace the service with its new configuration using the following command:
gcloud run services replace service.yamlNote: We recommend that you require Binary Authorization for Cloud Run by configuring an organization policy to do so. Binary Authorization can be disabled by Cloud Run developers if the policy is not configured. Enable Binary Authorization on an existing Cloud Run job
You can enable Binary Authorization enforcement on an existing job using the Google Cloud console or Google Cloud CLI:
ConsoleGo to the Cloud Run jobs page in the Google Cloud console.
Click the job to open the job details.
Click the Configuration tab.
Under Binary Authorization, select a policy from the policy list.
Click Apply to enable Binary Authorization enforcement on the job.
Optional: To configure the Binary Authorization policy, click Configure Policy.
Enable Binary Authorization on the job:
gcloud run jobs update JOB_NAME --binary-authorization=POLICY
Replace the following:
JOB_NAME
: the name of your job.POLICY
: the policy you want to apply. Use the value default
to use the default policy.We recommend that you require Binary Authorization for Cloud Run by configuring an organization policy to do so. Binary Authorization can be disabled by Cloud Run developers if the policy is not configured.
View the policyTo view the policy, click View policy.
For more information, see configuring a Binary Authorization policy.
Service or job deploy failureIf your service or job fails to deploy because it violates the Binary Authorization policy, you might see an error like the following:
Revision REVISION_NAME uses an unauthorized container image. Container image IMAGE_NAME is not authorized by policy.Note: The service or job displays a red exclamation point, but the service continues to serve the previously serving healthy revision.
The error also contains information about why the image violated the policy. In this case, you can use breakglass to bypass policy enforcement and deploy the image.
Note: Using breakglass creates a log entry. View breakglass events in Cloud Audit Logs. Enable Binary Authorization on a new serviceYou can enable Binary Authorization on a new service using the Google Cloud console or Google Cloud CLI:
ConsoleGo to the Cloud Run page:
Click Create service.
In the Create service form :
Select the Verify container deployment with Binary Authorization checkbox.
Note: This checkbox might be disabled if your organization policy is set to require Binary Authorization for Cloud Run.Optional: Click Configure policy to configure the Binary Authorization policy. To learn more about configuring a policy, see Configuring a policy
Deploy the service.
Enable Binary Authorization on the service and deploy it:
gcloud run deploy SERVICE_NAME --image=IMAGE_URL --binary-authorization=default --region=REGION
Replace the following:
SERVICE_NAME
: a name for your service.IMAGE_URL
: the image you want to deploy.REGION
: the region in which you want to deploy your service.You can enable Binary Authorization on a new job using the Google Cloud CLI:
gcloudCreate a new job with Binary Authorization enabled:
gcloud run jobs create JOB_NAME \ --image IMAGE_URL OPTIONS \ --binary-authorization=POLICY \ --region=REGION
Replace the following:
JOB_NAME
: the name of the job you want to create. You can omit this parameter, but you will be prompted for the job name if you omit it.POLICY
: the policy you want to apply. Use the value default
to use the default policy.us-docker.pkg.dev/cloudrun/container/job:latest
.REGION
: the region where this job will run.OPTIONS
: any of the available options described in the Cloud Run job creation page.Wait for the job creation to finish. Upon successful completion, the console displays a success message.
To execute the job, see Execute jobs or execute jobs on a schedule.
When you create a new job, the Cloud Run service agent needs to be able to access the container, which is the case by default.
YAMLCreate a new job.yaml
file with this content:
apiVersion: run.googleapis.com/v1 kind: Job metadata: name: JOB annotations: run.googleapis.com/binary-authorization: POLICY spec: template: spec: containers: - image: IMAGE
Replace the following:
default
Deploy the new job using the following command:
gcloud run jobs replace job.yaml
built-by-cloud-build
attestor to deploy only images built by Cloud Build.Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This guide demonstrates how to enable Binary Authorization for both Cloud Run services and jobs, ensuring only policy-compliant deployments."],["Binary Authorization can be enabled on existing or new Cloud Run services and jobs through the Google Cloud console, gcloud CLI, or YAML configuration."],["When enabled, Binary Authorization enforces deployment policies on any updates or revisions to Cloud Run services and jobs receiving traffic, potentially resulting in deployment failures if policies are violated."],["Users can customize the Binary Authorization policy and apply it, with the option to use a `default` policy, to dictate which container images are authorized for deployment."],["If a deployment violates the Binary Authorization policy, the service or job will display an error, but it continues to serve the previously healthy revision, however, users can bypass policy with breakglass."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4