Use Cilium to Replace KubeProxy
Why?
kube-proxyusesnetfilter(more specificall,iptables).iptablesis essentially a list of access rules that are transversed sequentially. The more services and endpoints you have, the less performant it is.- Cilium uses
eBPFwith a per-cpu hash table containing all endpoints in the cluster to route traffic, replacingiptablescompletely. - if
kubeProxyReplacement: false, kube-proxy is still operating in the cluster and routing traffic
How to replace kube-proxy
- delete the kube-proxy daemonset
- configure:
kubeProxyReplacement: "true" k8sServiceHost: "<IP address of the KubeAPI service" k8sServicePort: "6443" - After changing the above values, you will need to restart the cilium-agent daemonset
Sticky Sessions
- Cilium supports sticky sessions, so that traffic directed to a pod will have all subsequent requests in the connection sent to that same pod.
Traffic Policies
- Cilium with
kubeProxyReplacementenabled supports both theinternalTrafficPolicyandexternalTrafficPolicytraffic policies - When you set
internalTrafficPolicytolocalCilium forwards internal traffic to endpoints that are on that same node. externalTrafficPolicyis set toclusterby default. In this mode, any node that receives traffic can forward it to any ready backend in the cluster. This maximizes availability but comes with two caveats:- source IP is not preserved
- an additional hop may be added as traffic wonโt necessarily enter the node closest to the backend