Limit Egress with Google Cloud NGFW Standard
This content is authored by Red Hat experts, but has not yet been tested on every supported configuration.
In this guide, we will implement egress restrictions for OpenShift Dedicated by using Google’s Cloud Next Generation Firewall (NGFW) Standard . Cloud NGFW is a fully distributed firewall service that allows fully qualified domain name (FQDN) objects in firewall policy rules. This is necessary for many of the external endpoints that OpenShift Dedicated relies on.
The ability to restrict egress traffic using a firewall or other network device is only supported with OpenShift Dedicated clusters deployed using Google Private Service Connect (not yet generally available). Clusters that do not use Google Private Service Connect require a support exception to use this functionality. For additional assistance, please open a support case .
Prerequisites
- Ensure that you have the
Google Cloud CLI
(
gcloud) installed. - Ensure that you are logged in to the Google Cloud CLI and that you are in the correct project where you plan to deploy OpenShift Dedicated.
- Confirm that you have the minimum necessary permissions in Google Cloud, including:
- Compute Network Admin
- DNS Administrator
- Confirm you have the
networksecurity.googleapis.com,networkservices.googleapis.com, andservicenetworking.googleapis.comservices enabled. To enable them, run the following command:
Environment
Prepare the environment variables:
In this example, we will use us-east1 as the region to deploy into and we will prefix all of our resources with osd-ngfw. We will use the default CIDR ranges for the service and pod networks, and will configure our machine CIDR to be based on our subnet ranges we set below. Modify the parameters to meet your needs.
Create the VPC and Subnets
Before we can deploy a Cloud NGFW, we must first create a VPC and subnets that we will use for OpenShift Dedicated:
- Create the VPC by running the following command:
- Create the worker, control plane, and Private Service Connect subnets by running the following commands:
In this example, we are using subnet ranges of 10.0.0.0/25for the control plane subnet,10.0.2.0/23for the worker subnets, and10.0.0.128/29for the PSC subnet. Modify the parameters to meet your needs. Ensure these values are contained within the machine CIDR you set above.
Deploy a global network firewall policy
Create a global network firewall policy by running the following command:
Associate the newly created global network firewall policy to your VPC you created above by running the following command:
Create a Cloud Router and a Cloud NAT gateway
Reserve an IP address for Cloud NAT by running the following command:
Store the IP address you created above in a variable by running the following command:
Create a Cloud Router by running the following command:
Create a Cloud NAT by running the following command:
Create private DNS records for Private Google Access
Create a private DNS zone for the
googleapis.comdomain by running the following command:Begin a record set transaction by running the following command:
Stage the DNS records for Google APIs under the googleapis.com domain by running the following command:
OpenShift Dedicated relies on the Service Usage API (
serviceusage.googleapis.com) which is not provided by the Private Google Access restricted VIP . To circumvent this, we expose the Service Usage API using the Private Google Access private VIP . This is the only service exposed by the Private Google Access private VIP in this tutorial.Apply the staged record set transaction you started above by running the following command:
Create the Firewall Rules
Create a blanket allow rule for private IP (RFC 1918) address space by running the following command:
Create an allow rule for HTTPS (
tcp/443) domains required for OpenShift Dedicated by running the following command:These domains are sourced from internal documentation. These domains will be published in general documentation when the Private Service Connect feature is released.
Create an allow rule for TCP (
tcp/9997) domains required for OpenShift Dedicated by running the following command:These domains are sourced from internal documentation. These domains will be published in general documentation when the Private Service Connect feature is released.
Create an allow rule for Private Google Access endpoints by running the following command:
Create a blanket deny rule by running the following command:
If there is not a matching rule that allows the traffic, it will be blocked by the firewall. To allow access to other resources, such as internal networks or other external endpoints, create additional rules with a priority of less than 1000. For more information on how to create firewall rules, see the documentation .
You are now ready to deploy your cluster following the OpenShift Dedicated documentation .