MicroShift is Technology Preview software only.
For more information about the support scope of Red Hat Technology Preview software, see Technology Preview Support Scope.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 2. Using a firewall
Firewalls are not required in Red Hat build of MicroShift, but using a firewall can prevent undesired access to the Red Hat build of MicroShift API.
2.1. About network traffic through the firewall Link kopierenLink in die Zwischenablage kopiert!
Firewalld is a networking service that runs in the background and responds to connection requests, creating a dynamic customizable host-based firewall. If you are using Red Hat Enterprise Linux (RHEL) for Edge with Red Hat build of MicroShift, firewalld should already be installed and you just need to configure it. Details are provided in procedures that follow. Overall, you must explicitly allow the following OVN-Kubernetes traffic when the firewalld
service is running:
- CNI pod to CNI pod
- CNI pod to Host-Network pod Host-Network pod to Host-Network pod
- CNI pod
- The Kubernetes pod that uses the CNI network
- Host-Network pod
-
The Kubernetes pod that uses host network You can configure the
firewalld
service by using the following procedures. In most cases, firewalld is part of {rhel} installations. If you do not have firewalld, you can install it with the simple procedure in this section.
Red Hat build of MicroShift pods must have access to the internal CoreDNS component and API servers.
2.2. Installing the firewalld service Link kopierenLink in die Zwischenablage kopiert!
If you are using RHEL for Edge, firewalld should be installed. To use the service, you can simply configure it. The following procedure can be used if you do not have firewalld, but want to use it.
Install and run the firewalld
service for Red Hat build of MicroShift by using the following steps.
Procedure
Optional: Check for firewalld on your system by running the following command:
rpm -q firewalld
$ rpm -q firewalld
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the
firewalld
service is not installed, run the following command:sudo dnf install -y firewalld
$ sudo dnf install -y firewalld
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To start the firewall, run the following command:
sudo systemctl enable firewalld --now
$ sudo systemctl enable firewalld --now
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3. Required firewall settings Link kopierenLink in die Zwischenablage kopiert!
An IP address range for the cluster network must be enabled during firewall configuration. You can use the default values or customize the IP address range. If you choose to customize the cluster network IP address range from the default 10.42.0.0/16
setting, you must also use the same custom range in the firewall configuration.
IP Range | Firewall rule required | Description |
---|---|---|
10.42.0.0/16 | No | Host network pod access to other pods |
169.254.169.1 | Yes | Host network pod access to Red Hat build of MicroShift API server |
The following are examples of commands for settings that are mandatory for firewall configuration:
Example commands
Configure host network pod access to other pods:
sudo firewall-cmd --permanent --zone=trusted --add-source=10.42.0.0/16
$ sudo firewall-cmd --permanent --zone=trusted --add-source=10.42.0.0/16
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure host network pod access to services backed by Host endpoints, such as the Red Hat build of MicroShift API:
sudo firewall-cmd --permanent --zone=trusted --add-source=169.254.169.1
$ sudo firewall-cmd --permanent --zone=trusted --add-source=169.254.169.1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.4. Using optional port settings Link kopierenLink in die Zwischenablage kopiert!
The Red Hat build of MicroShift firewall service allows optional port settings.
Procedure
To add customized ports to your firewall configuration, use the following command syntax:
sudo firewall-cmd --permanent --zone=public --add-port=<port number>/<port protocol>
$ sudo firewall-cmd --permanent --zone=public --add-port=<port number>/<port protocol>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Expand Table 2.2. Optional ports Port(s) Protocol(s) Description 80
TCP
HTTP port used to serve applications through the OpenShift Container Platform router.
443
TCP
HTTPS port used to serve applications through the OpenShift Container Platform router.
5353
UDP
mDNS service to respond for OpenShift Container Platform route mDNS hosts.
30000-32767
TCP
Port range reserved for NodePort services; can be used to expose applications on the LAN.
30000-32767
UDP
Port range reserved for NodePort services; can be used to expose applications on the LAN.
6443
TCP
HTTPS API port for the Red Hat build of MicroShift API.
The following are examples of commands used when requiring external access through the firewall to services running on Red Hat build of MicroShift, such as port 6443 for the API server, for example, ports 80 and 443 for applications exposed through the router.
Example commands
Configuring a port for the Red Hat build of MicroShift API server:
sudo firewall-cmd --permanent --zone=public --add-port=6443/tcp
$ sudo firewall-cmd --permanent --zone=public --add-port=6443/tcp
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configuring ports for applications exposed through the router:
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
$ sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
Copy to Clipboard Copied! Toggle word wrap Toggle overflow sudo firewall-cmd --permanent --zone=public --add-port=443/tcp
$ sudo firewall-cmd --permanent --zone=public --add-port=443/tcp
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.5. Allowing network traffic through the firewall Link kopierenLink in die Zwischenablage kopiert!
You can allow network traffic through the firewall by configuring the IP address range and inserting the DNS server to allow internal traffic from pods through the network gateway.
Procedure
Use one of the following commands to set the IP address range:
Configure the IP address range with default values by running the following command:
sudo firewall-offline-cmd --permanent --zone=trusted --add-source=10.42.0.0/16
$ sudo firewall-offline-cmd --permanent --zone=trusted --add-source=10.42.0.0/16
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the IP address range with custom values by running the following command:
sudo firewall-offline-cmd --permanent --zone=trusted --add-source=<custom IP range>
$ sudo firewall-offline-cmd --permanent --zone=trusted --add-source=<custom IP range>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To allow internal traffic from pods through the network gateway, run the following command:
sudo firewall-offline-cmd --permanent --zone=trusted --add-source=169.254.169.1
$ sudo firewall-offline-cmd --permanent --zone=trusted --add-source=169.254.169.1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.5.1. Applying firewall settings Link kopierenLink in die Zwischenablage kopiert!
To apply firewall settings, use the following one-step procedure:
Procedure
- After you have finished configuring network access through the firewall, run the following command to restart the firewall and apply the settings:
sudo firewall-cmd --reload
$ sudo firewall-cmd --reload
2.6. Verifying firewall settings Link kopierenLink in die Zwischenablage kopiert!
After you have restarted the firewall, you can verify your settings by listing them.
Procedure
To verify rules added in the default public zone, such as ports-related rules, run the following command:
sudo firewall-cmd --list-all
$ sudo firewall-cmd --list-all
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To verify rules added in the trusted zone, such as IP-range related rules, run the following command:
sudo firewall-cmd --zone=trusted --list-all
$ sudo firewall-cmd --zone=trusted --list-all
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.7. Known firewall issue Link kopierenLink in die Zwischenablage kopiert!
-
To avoid breaking traffic flows with a firewall reload or restart, execute firewall commands before starting Red Hat build of MicroShift. The CNI driver in Red Hat build of MicroShift makes use of iptable rules for some traffic flows, such as those using the NodePort service. The iptable rules are generated and inserted by the CNI driver, but are deleted when the firewall reloads or restarts. The absence of the iptable rules breaks traffic flows. If firewall commands have to be executed after Red Hat build of MicroShift is running, manually restart
ovnkube-master
pod in theopenshift-ovn-kubernetes
namespace to reset the rules controlled by the CNI driver.