This document includes the best practices and guidelines for Google Cloud services such as Compute Engine, Google Kubernetes Engine (GKE), Pub/Sub, Dataflow, and Cloud Run functions when running workloads on Google Cloud.
Compute controls
These controls apply to compute services.
Define VM instances that can enable IP forwarding
compute.vmCanIpForward
constraint defines the VM instances that can enable IP forwarding. By default, any VM can enable IP forwarding in any virtual network. Specify VM instances using one of the following formats: -
under:organizations/ORGANIZATION_ID -
under:folders/FOLDER_ID -
under:projects/PROJECT_ID -
projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME.
- Organization Policy Service
- Virtual Private Cloud (VPC)
- Compute Engine
constraints/compute.vmCanIpForward
=
-
Your list of VM instances that can enable IP forwarding.
- SC-7
- SC-8
- PR.AC-5.1
- PR.AC-5.2
- PR.DS-2.1
- PR.DS-2.2
- PR.DS-5.1
- PR.PT-4.1
- DE.CM-1.1
- DE.CM-1.2
- DE.CM-1.3
- DE.CM-1.4
Disable VM-nested virtualization
compute.disableNestedVirtualization
boolean constraint disables hardware-accelerated nested virtualization for Compute Engine VMs.- Organization Policy Service
- Virtual Private Cloud (VPC)
- Compute Engine
constraints/compute.disableNestedVirtualization
Is
-
True
- SC-7
- SC-8
- PR.AC-5.1
- PR.AC-5.2
- PR.DS-2.1
- PR.DS-2.2
- PR.DS-5.1
- PR.PT-4.1
- DE.CM-1.1
- DE.CM-1.2
- DE.CM-1.3
- DE.CM-1.4
Restrict external IP addresses on VMs
Unless needed, prevent the creation of Compute Engine instances with public IP addresses. The compute.vmExternalIpAccess
list constraint defines the set of Compute Engine VM instances that can have external IP addresses.
Prevent Compute Engine instances from having external IP addresses to drastically reduce their exposure to the internet. Any instance with an external IP address is immediately discoverable and becomes a direct target for automated scans, brute-force attacks, and attempts to exploit vulnerabilities. Instead, require instances to use private IP addresses and manage access through controlled, authenticated, and logged pathways like the Identity-Aware Proxy (IAP) tunnel or a bastion host.
Adopting this deny-by-default posture is a foundational security best practice that helps minimize your attack surface and enforces a zero-trust approach to your network. This constraint isn't retroactive.
- Organization Policy Service
- Virtual Private Cloud (VPC)
- Compute Engine
constraints/compute.vmExternalIpAccess
=
-
The list of VM instances in your organization that can have external IP addresses.
- SC-7
- SC-8
- PR.AC-5.1
- PR.AC-5.2
- PR.DS-2.1
- PR.DS-2.2
- PR.DS-5.1
- PR.PT-4.1
- DE.CM-1.1
- DE.CM-1.2
- DE.CM-1.3
- DE.CM-1.4
Define permitted external IP addresses for VM instances
The compute.vmExternalIpAccess
list constraint lets you restrict external access to virtual machines by not assigning external IP addresses. Configure this list constraint to deny all external IP addresses to virtual machines.
- Organization Policy Service
- Compute Engine
compute.vmExternalIpAccess
=
-
Deny All
- AC-3
- AC-12
- AC-17
- AC-20
- PR.AC-3.1
- PR.AC-3.2
- PR.AC-4.1
- PR.AC-4.2
- PR.AC-4.3
- PR.AC-6.1
- PR.AC-7.1
- PR.AC-7.2
- PR.PT-3.1
- PR-PT-4.1
Require VPC connector for Cloud Run functions
The cloudfunctions.requireVPCConnector
boolean constraint requires that administrators specify a Serverless VPC Access connector when they deploy a Cloud Run function. When enforced, functions must specify a connector.
- Organization Policy Service
- Cloud Run functions
constraints/cloudfunctions.requireVPCConnector
=
-
True
- SC-7
- SC-8
- PR.AC-5.1
- PR.AC-5.2
- PR.DS-2.1
- PR.DS-2.2
- PR.DS-5.1
- PR.PT-4.1
- DE.CM-1.1
- DE.CM-1.2
- DE.CM-1.3
- DE.CM-1.4
Configure message storage policies
- Set a message storage policy using the Resource Location Restriction (
gcp.resourceLocations) organization policy constraint. - Configure a message storage policy when creating a topic. For example:
gcloud pubsub topics create TOPIC_ID \--message-storage-policy-allowed-regions=REGION1, REGION2
- Organization Policy Service
- Pub/Sub
- AC-3
- AC-17
- AC-20
- PR.AC-3.1
- PR.AC-3.2
- PR.AC-4.1
- PR.AC-4.2
- PR.AC-4.3
- PR.AC-6.1
- PR.PT-3.1
- PR.PT-4.1
Turn off external IP addresses for Dataflow jobs
Turn off external IP addresses for administrative and monitoring tasks that are related to Dataflow jobs. Instead, configure access to your Dataflow worker VMs using SSH.
Enable Private Google Access and specify one of the following options in your Dataflow job:
-
--usePublicIps=falseand--network=NETWORK-NAME -
--subnetwork=SUBNETWORK-NAME
Where:
-
NETWORK-NAME: The name of your Compute Engine network. -
SUBNETWORK-NAME: The name of your Compute Engine subnetwork.
- Compute Engine
- Dataflow
- SC-7
- SC-8
- PR.AC-5.1
- PR.AC-5.2
- PR.DS-2.1
- PR.DS-2.2
- PR.DS-5.1
- PR.PT-4.1
- DE.CM-1.1
- DE.CM-1.2
- DE.CM-1.3
- DE.CM-1.4
Use network tags for firewall rules
Network tags are text attributes that attach to Compute Engine VMs such as Dataflow worker VMs. Network tags let you make VPC network firewall rules and some custom static routes applicable to specific VM instances. Dataflow supports adding network tags to all worker VMs that run a particular Dataflow job.
- Compute Engine
- Dataflow
- SC-7
- SC-8
- PR.AC-5.1
- PR.AC-5.2
- PR.DS-2.1
- PR.DS-2.2
- PR.DS-5.1
- PR.PT-4.1
- DE.CM-1.1
- DE.CM-1.2
- DE.CM-1.3
- DE.CM-1.4
Container controls
These controls apply to containers within GKE.
Restrict control plane access
By default, the Google Kubernetes Engine (GKE) cluster control plane and nodes have internet routable addresses that can be accessed from any IP address. Restrict network access to the control plane by using a DNS-based endpoint and by creating private clusters. The control plane is the management center for a Kubernetes cluster, and exposing it to the internet makes it a prime target for attackers. This configuration makes the control plane private and removes it from the internet.
Restricting control plane access helps ensure that only trusted devices within your organization's private network can manage the cluster, drastically reducing the risk of an external attack.
- GKE
- SC-7
- PR.AC-3.1
Use least-privilege firewall rules
When you create firewall rules, use the principle of least privilege to provide access only for the required purpose. Ensure that your firewall rules don't conflict with the GKE default firewall rules when possible.
- GKE
- AC-3
- AC-4
- AC-17
- SC-7
Use Google Groups for RBAC
Use Google Groups for role-based access control (RBAC), which also lets you integrate with your existing user account management practices, such as revoking access when someone leaves your organization. Google Groups for RBAC helps provide efficient management of cluster access using Identity and Access Management (IAM) and Google Groups, which is suitable for most organizations that use Google Groups.
- Google Kubernetes Engine (GKE)
- AC-2
- PR.AC-1.1
Enable Shielded GKE Nodes
Enable Shielded GKE Nodes for cryptographic verification of the nodes in your cluster. Shielded GKE Nodes provide strong, verifiable node identity and integrity. Enable Shielded GKE Nodes when creating or updating clusters. Where possible, use Shielded GKE Nodes with secure boot to also authenticate the boot components of your node VMs during the boot process. Don't use secure boot if you need third-party unsigned kernel modules.
Shielded GKE Nodes is enabled by default when you create a cluster.
- GKE
- AC-3
- AC-4
- AC-17
- SC-7
Use Container-Optimized OS with containerd runtime
Use Container-Optimized OS to implement a hardened and managed container OS. General-purpose operating systems include many extra programs that aren't needed to run containers and therefore create a larger, unnecessary target for attackers. Container-Optimized OS is a minimal, locked-down operating system that significantly reduces this attack surface by including only what is necessary. As a managed OS, Container-Optimized OS also has security patches that are automatically applied by Google, which help ensure critical vulnerabilities are fixed and reduces your operational workload.
An image that includes Container-Optimized OS with containerd (cos_containerd) has containerd as the main container runtime directly integrated with Kubernetes. containerd is the core runtime component of Docker and is designed to deliver core container functionality for the Kubernetes Container Runtime Interface (CRI). It is significantly less complex than the full Docker daemon, and therefore has a smaller attack surface.
- Container-Optimized OS
- CM-7
- SC-7
- SC-38
- SI-2
- SI-7
- PR.PT-3.1
Use Workload Identity Federation for GKE
Use Workload Identity Federation for GKE to securely authenticate to Google Cloud APIs from Google Kubernetes Engine (GKE) workloads. Workload Identity Federation for GKE provides a simpler and safer alternative to using service account keys.
- GKE
- IA-2
- PR.AC-1.1
Enable GKE Sandbox
Use GKE Sandbox to provide an extra layer of security to help prevent untrusted code from affecting the host kernel on your Google Kubernetes Engine (GKE) cluster nodes. GKE Sandbox enhances workload isolation for untrusted or sensitive workloads, providing an additional layer of protection against container escape attacks.
- GKE
- SC-39
- PR.DS-1.1
Disable the kubelet read-only port
Disable kubelet read-only port 10255 and use the more secure port 10250 instead. Kubernetes doesn't perform any authentication or authorization checks on this port. The kubelet serves the same endpoints on the more secure, authenticated port 10250.
You can only disable the insecure kubelet read-only port in GKE version 1.26.4-gke.500 or later.
- GKE
- AC-3
- SC-7
Use namespace and RBAC to restrict access to cluster resources
Create separate namespaces or clusters for each team and environment to implement least-privilege access to Kubernetes. Assign cost centers and appropriate labels to each namespace for accountability and chargeback. Only give developers the level of access to their namespace that they need to deploy and manage their application, especially in production. Map out the tasks that your users need to undertake against the cluster and define the permissions that they require to do each task.
Assign the appropriate Identity and Access Management (IAM) roles for Google Kubernetes Engine (GKE) to groups and users to provide permissions at the project level and use RBAC to grant permissions on a cluster and namespace level.
- GKE
- IAM
- AC-3
- AC-4
- AC-6
Restrict traffic among pods
By default, all pods in a cluster can communicate with each other. Control pod-to-pod communication as needed for your workloads. Restricting network access to services makes it much more difficult for attackers to move laterally within your cluster, and also offers services some protection against accidental or deliberate denial of service.
There are two ways to control traffic:
- Use Cloud Service Mesh or Istio for load balancing, service authorization, throttling, quota, metrics and more.
- Use Kubernetes network policies. Choose this option if you're looking for the basic access control functionality that's exposed by Kubernetes.
- GKE
- AC-3
- AC-4
- SC-7
Use admission controllers to enforce policies
Admission controllers are plugins that govern and enforce how the cluster is used. Enable them to use some of the more advanced security features of Kubernetes because they are an important part of the defense in depth approach to hardening your cluster. By default, pods in Kubernetes can operate with capabilities beyond what they require. Use admission controls to restrict the pod's capabilities to only those that are required for that workload.
GKE supports numerous controls for restricting your pods to execute with capabilities that are explicitly granted. For example, Policy Controller is available for clusters in fleets. Kubernetes also has the built-in PodSecurity admission controller that lets you enforce the Pod Security Standards in individual clusters. Policy Controller is a feature of GKE that lets you enforce and validate security on GKE clusters at scale by using declarative policies.
- GKE
- CM-2
- CM-3
- CM-6
- CM-7
Restrict the ability for workloads to self-modify
Certain Kubernetes workloads, especially system workloads, have permission to self-modify. For example, some workloads vertically autoscale themselves. While convenient, self-modification can allow an attacker who has already compromised a node to escalate further in the cluster. For example, an attacker could have a workload on the node change itself to run as a more privileged service account that exists in the same namespace.
Don't grant workloads the permission to modify themselves by default. When self-modification is necessary, limit permissions by applying Gatekeeper or Policy Controller constraints, such as NoUpdateServiceAccount from the open source Gatekeeper library, which provides several useful security policies.
When you deploy policies, allow the controllers that manage the cluster lifecycle to bypass the policies. Controllers must make changes to the cluster, such as applying cluster upgrades. For example, if you deploy the NoUpdateServiceAccount policy on GKE, you must set the following parameters in the constraint:
parameters:
allowedGroups:
- system:masters
allowedUsers:
- system:addon-manager
- GKE
- AC-3
- CM-3
- SI-7
Monitor your cluster configurations
Audit your cluster configurations for deviations from your defined settings. Settings covered in these best practices, as well as other common misconfigurations, can be automatically checked using Security Command Center.
- GKE
- Security Command Center
- SI-4
- SI-5
- RA-5
Enforce Binary Authorization
Use Binary Authorization to make sure trusted images are deployed to Google Kubernetes Engine (GKE) and Cloud Run. Binary Authorization helps ensure that only verified and trusted container images can be deployed in your clusters, strengthening software supply chain security.
- GKE
- Binary Authorization
- Cloud Run
constraints/binaryauthorization.requireBinauthz
==
-
True
- SI-7
- PR.DS-6.1
What's next
-
Review data management controls .
-
See more Google Cloud security best practices and guidelines .

