$ cat << EOF| oc create -f -
apiVersion: v1
kind: Namespace
metadata:
labels:
pod-security.kubernetes.io/enforce: privileged
pod-security.kubernetes.io/enforce-version: v1.24
name: openshift-ingress-node-firewall
EOF
入口节点防火墙 Operator 通过将守护程序集部署到您在防火墙配置中指定和管理的节点,在节点级别提供入口防火墙规则。要部署守护程序集,您需要创建一个IngressNodeFirewallConfig自定义资源 (CR)。Operator 应用IngressNodeFirewallConfig CR 来创建入口节点防火墙守护程序集daemon,该守护程序集在与nodeSelector匹配的所有节点上运行。
您可以配置IngressNodeFirewall CR 的rules,并使用nodeSelector将它们应用于集群,并将值设置为“true”。
|
入口节点防火墙 Operator 只支持无状态防火墙规则。 不支持原生 XDP 驱动的网络接口控制器 (NIC) 将以较低的性能运行。 对于 Red Hat OpenShift Service on AWS 4.14 或更高版本,您必须在 RHEL 9.0 或更高版本上运行入口节点防火墙 Operator。 |
作为集群管理员,您可以使用 Red Hat OpenShift Service on AWS CLI 或 Web 控制台安装入口节点防火墙 Operator。
作为集群管理员,您可以使用 CLI 安装 Operator。
您已安装 OpenShift CLI (oc)。
您拥有具有管理员权限的帐户。
要创建openshift-ingress-node-firewall命名空间,请输入以下命令:
$ cat << EOF| oc create -f -
apiVersion: v1
kind: Namespace
metadata:
labels:
pod-security.kubernetes.io/enforce: privileged
pod-security.kubernetes.io/enforce-version: v1.24
name: openshift-ingress-node-firewall
EOF
要创建OperatorGroup CR,请输入以下命令:
$ cat << EOF| oc create -f -
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: ingress-node-firewall-operators
namespace: openshift-ingress-node-firewall
EOF
订阅入口节点防火墙 Operator。
要为入口节点防火墙 Operator 创建Subscription CR,请输入以下命令:
$ cat << EOF| oc create -f -
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: ingress-node-firewall-sub
namespace: openshift-ingress-node-firewall
spec:
name: ingress-node-firewall
channel: stable
source: redhat-operators
sourceNamespace: openshift-marketplace
EOF
要验证 Operator 是否已安装,请输入以下命令:
$ oc get ip -n openshift-ingress-node-firewall
NAME CSV APPROVAL APPROVED
install-5cvnz ingress-node-firewall..0-202211122336 Automatic true
要验证 Operator 的版本,请输入以下命令:
$ oc get csv -n openshift-ingress-node-firewall
NAME DISPLAY VERSION REPLACES PHASE
ingress-node-firewall..0-202211122336 Ingress Node Firewall Operator .0-202211122336 ingress-node-firewall..0-202211102047 Succeeded
作为集群管理员,您可以使用 Web 控制台安装 Operator。
您已安装 OpenShift CLI (oc)。
您拥有具有管理员权限的帐户。
安装入口节点防火墙 Operator
在 Red Hat OpenShift Service on AWS Web 控制台中,单击**Operators** → **OperatorHub**。
从可用 Operators 列表中选择**入口节点防火墙 Operator**,然后单击**Install**。
在**Install Operator**页面上的**Installed Namespace**下,选择**Operator recommended Namespace**。
单击**Install**。
验证入口节点防火墙 Operator 是否已成功安装
导航到**Operators** → **Installed Operators**页面。
确保**入口节点防火墙 Operator**列在**openshift-ingress-node-firewall**项目中,且**Status**为**InstallSucceeded**。
|
在安装过程中,Operator 可能会显示**Failed**状态。如果安装稍后成功并显示**InstallSucceeded**消息,您可以忽略**Failed**消息。 |
如果 Operator 的**Status**不是**InstallSucceeded**,请使用以下步骤进行故障排除:
检查**Operator Subscriptions**和**Install Plans**选项卡中**Status**下的任何故障或错误。
导航到**Workloads** → **Pods**页面,并检查openshift-ingress-node-firewall项目中 Pod 的日志。
检查 YAML 文件的命名空间。如果注释缺失,您可以使用以下命令向 Operator 命名空间添加注释workload.openshift.io/allowed=management:
$ oc annotate ns/openshift-ingress-node-firewall workload.openshift.io/allowed=management
|
对于单节点 OpenShift 集群, |
已安装入口节点防火墙 Operator。
要部署入口节点防火墙 Operator,请创建一个IngressNodeFirewallConfig自定义资源,该资源将部署 Operator 的守护程序集。您可以通过应用防火墙规则将一个或多个IngressNodeFirewall CRD 部署到节点。
在名为ingressnodefirewallconfig的openshift-ingress-node-firewall命名空间中创建IngressNodeFirewallConfig。
运行以下命令来部署入口节点防火墙 Operator 规则:
$ oc apply -f rule.yaml
下表描述了入口节点防火墙配置对象的字段:
| 字段 | 类型 | 描述 | ||
|---|---|---|---|---|
|
|
CR 对象的名称。防火墙规则对象的名称必须为 |
||
|
|
入口防火墙 Operator CR 对象的命名空间。 |
||
|
|
用于通过指定的节点标签来定位节点的节点选择约束。例如:
|
||
|
|
指定节点入口防火墙 Operator 是否使用 eBPF Manager Operator 来管理 eBPF 程序。此功能是技术预览功能。 有关 Red Hat 技术预览功能支持范围的更多信息,请参见技术预览功能支持范围。 |
|
Operator 使用 CR 并创建在与 |
完整的入口节点防火墙配置在以下示例中指定:
apiVersion: ingressnodefirewall.openshift.io/v1alpha1
kind: IngressNodeFirewallConfig
metadata:
name: ingressnodefirewallconfig
namespace: openshift-ingress-node-firewall
spec:
nodeSelector:
node-role.kubernetes.io/worker: ""
|
Operator 使用 CR 并创建在与 |
下表描述了入口节点防火墙规则对象的字段:
| 字段 | 类型 | 描述 |
|---|---|---|
|
|
CR 对象的名称。 |
|
|
此对象的字段指定要应用防火墙规则的接口。例如, |
|
|
您可以使用 |
|
|
|
ingress对象的取值在下表中定义:
| 字段 | 类型 | 描述 | ||
|---|---|---|---|---|
|
|
允许您设置 CIDR 块。您可以配置来自不同地址族的多个 CIDR。
|
||
|
|
入口防火墙
将
|
完整的入口节点防火墙配置在以下示例中指定
apiVersion: ingressnodefirewall.openshift.io/v1alpha1
kind: IngressNodeFirewall
metadata:
name: ingressnodefirewall
spec:
interfaces:
- eth0
nodeSelector:
matchLabels:
<ingress_firewall_label_name>: <label_value> (1)
ingress:
- sourceCIDRs:
- 172.16.0.0/12
rules:
- order: 10
protocolConfig:
protocol: ICMP
icmp:
icmpType: 8 #ICMP Echo request
action: Deny
- order: 20
protocolConfig:
protocol: TCP
tcp:
ports: "8000-9000"
action: Deny
- sourceCIDRs:
- fc00:f853:ccd:e793::0/64
rules:
- order: 10
protocolConfig:
protocol: ICMPv6
icmpv6:
icmpType: 128 #ICMPV6 Echo request
action: Deny
| 1 | 节点上必须存在<label_name>和<label_value>,并且必须与应用于您希望ingressfirewallconfig CR在其上运行的节点的nodeselector标签和值匹配。<label_value>可以是true或false。通过使用nodeSelector标签,您可以将不同的规则应用于不同的节点组,以使用ingressfirewallconfig CR。 |
零信任入口节点防火墙规则可以为多接口集群提供额外的安全性。例如,您可以使用零信任入口节点防火墙规则来丢弃特定接口上的所有流量,除了SSH流量。
完整的零信任入口节点防火墙规则集配置在以下示例中指定
|
为了确保正常功能,用户需要在以下情况下将应用程序将使用的所有端口添加到允许列表中。 |
apiVersion: ingressnodefirewall.openshift.io/v1alpha1
kind: IngressNodeFirewall
metadata:
name: ingressnodefirewall-zero-trust
spec:
interfaces:
- eth1 (1)
nodeSelector:
matchLabels:
<ingress_firewall_label_name>: <label_value> (2)
ingress:
- sourceCIDRs:
- 0.0.0.0/0 (3)
rules:
- order: 10
protocolConfig:
protocol: TCP
tcp:
ports: 22
action: Allow
- order: 20
action: Deny (4)
| 1 | 网络接口集群 |
| 2 | <label_name>和<label_value>需要与应用于您希望应用ingressfirewallconfig CR 的特定节点的nodeSelector标签和值匹配。 |
| 3 | 0.0.0.0/0 设置为匹配任何CIDR |
| 4 | action设置为Deny |
|
eBPF Manager Operator集成只是一个技术预览功能。技术预览功能不受Red Hat生产服务级别协议 (SLA) 的支持,并且可能功能不完整。Red Hat不建议在生产环境中使用它们。这些功能提供对即将推出的产品功能的早期访问,使客户能够在开发过程中测试功能并提供反馈。 有关 Red Hat 技术预览功能支持范围的更多信息,请参见技术预览功能支持范围。 |
入口节点防火墙使用eBPF程序来实现其一些关键的防火墙功能。默认情况下,这些eBPF程序使用特定于入口节点防火墙的机制加载到内核中。您可以配置入口节点防火墙Operator来使用eBPF Manager Operator来加载和管理这些程序。
启用此集成后,将应用以下限制
如果XDP不可用并且TCX与bpfman不兼容,则入口节点防火墙Operator将使用TCX。
在应用防火墙规则之前,入口节点防火墙Operator守护程序集Pod将保持在ContainerCreating状态。
入口节点防火墙Operator守护程序集Pod以特权模式运行。
入口节点防火墙使用eBPF程序来实现其一些关键的防火墙功能。默认情况下,这些eBPF程序使用特定于入口节点防火墙的机制加载到内核中。
作为集群管理员,您可以配置入口节点防火墙Operator来使用eBPF Manager Operator来加载和管理这些程序,从而增加额外的安全性和可观察性功能。
您已安装 OpenShift CLI (oc)。
您拥有具有管理员权限的帐户。
您已安装入口节点防火墙Operator。
您已安装eBPF Manager Operator。
将以下标签应用于ingress-node-firewall-system命名空间
$ oc label namespace openshift-ingress-node-firewall \
pod-security.kubernetes.io/enforce=privileged \
pod-security.kubernetes.io/warn=privileged --overwrite
编辑名为ingressnodefirewallconfig的IngressNodeFirewallConfig对象,并设置ebpfProgramManagerMode字段
apiVersion: ingressnodefirewall.openshift.io/v1alpha1
kind: IngressNodeFirewallConfig
metadata:
name: ingressnodefirewallconfig
namespace: openshift-ingress-node-firewall
spec:
nodeSelector:
node-role.kubernetes.io/worker: ""
ebpfProgramManagerMode: <ebpf_mode>
其中
<ebpf_mode>:指定入口节点防火墙Operator是否使用eBPF Manager Operator来管理eBPF程序。必须是true或false。如果未设置,则不使用eBPF Manager。
运行以下命令以查看所有当前规则
$ oc get ingressnodefirewall
选择一个返回的<resource>名称,然后运行以下命令以查看规则或配置
$ oc get <resource> <name> -o yaml
运行以下命令列出已安装的入口节点防火墙自定义资源定义 (CRD)
$ oc get crds | grep ingressnodefirewall
NAME READY UP-TO-DATE AVAILABLE AGE
ingressnodefirewallconfigs.ingressnodefirewall.openshift.io 2022-08-25T10:03:01Z
ingressnodefirewallnodestates.ingressnodefirewall.openshift.io 2022-08-25T10:03:00Z
ingressnodefirewalls.ingressnodefirewall.openshift.io 2022-08-25T10:03:00Z
运行以下命令以查看入口节点防火墙Operator的状态
$ oc get pods -n openshift-ingress-node-firewall
NAME READY STATUS RESTARTS AGE
ingress-node-firewall-controller-manager 2/2 Running 0 5d21h
ingress-node-firewall-daemon-pqx56 3/3 Running 0 5d21h
以下字段提供有关Operator状态的信息:READY、STATUS、AGE和RESTARTS。当入口节点防火墙Operator正在将守护程序集部署到分配的节点时,STATUS字段为Running。
运行以下命令收集所有入口防火墙节点Pod的日志
$ oc adm must-gather – gather_ingress_node_firewall
日志可在包含eBPF bpftool输出(位于/sos_commands/ebpf)的sos节点报告中找到。这些报告包括用作入口防火墙XDP处理数据包处理、更新统计信息和发出事件的查找表。