-
Notifications
You must be signed in to change notification settings - Fork 455
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
[BUG] 集群中存在多个子网和 IP 池时,kubeovn 无法正确识别 attachnet.default.ovn.kubernetes.io/logical_switch: subnet-10-69
为 kubevirt VirtualMachine 分配 IP 地址
#4573
Comments
@hexiaodai 你好! 我是 Dosu,一个可以帮助你解决 bug、回答问题并成为贡献者的机器人。我在这里帮助你,等待人类维护者。 要在集群中存在多个子网和 IP 池时,正确地通过 以下是如何注解 VirtualMachine 的示例: apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
name: my-vm
annotations:
attachnet.default.ovn.kubernetes.io/logical_switch: subnet-10-69
spec:
running: false
template:
metadata:
labels:
kubevirt.io/domain: my-vm
spec:
domain:
devices:
disks:
- disk:
bus: virtio
name: containerdisk
volumes:
- name: containerdisk
containerDisk:
image: kubevirt/cirros-container-disk-demo 在这个示例中,注解 此外,确保子网 func (c *Controller) getPodAttachmentNet(pod *v1.Pod) ([]*kubeovnNet, error) {
// ... existing code ...
subnetName := pod.Annotations[fmt.Sprintf(util.LogicalSwitchAnnotationTemplate, providerName)]
if subnetName == "" {
for _, subnet := range subnets {
if subnet.Spec.Provider == providerName {
subnetName = subnet.Name
break
}
}
}
// ... existing code ...
} 这种配置确保即使在集群中存在多个子网和 IP 池时,VirtualMachine 的 IP 地址分配也会从指定的子网中进行[1][2]。 |
# subnet-10-69-9
apiVersion: kubeovn.io/v1
kind: IPPool
metadata:
name: subnet-10-69-9
spec:
ips:
- 10.69.9.10..10.69.9.240
namespaces:
- default
subnet: subnet-10-69 不同 IPPool 不支持同时绑定同一个 namespace。 |
Issues go stale after 60d of inactivity. Please comment or re-open the issue if you are still interested in getting this issue fixed. |
@zhangzujian 这个限制的原因是啥,有可能去掉么? |
IPPool 并不是为了这种场景设计的,所以没有做支持。 现在有一个 PR 已经在做支持了。 |
Kube-OVN Version
v1.12
Kubernetes Version
v1.25.3
Operation-system/Kernel Version
❯ awk -F '=' '/PRETTY_NAME/ { print $2 }' /etc/os-release
"Ubuntu 22.04.2 LTS"
❯ uname -r
6.8.0-40-generic
Description
集群中存在多个子网和 IP 池时,kubeovn 无法正确识别
attachnet.default.ovn.kubernetes.io/logical_switch: subnet-10-69
为 kubevirt VirtualMachine 分配 IP 地址。Steps To Reproduce
subnet-10-66
和subnet-10-69
子网:subnet-10-66-6
和subnet-10-69-9
IP 地址池,并且分别指定 subnet 字段为subnet-10-66
和 subnet-10-69:attachnet.default.ovn.kubernetes.io/logical_switch: subnet-10-69
virt-launcher-vmpod
kube-ovn-controller
日志,发现它尝试从subnet-10-66-6
IP 地址池中分配 IP(期望状态是从 subnet-10-69-9 IP 池中分配 IP,因为 subnet-10-69-9 IP 池与 subnet-10-69 子网绑定)attachnet.default.ovn.kubernetes.io/logical_switch: subnet-10-69
和attachnet.default.ovn.kubernetes.io/ip_pool: subnet-10-69-9
,IP 分配正常,kubevirt VirtualMachine 正常启动subnet-10-66-9
和subnet-10-69-9
,并且仅指定 kubevirt VirtualMachineattachnet.default.ovn.kubernetes.io/logical_switch: subnet-10-69
,IP 分配正常,kubevirt VirtualMachine 正常启动Current Behavior
集群中同时存在多个子网和 IP 池,kubeovn 无法从通过指定
attachnet.default.ovn.kubernetes.io/logical_switch: subnet-10-69
为 kubevirt VirtualMachine 分配 IP 地址。详见 kube-ovn-controller 日志:
Expected Behavior
集群中同时存在多个子网和 IP 池时,kubeovn 能正确的通过
attachnet.default.ovn.kubernetes.io/logical_switch: subnet-10-69
为 kubevirt VirtualMachine 分配 IP 地址。The text was updated successfully, but these errors were encountered: