diff --git a/pkg/kubelet/kubelet_network_linux.go b/pkg/kubelet/kubelet_network_linux.go index 613275c57f1..ae7d9235a55 100644 --- a/pkg/kubelet/kubelet_network_linux.go +++ b/pkg/kubelet/kubelet_network_linux.go @@ -31,6 +31,10 @@ import ( ) const ( + // KubeIPTablesHintChain is the chain whose existence in either iptables-legacy + // or iptables-nft indicates which version of iptables the system is using + KubeIPTablesHintChain utiliptables.Chain = "KUBE-IPTABLES-HINT" + // KubeMarkMasqChain is the mark-for-masquerade chain // TODO: clean up this logic in kube-proxy KubeMarkMasqChain utiliptables.Chain = "KUBE-MARK-MASQ" @@ -184,6 +188,13 @@ func (kl *Kubelet) syncNetworkUtil(iptClient utiliptables.Interface) bool { return false } + // Create hint chain so other components can see whether we are using iptables-legacy + // or iptables-nft. + if _, err := iptClient.EnsureChain(utiliptables.TableMangle, KubeIPTablesHintChain); err != nil { + klog.ErrorS(err, "Failed to ensure that iptables hint chain exists") + return false + } + return true }