Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cilium + macvlan overlay: node can't visit underlay ip of pod #143

Closed
cyclinder opened this issue Jan 10, 2023 · 6 comments
Closed

cilium + macvlan overlay: node can't visit underlay ip of pod #143

cyclinder opened this issue Jan 10, 2023 · 6 comments
Labels
kind/bug Something isn't working

Comments

@cyclinder
Copy link
Collaborator

/kind bug

What happend:

cilium + macvlan overlay: node can't visit underlay ip of pod

What you expected to happen:

cilium + macvlan overlay: node should be visit underlay ip of pod.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

image path and image ID (from 'docker images')

  • Kubernetes version (use kubectl version):
  • Primary CNI for Kubernetes cluster:
  • NetworkAttachment info (use kubectl get net-attach-def -o yaml)
  • Target pod yaml info (with annotation, use kubectl get pod <podname> -o yaml)
@github-actions
Copy link

Hi @cyclinder, Thanks for opening an issue! Please use '/'(for example: /bug) to label this issue.

@github-actions github-actions bot added the kind/bug Something isn't working label Jan 10, 2023
@cyclinder
Copy link
Collaborator Author

wecom-temp-7131bbbbb9656dac84b82aa7546eb6ce

@cyclinder
Copy link
Collaborator Author

cilium 比较严格,不允许非cilium 网卡用 lxc* 转发流量:

https://github.com/cilium/cilium/blob/4c9a6302c9423e821c00930ca00f8eb6a34e9313/bpf/bpf_lxc.c#L1273

@cyclinder
Copy link
Collaborator Author

cyclinder commented Feb 15, 2023

这个issue应有不同的处理方式:

  1. 当缺省CNI为calico时,不做任何修改,这可以正常工作
  2. 当缺省CNI为cilium时:
  • 不要在主机上设置策略路由,这样主机访问该主机上pod的underlay IP就不会从 lxc*网卡转发

优化点,对于router插件:

  1. pod 在访问本节点网卡所有IP时,不需要从 cali* or cilium* 转发, 从缺省CNI的默认路由转发即可

还有一种情况需要考虑:

  • 当 macvlan 的master interface (无论 vlan/non-vlan 接口)配置 IP 时,主机上会有一条直连路由,导致主机访问 pod underlay ip 从master interface 转发,这会访问失败(macvlan bridge mode的机制问题,父子接口不能直接通讯)
  • 当macvlan 的master interface (无论 vlan/non-vlan 接口)不 配置 IP 时,主机访问pod 的 underlay ip,会从主机上的静态路由或者默认路由路由转发,也就是说会绕一圈交换机,只要路由打通,那么通讯是没问题的。

对于sriov来说,不存在 PF 与 VF 之间不能直接通讯,所以 PF 是否配置 IP 都是可行的。但注意: 如果 PF 对接交换机的 Trunk 接口,那么一定不能配置 IP 地址。 如果对接 Access 接口,配置 IP是可选的。

@cyclinder
Copy link
Collaborator Author

总的来说,这里确实有优化的地方:

  1. 不要在主机上设置策略路由,这样主机访问该主机上pod的underlay IP就不会从 lxc*网卡转发
  2. 在 Pod 内不需要添加主机所有 IP 的路由,只需要加一条 kubelet IP 的路由即可。
  3. 增强文档,说明使用姿势。

@cyclinder
Copy link
Collaborator Author

这里通过文档补齐说明了

/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant