This page describes how to configure an organization policy that requires Binary Authorization enforcement of container images that are deployed to Cloud Run. You can require enforcement for a project, folder, or an organization.
Before you begin
You must have permission to modify
organization policies to set this
constraint. For example, the
orgpolicy.policyAdmin
role has permission to set organization policy constraints. The
resourcemanager.organizationAdmin
role has permission to add a user as an Organization Policy Administrator.
Read the
Using Constraints
page to learn more about managing policies at the organization level.
You can use a custom constraint
to require that Binary Authorization is set to default
at the project
level.
Set the organization policy
This section shows you how to set an organization policy to require Binary Authorization enforcement on images deployed to Cloud Run. You can set the policy using the Google Cloud console or the Google Cloud CLI.
Console
To set the organization policy using Google Cloud console, do the following:
In the Google Cloud console, go to the Organization policies page.
In the Project Selector at the top of the page, do the following:
Select the organization for which you want to set the policy.
You can set the policy at the organization, folder or project level using the folder ID and project ID, respectively. To learn more, see Using constraints.
To complete the selection, click Open.
In Filter, enter the following:
Allowed Binary Authorization Policies (Cloud Run)
To edit the policy details, in Policy details, click Edit.
In Applies to, click Customize.
Make sure Policy type is set to
Allow
.
To set the default Binary Authorization policy that the organization policy requires, do the following:
In Custom values, in the text field, type
default
.The policy value must be set to
default
. Setting the value todefault
configures Binary Authorization to use the policy in the same project as your Cloud Run services.To save this organization policy, click Save.
gcloud
To set the organization policy using gcloud
, do the following:
gcloud resource-manager org-policies allow run.allowedBinaryAuthorizationPolicies \ default \ --organization=ORGANIZATION_ID
Replace ORGANIZATION_ID with the numeric ID of the organization.
You can also apply the organization policy to a folder or a project with the
--folder
or the --project
flags, and the
folder ID
and
project ID,
respectively.
View the organization policy
You can view the organization policy using the Google Cloud console or gcloud
.
Console
In the Google Cloud console, go to the Organization policies page.
In the Project Selector, select the organization for which you want to view the policy.
In Filter, enter the following:
Allowed Binary Authorization Policies (Cloud Run)
To complete the selection, click Open.
You can view the
Allowed Binary Authorization Policies (Cloud Run)
policy configuration.
gcloud
To view the organization policy that requires Binary Authorization for Cloud Run on an organization, enter the following command:
gcloud resource-manager org-policies describe \ run.allowedBinaryAuthorizationPolicies \ --effective \ --organization=ORGANIZATION_ID
Replace ORGANIZATION_ID with the numeric ID of the organization.
Revert the policy
You can revert the policy so that Cloud Run no longer requires
Binary Authorization enforcement using the Google Cloud console or
gcloud
.
Console
To revert the policy using the Google Cloud console, do the following:
In the Google Cloud console, go to the Organization policies page.
In the Project Selector, select the organization for which you want to revert the policy.
In Filter, enter the following:
Allowed Binary Authorization Policies (Cloud Run)
To complete the selection, click Open.
To edit the policy details, in Policy details, click Edit.
In Applies to, select
Inherit parent's policy
.To save the organization policy, click Save.
gcloud
To revert the policy using gcloud
, do the following:
gcloud resource-manager org-policies delete \ run.allowedBinaryAuthorizationPolicies \ --organization=ORGANIZATION_ID
Replace ORGANIZATION_ID with the numeric ID of the organization.
The command returns the following:
Deleted [<Empty>]
Alternatively, you can view the org policy and note that
the Inheritance is set to Inherit
, instead of custom
and there is no
custom value set.
What's next
- Enable Binary Authorization on a Cloud Run service
- Deploy a prebuilt Cloud Run service
- Configure a Binary Authorization policy