Open alexcriss opened 2 months ago
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Not stale.
Hi @alexcriss I'm trying to replicate your issue but I wasn't able to do it. On your setup do you have other services created and only one is getting the issue? Do you have network policies configured?
Hi @rbrtbnfgl,
We have multiple services, all of them are impacted. These services all have ExternalIPs announced by BGP and wwe see traffic failing on those IPs. They are also all target of Network Policies, which allow traffic to said ExternalIPs only by specific IPs.
So yeah, we send traffic to the ExternalIP, and the IPs that the Netowrk Policies allow to send traffic there are not in the ipset that allow traffic at the iptables layer.
Hopefully this helps, I am here for any other question!
Could it be possible related to the network policy defined? How you defined it? I tried using from
and to
and still I'm not getting the missing ipset reference.
The netpol we use has multiple entries, we match on pod selectors and on raw IPs. I am not really sure it matters though, since the IP that is not getting set in the kube-router-svip-prt
has nothing to do with the netpol itself.
A stripped down version of the netpol looks like
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: ingress-nginx-api
namespace: ingress-nginx
spec:
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: monitoring
podSelector:
matchLabels:
app: prometheus
ports:
- port: 12345
protocol: TCP
- from:
- ipBlock:
cidr: a.b.c.d/32
- ipBlock:
cidr: x.y.0.0/16
ports:
- port: 80
protocol: TCP
- port: 443
protocol: TCP
podSelector:
matchLabels:
nginx-ingress: api
policyTypes:
- Ingress
What happened?
I am observing a race condition between the
NetworkPolicyController
and theNetworkServicesController
when updating IPVS entries. The scenario is as follow:kube-router
runs the periodicsyncIpvsFirewall
and adds the ExternalIP to thekube-router-svip-prt
ipset. Here traffic to the ExternalIP coming from other nodes start being ACCEPT-ed byiptables
. At this stage,NetworkServicesController
also adds the ExternalIP to theipSetHandlers
map it maintains in memory.kube-router
runssyncNetworkPolicyChains
. This refreshes ipsets to include IPs contained in NetworkPolicies, starting from the in memory values that theNetworkPolicyController
holds in itsipSetHandlers
.NetworkPolicyController
ipSetHandlers
map doesn't know anything about the ExternalIP that was added by theNetworkServicesController
, and hence it is removed fromkube-router-svip-prt
. Traffic to the ExternalIP gets REJECT-ed by itlables, untilsyncIpvsFirewall
runs again.What did you expect to happen?
The ExternalIPs of services should be added to the
kube-router-svip-prt
ipset and remain there, instead of getting removed and re-added.How can we reproduce the behavior you experienced?
Steps to reproduce the behavior:
a.b.c.d
.kube-router-svip-prt
ipset on the host where the pod started withipset list kube-router-svip-prt | grep -P "a\.b\.c\.d"
kube-router
runssyncIpvsFirewall
and will disappear whenkube-router
runsfullPolicySync
.System Information (please complete the following information)
Kube-Router Version (
kube-router --version
):Running kube-router version v2.1.0-11-gac6b898c, built on 2024-03-18T20:39:38+0100, go1.22.0
Kube-Router Parameters:
Kubernetes Version (
kubectl version
) : 1.27.13Cloud Type: on premise
Kubernetes Deployment Type: custom scripts
Kube-Router Deployment Type: System service
Cluster Size: The cluster test is 10 nodes, prod clusters are around 100 nodes
Logs, other output, metrics
This is what i see in logs (I extracted the relevant parts, the full run is attached)
When ipsets are restored by the
NetworkServicesController
thekube-router-svip-prt
contains87.250.179.246
, while when they are restored by theNetworkPolicyController
87.250.179.246
is missing.I am patching the issue for now by running
ipset.Save()
at each controller before they build their updated version, to make sure the base layer is the current config, instead of the previous inmemory content which might be outdated. kube-router-ipset-race.log