This document explains core GKE network security concepts, such
as the principle of least privilege, and helps you choose the right tools to
secure your cluster. The primary goals of implementing GKE
network security are workload isolation and secure multi-tenancy. To achieve
these goals, you should apply the principles of least privilege,
defense-in-depth, and use actionable data to inform your security decisions.

In Google Kubernetes Engine (GKE), applying the principle of least privilege to
network traffic means restricting communication to only what is necessary for
your applications to function. By default, the network within a
GKE cluster is open, which means every Pod can communicate with
every other Pod.

GKE now supports a hierarchical approach to network security by
using ClusterNetworkPolicy for administrative-level enforcement across all
namespaces.

This document provides information that Operators,
Networking specialists, and Security specialists need to understand and
implement network security within GKE clusters. For more
information about common roles and example tasks in Google Cloud, see [Common
GKE user roles and
tasks](https://docs.cloud.google.com/kubernetes-engine/enterprise/docs/concepts/roles-tasks).

Before reading this document, verify that you are familiar with the following:

- **GKE networking concepts** : for an overview, see [About
  GKE
  networking](https://docs.cloud.google.com/kubernetes-engine/docs/learn/learn-gke-net-fundamentals).
- **Kubernetes Pods, Services, and namespaces** : these fundamental Kubernetes resources are central to defining network security policies. See the [Kubernetes documentation](https://kubernetes.io/docs/concepts/).
- **The principle of least privilege**: this security principle is a core concept applied throughout this document.

## Goals of GKE network security

GKE network security policies provide fine-grained,
Kubernetes-aware traffic control within your cluster. These policies are a
critical element of your overall security strategy. To implement robust network
security, consider these fundamental principles:

- **Least privilege** : grant systems and services only the minimum privileges required to perform their functions. This principle reduces the potential impact of a compromise. [Kubernetes network
  policies](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy) help you move from a default-open network to one where only necessary connections are allowed.
- **Defense in depth** : layer multiple, independent security controls. A failure in one control does not lead to a total system compromise. For example, you use a [network
  policy](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy) to isolate a database, even if the database itself requires authentication.
- **Actionable data** : base security decisions on data. Threat modeling and risk assessment inform your security posture. Features like [network policy
  logging](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy-logging) provide the data to verify policies and detect potential breaches.

## Choose a network security policy

To choose the right policy, identify the type and scope of the traffic you need
to control.

### Types of traffic

To choose the right policy, consider the source and destination of the traffic
you want to manage:

- **Communication between Pods within the cluster**: to control how
  microservices communicate with each other, use policies that operate on Pod
  labels and namespaces.

  - As an application developer, use the standard Kubernetes [NetworkPolicy](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy.md.txt) to define ingress and egress rules for your application within its namespace.
  - As a cluster administrator, use the standard Kubernetes [ClusterNetworkPolicy](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/configure-cluster-network-policy.md.txt) to enforce mandatory security guardrails (`Admin` tier) or establish zero-trust defaults (`Baseline` tier) across all namespaces. This resource is supported on clusters running GKE version 1.36.1-gke.1067000 or later.
  - As a cluster administrator, use the proprietary [CiliumClusterwideNetworkPolicy](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/configure-cilium-network-policy.md.txt) for specialized cluster-wide traffic control. For new deployments, use the Kubernetes-native `ClusterNetworkPolicy` instead of this proprietary policy.
- **Egress traffic from Pods to external services** : to control egress traffic
  from Pods to external services based on domain names, use
  [FQDNNetworkPolicy](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/fqdn-network-policies.md.txt).
  This policy is useful when the IP addresses of external services are not
  static, because it automatically resolves and updates the allowed IP
  addresses based on DNS.

- **Encryption for all service-to-service traffic** : to help ensure all
  communication between services is encrypted and authenticated, use a service
  mesh. Use [Istio or Anthos Cloud Service Mesh](https://docs.cloud.google.com/service-mesh/docs.md.txt) to implement
  mutual TLS (mTLS), which automatically handles encryption.

### Content security for AI workloads

For AI agents processing external prompts or retrieving sensitive internal data,
standard Layer 4 access controls are often insufficient. To protect these
workloads, you can apply content security and AI guardrails by using the
ServiceExtensionBinding custom resource (GCPExtensionBinding).

By attaching a ServiceExtensionBinding custom resource to the GCPAgentGateway object associated with your ingress Gateway, you can route incoming and outgoing agent traffic
through Google Cloud Model Armor. This lets you perform
real-time data sanitization and block prompt injection attacks before the
request is processed by your agent's reasoning engine.

### Policy evaluation tiers

GKE evaluates network security policies in three hierarchical
tiers.

1. **Admin tier (ClusterNetworkPolicy)** : the highest level of precedence. Use this tier to enforce mandatory security mandates. **Deny** rules in this tier override all other policies. **Accept** rules permit traffic and stop evaluation for that packet.
2. **NetworkPolicy tier**: the tier where developers define application-specific security. Policies include the standard NetworkPolicy, FQDNNetworkPolicy, and CiliumClusterwideNetworkPolicy resources.
3. **Baseline tier (ClusterNetworkPolicy)**: the lowest level of precedence. Use this tier to set default "deny-by-default" guardrails that developers can selectively override in the NetworkPolicy tier.

If no policies match in any tier, GKE defaults to an implicit
"allow all" behavior.

### Summary of policy choices

The following table summarizes which policy to use based on your security goal.

| **Goal** | **Recommended policy** |
|---|---|
| Control traffic between Pods by using labels and namespaces. | [Kubernetes `NetworkPolicy`](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy.md.txt) |
| Control egress traffic to external services by domain name. | [`FQDNNetworkPolicy`](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/fqdn-network-policies.md.txt) |
| Encrypt and authenticate all service-to-service traffic. | [Istio or Anthos Cloud Service Mesh (for mTLS)](https://docs.cloud.google.com/service-mesh/docs.md.txt) |
| Enforce mandatory, non-overridable security guardrails. | [`ClusterNetworkPolicy` (Admin tier)](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/configure-cluster-network-policy.md.txt) |
| Establish default "zero-trust" guardrails that developers can override. | [`ClusterNetworkPolicy` (Baseline tier)](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/configure-cluster-network-policy.md.txt) |
| Configure proprietary cluster-wide policies (not recommended for new deployments). | [`CiliumClusterwideNetworkPolicy`](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/configure-cilium-network-policy.md.txt) |
| Audit and log connections allowed or denied by policies. | [network policy logging](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy-logging.md.txt) (enabled for any policy) |

## Audit and troubleshoot network policies

After implementing network policies, verify that they work as expected and
diagnose any connectivity issues. You can use [Network Policy
Logging](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy-logging) as the primary
tool for this.

When you enable network policy logging, GKE generates a log
record in Cloud Logging for every connection that a network policy allows or
denies. These logs are essential for performing security auditing and
troubleshooting unexpected behavior. Reviewing these logs lets you see the
concrete effects of your rules, confirming that legitimate traffic flows as
expected and that unauthorized traffic is blocked.

Unlike standard policies which are "allow-only," `ClusterNetworkPolicy`
resources support explicit **Deny** actions. If an administrative policy drops
traffic, the log record attributes the denial to the specific policy responsible
for the block.

## What's next

- Learn how to [configure a Kubernetes
  NetworkPolicy](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy).
- Learn how to [control egress traffic using an
  FQDNNetworkPolicy](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/fqdn-network-policies).
- Learn how to [enforce cluster-wide security guardrails using
  ClusterNetworkPolicy](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/configure-cluster-network-policy).
- Learn how to [set up CiliumClusterwideNetworkPolicy for cluster-wide
  rules](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/configure-cilium-network-policy).
- Learn how to [enable network policy
  logging](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/network-policy-logging) to audit your policies.