Skip to content

Commit 2d385b9

Browse files
authored
Merge pull request #850 from l1b0k/kpr
refactor(terway-cli): kube-proxy replacement
2 parents 15fb7aa + e8e97b5 commit 2d385b9

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

cmd/terway-cli/node.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const eniOnlyCNI = `{
3939

4040
const cniFilePath = "/etc/cni/net.d/10-terway.conflist"
4141
const nodeCapabilitiesFile = "/var/run/eni/node_capabilities"
42-
const kubeProxyCapabilitiesFile = "/var/run/kube-proxy/node_capabilities"
4342

4443
type Task struct {
4544
Name string
@@ -204,18 +203,7 @@ func enableKPR(cmd *cobra.Command, args []string) error {
204203
return nil
205204
}
206205

207-
kubeProxy := nodecap.NewFileNodeCapabilities(kubeProxyCapabilitiesFile)
208-
err = kubeProxy.Load()
209-
if err != nil {
210-
return err
211-
}
212-
213-
// depends on kube-proxy
214-
if kubeProxy.Get(nodecap.NodeCapabilityKubeProxyReplacement) == True {
215-
store.Set(nodecap.NodeCapabilityKubeProxyReplacement, True)
216-
} else {
217-
store.Set(nodecap.NodeCapabilityKubeProxyReplacement, False)
218-
}
206+
store.Set(nodecap.NodeCapabilityKubeProxyReplacement, True)
219207

220208
return store.Save()
221209
}

cmd/terway-cli/policy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ func runCilium(cfg *PolicyConfig) error {
225225

226226
if cfg.EnableKPR {
227227
args = append(args, "--kube-proxy-replacement=true")
228+
args = append(args, "--bpf-lb-sock=true")
229+
args = append(args, "--bpf-lb-sock-hostns-only=true")
228230
args = append(args, "--enable-node-port=true")
229231
args = append(args, "--enable-host-port=true")
230232
args = append(args, "--enable-external-ips=true")

hack/init.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ cat $node_capabilities
4646
sysctl -w net.ipv4.conf.eth0.rp_filter=0
4747
modprobe sch_htb || true
4848

49+
if grep -qE '\bkube_proxy_replacement\s*=\s*true\b' "$node_capabilities"; then
50+
mkdir -p 0755 /host/var/run/cilium/cgroupv2
51+
cp -f /bin/cilium-mount /host/opt/cni/bin/cilium-mount
52+
nsenter --cgroup=/host/proc/1/ns/cgroup --mount=/host/proc/1/ns/mnt /opt/cni/bin/cilium-mount /var/run/cilium/cgroupv2;
53+
rm -f /host/opt/cni/bin/cilium-mount
54+
fi
55+
4956
set +o errexit
5057

5158
chroot /host systemctl disable eni.service

0 commit comments

Comments
 (0)