Stay organized with collections Save and categorize content based on your preferences.
This page describes how to disable the ingress allow VPC firewall rules that GKE creates for LoadBalancer Services.
Disabling these automatically created firewall rules for LoadBalancer Services can be useful in the following situations:
To disable automatically created firewall rules for LoadBalancer Services, you must specify the --disable-l4-lb-firewall-reconciliation
flag when you create or update a cluster. The --disable-l4-lb-firewall-reconciliation
flag does not affect other automatically created VPC firewall rules, such as those facilitating communication between nodes or those that permit health checks for your Services.
GKE supports disabling the automatic creation of firewall rules for these types of LoadBalancer Services:
You cannot disable the automatic creation of firewall rules for these types of LoadBalancer Services:
Before you start, make sure that you have performed the following tasks:
gcloud components update
. Note: For existing gcloud CLI installations, make sure to set the compute/region
property. If you use primarily zonal clusters, set the compute/zone
instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: One of [--zone, --region] must be supplied: Please specify location
. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.Before you disable automatic creation of VPC firewall rules for LoadBalancer Services in your GKE cluster, work with a Security Admin to develop a strategy for configuring firewall rules manually.
Decide which type of firewall policy to use: a hierarchical firewall policy, a global network firewall policy, or a regional network firewall policy. For steps to create a firewall policy, see:
You can also use VPC firewall rules, which don't use any policy.
Your manually created firewall rules must be ingress allow rules because the implied deny ingress firewall rule prohibits incoming traffic. When you've disabled the automatic creation of VPC firewall rules, incoming traffic won't reach your nodes unless you've created ingress allow firewall rules that match traffic for your LoadBalancer Services.
Depending on the firewall rule's parameters, a single ingress allow firewall rule can apply to one or more LoadBalancer Services. For each ingress allow firewall rule you create, define the following parameters:
Target parameter: Ensure that the firewall rule at least includes all nodes of the cluster that contains the LoadBalancer Services. Supported targets depend on what type of firewall policy a rule is located in or if you're using a VPC firewall rule. For information about the target parameter of a rule in a firewall policy, see Targets.
Protocols and ports: Include all protocols and destination ports used by the LoadBalancer Services to which the firewall rule needs to apply.
Destination parameter: You can employ one of the following strategies for the destination parameter:
kubectl get svc LOADBALANCER_NAME \
-n NAMESPACE_NAME \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}
Source parameter: Specify the sources (for example, IP addresses) used by clients that need to connect to the Load Balancer Serfices to which the firewall rule needs to apply.
For steps to create firewall rules, see:
To ensure that your manually created firewall rules are working correctly, run a Network Intelligence Center (NIC) Connectivity Test. When running the Connectivity Test:
For more information, see Troubleshoot connectivity issues.
This section describes steps to disable the automatic creation of VPC firewall rules for LoadBalancer Services.
Create a new GKE cluster with VPC firewall rules creation disabledTo disable the automatically created VPC firewall rules for LoadBalancer Services in a newly created cluster, create the cluster with the --disable-l4-lb-firewall-reconciliation
flag:
Autopilot:
gcloud container clusters create-auto CLUSTER_NAME \
--disable-l4-lb-firewall-reconciliation \
--cluster-version=VERSION
Standard:
gcloud container clusters create CLUSTER_NAME \
--disable-l4-lb-firewall-reconciliation \
--enable-l4-ilb-subsetting \
--cluster-version=VERSION
Replace the following:
CLUSTER_NAME
: the name of the new cluster.VERSION
: the GKE version.Create an external or internal LoadBalancer Service:
Verify that GKE doesn't create an ingress allow firewall rule for the LoadBalancer Service. (Automatically created ingress allow firewall rules have names of the following form: k8s2-[cluster-id]-[namespace]-[service-name]-[suffixhash]
).
The following command returns a list of firewall rules that contain k8s2
:
gcloud compute firewall-rules list --format="value(name)" | grep "k8s2"
The response should return only the health check firewall rule of the form k8s2-[cluster-id]-[namespace]-[service-name]-[suffixhash]-fw
if the externalTrafficPolicy
parameter is set to Local
. It uses the TCP port defined by the spec.healthCheckNodePort
parameter. If unspecified, the Kubernetes control plane assigns a health check port from the node port range.
k8s2-rkdld6go-default-ilb-svc-dluvsefq-fw default INGRESS 1000 tcp:30868 False
If the externalTrafficPolicy
parameter is set to Cluster
, the following health check firewall rule is returned instead.
k8s2-rkdld6go-l4-shared-hc-fw default INGRESS 1000 tcp:10256 False
For more information about generated firewall rules for GKE Services, see Automatically created firewall rules.
Before disabling VPC firewall rules creation, note the following points about updating an existing cluster:
--enable-l4-lb-firewall-reconciliation
flag with the gcloud_name container clusters update
command.To disable the automatic firewall rule creation on an existing cluster:
Update the cluster to disable the automatic creation and management of firewall rules for LoadBalancer Services:
gcloud container clusters update CLUSTER_NAME \
--disable-l4-lb-firewall-reconciliation \
--cluster-version=supported_version
Replace the following:
CLUSTER_NAME
: the name of the new cluster.VERSION
: the GKE version.Create an external or internal LoadBalancer Service:
Verify that GKE doesn't create an ingress allow firewall rule for the LoadBalancer Service. (Automatically created ingress allow firewall rules have names of the following form: k8s2-[cluster-id]-[namespace]-[service-name]-[suffixhash]
).
The following command returns a list of firewall rules that contain k8s2
:
gcloud compute firewall-rules list --format="value(name)" | grep "k8s2"
The response should return only the health check firewall rule of the form k8s2-[cluster-id]-[namespace]-[service-name]-[suffixhash]-fw
if the externalTrafficPolicy
parameter is set to Local
. It uses the TCP port defined by the spec.healthCheckNodePort
parameter. If unspecified, the Kubernetes control plane assigns a health check port from the node port range.
k8s2-rkdld6go-default-ilb-svc-dluvsefq-fw default INGRESS 1000 tcp:30868 False
If the externalTrafficPolicy
parameter is set to Cluster
, the following health check firewall rule is returned instead.
k8s2-rkdld6go-l4-shared-hc-fw default INGRESS 1000 tcp:10256 False
For more information about generated firewall rules for GKE Services, see Automatically created firewall rules.
The following examples illustrate how to use Network Intelligence Center Connectivity Tests to test connectivity to an external LoadBalancer Service:cluster:
Network Intelligence Center:
The gcloud CLI:
The following example command creates and runs a test with your local workstation's public IP address as the source and the external load balancer's external IP address as the destination:
gcloud network-management connectivity-tests create TEST_NAME \
--source-ip-address=SOURCE_IP_ADDRESS \
--source-network-type=NON_GCP_NETWORK \
--destination-ip-address=$(kubectl get svc LOADBALANCER_NAME -o jsonpath='{.status.loadBalancer.ingress[0].ip}') \
--destination-port=$(kubectl get svc LOADBALANCER_NAME -o jsonpath='{.spec.ports[0].targetPort}') \
--destination-network=projects/PROJECT_ID/global/networks/NETWORK_NAME
Replace the following:
TEST_NAME
: A name for the connectivity test.SOURCE_IP_ADDRESS
: The IP address of the system that needs to connect to the external LoadBalancer Service. For exampleLOADBALANCER_NAME
: The name of the external LoadBalancer Service.PROJECT_ID
: The project ID of the project that contains the cluster's VPC network. If your cluster uses a Shared VPC network, use the project ID of the host project.NETWORK_NAME
: The name of your cluster's VPC network.Check test results:
gcloud network-management connectivity-tests describe TEST_NAME
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-12 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-12 UTC."],[],[]]
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