|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/network_security/configuring-egress-firewall-ovn.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: CONCEPT |
| 6 | +[id="nw-egress-firewall-about_{context}"] |
| 7 | += How an egress firewall works in a project |
| 8 | + |
| 9 | +As a cluster administrator, you can use an _egress firewall_ to limit the external hosts that some or all pods can access from within the |
| 10 | +cluster. An egress firewall supports the following scenarios: |
| 11 | + |
| 12 | +- A pod can only connect to internal hosts and cannot initiate connections to |
| 13 | +the public internet. |
| 14 | +- A pod can only connect to the public internet and cannot initiate connections |
| 15 | +to internal hosts that are outside the {product-title} cluster. |
| 16 | +- A pod cannot reach specified internal subnets or hosts outside the {product-title} cluster. |
| 17 | +- A pod can only connect to specific external hosts. |
| 18 | +
|
| 19 | +For example, you can allow one project access to a specified IP range but deny the same access to a different project. Or, you can restrict application developers from updating from Python pip mirrors, and force updates to come only from approved sources. |
| 20 | + |
| 21 | +You configure an egress firewall policy by creating an `EgressFirewall` custom resource (CR). The egress firewall matches network traffic that meets any of the following criteria: |
| 22 | + |
| 23 | +- An IP address range in CIDR format |
| 24 | +- A DNS name that resolves to an IP address |
| 25 | +- A port number |
| 26 | +- A protocol that is one of the following protocols: TCP, UDP, and SCTP |
| 27 | +
|
| 28 | +[id="limitations-of-an-egress-firewall-ovn-k_{context}"] |
| 29 | +== Limitations of an egress firewall |
| 30 | + |
| 31 | +An egress firewall has the following limitations: |
| 32 | + |
| 33 | +* No project can have more than one `EgressFirewall` CR. |
| 34 | + |
| 35 | +* Egress firewall rules do not apply to traffic that goes through routers. Any user with permission to create a `Route` CR object can bypass egress firewall policy rules by creating a route that points to a forbidden destination. |
| 36 | + |
| 37 | +* Egress firewall does not apply to the host network namespace. Pods with host networking enabled are unaffected by egress firewall rules. |
| 38 | + |
| 39 | +* If your egress firewall includes a deny rule for `0.0.0.0/0`, access to your {product-title} API servers is blocked. You must either add allow rules for each IP address or use the `nodeSelector` type allow rule in your egress policy rules to connect to API servers. |
| 40 | ++ |
| 41 | +The following example illustrates the order of the egress firewall rules necessary to ensure API server access: |
| 42 | ++ |
| 43 | +.`EgressFirewall` API server access example |
| 44 | +[source,yaml,subs="attributes+"] |
| 45 | +---- |
| 46 | +apiVersion: k8s.ovn.org/v1 |
| 47 | +kind: EgressFirewall |
| 48 | +metadata: |
| 49 | + name: default |
| 50 | + namespace: <namespace> <1> |
| 51 | +spec: |
| 52 | + egress: |
| 53 | + - to: |
| 54 | + cidrSelector: <api_server_address_range> <2> |
| 55 | + type: Allow |
| 56 | +# ... |
| 57 | + - to: |
| 58 | + cidrSelector: 0.0.0.0/0 <3> |
| 59 | + type: Deny |
| 60 | +---- |
| 61 | ++ |
| 62 | +where: |
| 63 | + |
| 64 | +<namespace>:: Specifies the namespace for the egress firewall. |
| 65 | +<api_server_address_range>:: Specifies the IP address range that includes your {product-title} API servers. |
| 66 | +<cidrSelector>:: Specifies a value of `0.0.0.0/0` to set a global deny rule that prevents access to the {product-title} API servers. |
| 67 | ++ |
| 68 | +To find the IP address for your API servers, run `oc get ep kubernetes -n default`. |
| 69 | ++ |
| 70 | +For more information, see link:https://bugzilla.redhat.com/show_bug.cgi?id=1988324[BZ#1988324]. |
| 71 | + |
| 72 | +* A maximum of one `EgressFirewall` object with a maximum of 8,000 rules can be defined per project. |
| 73 | + |
| 74 | +* If you are using the OVN-Kubernetes network plugin with shared gateway mode in Red{nbsp}Hat OpenShift Networking, return ingress replies are affected by egress firewall rules. If the egress firewall rules drop the ingress reply destination IP, the traffic is dropped. |
| 75 | + |
| 76 | +* In general, using Domain Name Server (DNS) names in your egress firewall policy does not affect local DNS resolution through CoreDNS. However, if your egress firewall policy uses domain names and an external DNS server handles DNS resolution for an affected pod, you must include egress firewall rules that permit access to the IP addresses of your DNS server. |
| 77 | + |
| 78 | +Violating any of these restrictions results in a broken egress firewall for the project. Consequently, all external network traffic is dropped, which can cause security risks for your organization. |
| 79 | + |
| 80 | +An `EgressFirewall` resource is created in the `kube-node-lease`, `kube-public`, `kube-system`, `openshift` and `openshift-` projects. |
| 81 | + |
| 82 | +[id="policy-rule-order-ovn-k_{context}"] |
| 83 | +== Matching order for egress firewall policy rules |
| 84 | + |
| 85 | +OVN-Kubernetes evaluates egress firewall policy rules in the order they are defined in, from first to last. The first rule that matches an egress connection from a pod applies. Any subsequent rules are ignored for that connection. |
| 86 | + |
| 87 | +[id="domain-name-server-resolution-ovn-k_{context}"] |
| 88 | +== How Domain Name Server (DNS) resolution works |
| 89 | + |
| 90 | +If you use DNS names in any of your egress firewall policy rules, proper resolution of the domain names is subject to the following restrictions: |
| 91 | + |
| 92 | +* Domain name updates are polled based on a time-to-live (TTL) duration. By default, the duration is 30 minutes. When the egress firewall controller queries the local name servers for a domain name, if the response includes a TTL and the TTL is less than 30 minutes, the controller sets the duration for that DNS name to the returned value. Each DNS name is queried after the TTL for the DNS record expires. |
| 93 | + |
| 94 | +* The pod must resolve the domain from the same local name servers when necessary. Otherwise the IP addresses for the domain known by the egress firewall controller and the pod can be different. If the IP addresses for a hostname differ, the egress firewall might not be enforced consistently. |
| 95 | + |
| 96 | +* Because the egress firewall controller and pods asynchronously poll the same local name server, the pod might obtain the updated IP address before the egress controller does, which causes a race condition. Due to this current limitation, domain name usage in `EgressFirewall` objects is only recommended for domains with infrequent IP address changes. |
0 commit comments