Ingress Node Firewall Operator in OKD

The Ingress Node Firewall Operator allows administrators to manage firewall configurations at the node level.

Installing the Ingress Node Firewall Operator

As a cluster administrator, you can install the Ingress Node Firewall Operator by using the OKD CLI or the web console.

Installing the Ingress Node Firewall Operator using the CLI

As a cluster administrator, you can install the Operator using the CLI.

Prerequisites

  • You have installed the OpenShift CLI (oc).

  • You have an account with administrator privileges.

Procedure

  1. To create the openshift-ingress-node-firewall namespace, enter the following command:

    1. $ cat << EOF| oc create -f -
    2. apiVersion: v1
    3. kind: Namespace
    4. metadata:
    5. labels:
    6. pod-security.kubernetes.io/enforce: privileged
    7. pod-security.kubernetes.io/enforce-version: v1.24
    8. name: openshift-ingress-node-firewall
    9. EOF
  2. To create an OperatorGroup CR, enter the following command:

    1. $ cat << EOF| oc create -f -
    2. apiVersion: operators.coreos.com/v1
    3. kind: OperatorGroup
    4. metadata:
    5. name: ingress-node-firewall-operators
    6. namespace: openshift-ingress-node-firewall
    7. EOF
  3. Subscribe to the Ingress Node Firewall Operator.

    1. To create a Subscription CR for the Ingress Node Firewall Operator, enter the following command:

      1. $ cat << EOF| oc create -f -
      2. apiVersion: operators.coreos.com/v1alpha1
      3. kind: Subscription
      4. metadata:
      5. name: ingress-node-firewall-sub
      6. namespace: openshift-ingress-node-firewall
      7. spec:
      8. name: ingress-node-firewall
      9. channel: stable
      10. source: redhat-operators
      11. sourceNamespace: openshift-marketplace
      12. EOF
  4. To verify that the Operator is installed, enter the following command:

    1. $ oc get ip -n openshift-ingress-node-firewall

    Example output

    1. NAME CSV APPROVAL APPROVED
    2. install-5cvnz ingress-node-firewall.4.0-202211122336 Automatic true
  5. To verify the version of the Operator, enter the following command:

    1. $ oc get csv -n openshift-ingress-node-firewall

    Example output

    1. NAME DISPLAY VERSION REPLACES PHASE
    2. ingress-node-firewall.4.0-202211122336 Ingress Node Firewall Operator 4.0-202211122336 ingress-node-firewall.4.0-202211102047 Succeeded

Installing the Ingress Node Firewall Operator using the web console

As a cluster administrator, you can install the Operator using the web console.

Prerequisites

  • You have installed the OpenShift CLI (oc).

  • You have an account with administrator privileges.

Procedure

  1. Install the Ingress Node Firewall Operator:

    1. In the OKD web console, click OperatorsOperatorHub.

    2. Select Ingress Node Firewall Operator from the list of available Operators, and then click Install.

    3. On the Install Operator page, under Installed Namespace, select Operator recommended Namespace.

    4. Click Install.

  2. Verify that the Ingress Node Firewall Operator is installed successfully:

    1. Navigate to the OperatorsInstalled Operators page.

    2. Ensure that Ingress Node Firewall Operator is listed in the openshift-ingress-node-firewall project with a Status of InstallSucceeded.

      During installation an Operator might display a Failed status. If the installation later succeeds with an InstallSucceeded message, you can ignore the Failed message.

      If the Operator does not have a Status of InstallSucceeded, troubleshoot using the following steps:

      • Inspect the Operator Subscriptions and Install Plans tabs for any failures or errors under Status.

      • Navigate to the WorkloadsPods page and check the logs for pods in the openshift-ingress-node-firewall project.

      • Check the namespace of the YAML file. If the annotation is missing, you can add the annotation workload.openshift.io/allowed=management to the Operator namespace with the following command:

        1. $ oc annotate ns/openshift-ingress-node-firewall workload.openshift.io/allowed=management

        For single-node OpenShift clusters, the openshift-ingress-node-firewall namespace requires the workload.openshift.io/allowed=management annotation.

Ingress Node Firewall Operator

The Ingress Node Firewall Operator provides ingress firewall rules at a node level by deploying the daemon set to nodes you specify and manage in the firewall configurations. To deploy the daemon set, you create an IngressNodeFirewallConfig custom resource (CR). The Operator applies the IngressNodeFirewallConfig CR to create ingress node firewall daemon set daemon, which run on all nodes that match the nodeSelector.

You configure rules of the IngressNodeFirewall CR and apply them to clusters using the nodeSelector and setting values to “true”.

The Ingress Node Firewall Operator supports only stateless firewall rules.

Network interface controllers (NICs) that do not support native XDP drivers will run at a lower performance.

For OKD 4.14 or later, you must run Ingress Node Firewall Operator on Fedora 9.0 or later.

Deploying Ingress Node Firewall Operator

Prerequisite

  • The Ingress Node Firewall Operator is installed.

Procedure

To deploy the Ingress Node Firewall Operator, create a IngressNodeFirewallConfig custom resource that will deploy the Operator’s daemon set. You can deploy one or multiple IngressNodeFirewall CRDs to nodes by applying firewall rules.

  1. Create the IngressNodeFirewallConfig inside the openshift-ingress-node-firewall namespace named ingressnodefirewallconfig.

  2. Run the following command to deploy Ingress Node Firewall Operator rules:

    1. $ oc apply -f rule.yaml

Ingress Node Firewall configuration object

The fields for the Ingress Node Firewall configuration object are described in the following table:

Table 1. Ingress Node Firewall Configuration object
FieldTypeDescription

metadata.name

string

The name of the CR object. The name of the firewall rules object must be ingressnodefirewallconfig.

metadata.namespace

string

Namespace for the Ingress Firewall Operator CR object. The IngressNodeFirewallConfig CR must be created inside the openshift-ingress-node-firewall namespace.

spec.nodeSelector

string

A node selection constraint used to target nodes through specified node labels. For example:

  1. spec:
  2. nodeSelector:
  3. node-role.kubernetes.io/worker: “”

One label used in nodeSelector must match a label on the nodes in order for the daemon set to start. For example, if the node labels node-role.kubernetes.io/worker and node-type.kubernetes.io/vm are applied to a node, then at least one label must be set using nodeSelector for the daemon set to start.

The Operator consumes the CR and creates an ingress node firewall daemon set on all the nodes that match the nodeSelector.

Ingress Node Firewall Operator example configuration

A complete Ingress Node Firewall Configuration is specified in the following example:

Example Ingress Node Firewall Configuration object

  1. apiVersion: ingressnodefirewall.openshift.io/v1alpha1
  2. kind: IngressNodeFirewallConfig
  3. metadata:
  4. name: ingressnodefirewallconfig
  5. namespace: openshift-ingress-node-firewall
  6. spec:
  7. nodeSelector:
  8. node-role.kubernetes.io/worker: ""

The Operator consumes the CR and creates an ingress node firewall daemon set on all the nodes that match the nodeSelector.

Ingress Node Firewall rules object

The fields for the Ingress Node Firewall rules object are described in the following table:

Table 2. Ingress Node Firewall rules object
FieldTypeDescription

metadata.name

string

The name of the CR object.

interfaces

array

The fields for this object specify the interfaces to apply the firewall rules to. For example, - en0 and - en1.

nodeSelector

array

You can use nodeSelector to select the nodes to apply the firewall rules to. Set the value of your named nodeselector labels to true to apply the rule.

ingress

object

ingress allows you to configure the rules that allow outside access to the services on your cluster.

Ingress object configuration

The values for the ingress object are defined in the following table:

Table 3. ingress object
FieldTypeDescription

sourceCIDRs

array

Allows you to set the CIDR block. You can configure multiple CIDRs from different address families.

Different CIDRs allow you to use the same order rule. In the case that there are multiple IngressNodeFirewall objects for the same nodes and interfaces with overlapping CIDRs, the order field will specify which rule is applied first. Rules are applied in ascending order.

rules

array

Ingress firewall rules.order objects are ordered starting at 1 for each source.CIDR with up to 100 rules per CIDR. Lower order rules are executed first.

rules.protocolConfig.protocol supports the following protocols: TCP, UDP, SCTP, ICMP and ICMPv6. ICMP and ICMPv6 rules can match against ICMP and ICMPv6 types or codes. TCP, UDP, and SCTP rules can match against a single destination port or a range of ports using <start : end-1> format.

Set rules.action to allow to apply the rule or deny to disallow the rule.

Ingress firewall rules are verified using a verification webhook that blocks any invalid configuration. The verification webhook prevents you from blocking any critical cluster services such as the API server or SSH.

Ingress Node Firewall rules object example

A complete Ingress Node Firewall configuration is specified in the following example:

Example Ingress Node Firewall configuration

  1. apiVersion: ingressnodefirewall.openshift.io/v1alpha1
  2. kind: IngressNodeFirewall
  3. metadata:
  4. name: ingressnodefirewall
  5. spec:
  6. interfaces:
  7. - eth0
  8. nodeSelector:
  9. matchLabels:
  10. <ingress_firewall_label_name>: <label_value> (1)
  11. ingress:
  12. - sourceCIDRs:
  13. - 172.16.0.0/12
  14. rules:
  15. - order: 10
  16. protocolConfig:
  17. protocol: ICMP
  18. icmp:
  19. icmpType: 8 #ICMP Echo request
  20. action: Deny
  21. - order: 20
  22. protocolConfig:
  23. protocol: TCP
  24. tcp:
  25. ports: "8000-9000"
  26. action: Deny
  27. - sourceCIDRs:
  28. - fc00:f853:ccd:e793::0/64
  29. rules:
  30. - order: 10
  31. protocolConfig:
  32. protocol: ICMPv6
  33. icmpv6:
  34. icmpType: 128 #ICMPV6 Echo request
  35. action: Deny
1A <label_name> and a <label_value> must exist on the node and must match the nodeselector label and value applied to the nodes you want the ingressfirewallconfig CR to run on. The <label_value> can be true or false. By using nodeSelector labels, you can target separate groups of nodes to apply different rules to using the ingressfirewallconfig CR.

Zero trust Ingress Node Firewall rules object example

Zero trust Ingress Node Firewall rules can provide additional security to multi-interface clusters. For example, you can use zero trust Ingress Node Firewall rules to drop all traffic on a specific interface except for SSH.

A complete configuration of a zero trust Ingress Node Firewall rule set is specified in the following example:

Users need to add all ports their application will use to their allowlist in the following case to ensure proper functionality.

Example zero trust Ingress Node Firewall rules

  1. apiVersion: ingressnodefirewall.openshift.io/v1alpha1
  2. kind: IngressNodeFirewall
  3. metadata:
  4. name: ingressnodefirewall-zero-trust
  5. spec:
  6. interfaces:
  7. - eth1 (1)
  8. nodeSelector:
  9. matchLabels:
  10. <ingress_firewall_label_name>: <label_value> (2)
  11. ingress:
  12. - sourceCIDRs:
  13. - 0.0.0.0/0 (3)
  14. rules:
  15. - order: 10
  16. protocolConfig:
  17. protocol: TCP
  18. tcp:
  19. ports: 22
  20. action: Allow
  21. - order: 20
  22. action: Deny (4)
1Network-interface cluster
2The <label_name> and <label_value> needs to match the nodeSelector label and value applied to the specific nodes with which you wish to apply the ingressfirewallconfig CR.
30.0.0.0/0 set to match any CIDR
4action set to Deny

Viewing Ingress Node Firewall Operator rules

Procedure

  1. Run the following command to view all current rules :

    1. $ oc get ingressnodefirewall
  2. Choose one of the returned <resource> names and run the following command to view the rules or configs:

    1. $ oc get <resource> <name> -o yaml

Troubleshooting the Ingress Node Firewall Operator

  • Run the following command to list installed Ingress Node Firewall custom resource definitions (CRD):

    1. $ oc get crds | grep ingressnodefirewall

    Example output

    1. NAME READY UP-TO-DATE AVAILABLE AGE
    2. ingressnodefirewallconfigs.ingressnodefirewall.openshift.io 2022-08-25T10:03:01Z
    3. ingressnodefirewallnodestates.ingressnodefirewall.openshift.io 2022-08-25T10:03:00Z
    4. ingressnodefirewalls.ingressnodefirewall.openshift.io 2022-08-25T10:03:00Z
  • Run the following command to view the state of the Ingress Node Firewall Operator:

    1. $ oc get pods -n openshift-ingress-node-firewall

    Example output

    1. NAME READY STATUS RESTARTS AGE
    2. ingress-node-firewall-controller-manager 2/2 Running 0 5d21h
    3. ingress-node-firewall-daemon-pqx56 3/3 Running 0 5d21h

    The following fields provide information about the status of the Operator: READY, STATUS, AGE, and RESTARTS. The STATUS field is Running when the Ingress Node Firewall Operator is deploying a daemon set to the assigned nodes.

  • Run the following command to collect all ingress firewall node pods’ logs:

    1. $ oc adm must-gather gather_ingress_node_firewall

    The logs are available in the sos node’s report containing eBPF bpftool outputs at /sos_commands/ebpf. These reports include lookup tables used or updated as the ingress firewall XDP handles packet processing, updates statistics, and emits events.