Strange internal IP is reported when a worker node has multiple NICs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Kubernetes Control Plane Charm |
Triaged
|
Medium
|
Unassigned | ||
Openstack Integrator Charm |
Triaged
|
Medium
|
Unassigned |
Bug Description
Hi all,
I'm running charmed kubernetes 1.24.1 on top of OpenStack Focal Ussuri. My control-plane node and worker nodes are Juju manual machines. Control plane node has just 1 network interface connected to a Neutron network and it has an IP address from 192.168.150.0/24 subnet. Worker nodes have 4 network interfaces: 1 connected to Neutron overlay network, configured with IP address, 3 active, but not configured.
After deployment is settled (see the bundle attached), from time to time I see the following picture: worker-3 reports internal-ip from the subnet that belongs to a non-configured interface (192.168.140.45) while I expect it to be 192.168.150.53, see below:
$ kubectl get nodes -A -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master-1 Ready <none> 125m v1.24.1 192.168.150.50 <none> Ubuntu 20.04.4 LTS 5.4.0-109-generic containerd://1.5.9
worker-1 Ready <none> 125m v1.24.1 192.168.150.51 <none> Ubuntu 20.04.4 LTS 5.4.0-109-generic containerd://1.5.9
worker-2 Ready <none> 125m v1.24.1 192.168.150.52 <none> Ubuntu 20.04.4 LTS 5.4.0-109-generic containerd://1.5.9
worker-3 Ready <none> 125m v1.24.1 192.168.140.45 <none> Ubuntu 20.04.4 LTS 5.4.0-109-generic containerd://1.5.9
192.168.140.45 is indeed a valid address of the Neutron port from one of the VM's NICs but it is commented out in netplan's config:
$ juju ssh -m k8s kubernetes-worker/2 'grep 192.168.140 /etc/netplan/* -C 2'
--
## routes:
## - to: 0.0.0.0/0
## via: 192.168.140.1
--
## routes:
## - to: 0.0.0.0/0
## via: 192.168.140.1
Connection to 192.168.150.53 closed.
and deconfigured on the host side:
$ juju ssh -m k8s kubernetes-worker/2 ip -4 a s
1: lo: <LOOPBACK,
inet 127.0.0.1/8 scope host lo
2: ens3: <BROADCAST,
inet 192.168.150.53/24 brd 192.168.150.255 scope global dynamic ens3
6: fan-252: <BROADCAST,
inet 252.53.0.1/8 scope global fan-252
10: vxlan.calico: <BROADCAST,
inet 192.168.200.128/32 scope global vxlan.calico
Connection to 192.168.150.53 closed.
I suspect openstack-
$ kubectl edit node worker-3 # similar would be for worker-[12] as well
...
spec:
providerID: openstack:
...
status:
- address: 192.168.140.45
type: InternalIP
- address: 192.168.141.41
type: InternalIP
- address: 192.168.140.46
type: InternalIP
- address: 192.168.150.53 # this is the only correct IP address
type: InternalIP
- address: worker-3
type: Hostname
...
If I then do
$ juju remove-relation -m k8s kubernetes-worker openstack-
then after execution of necessary hooks I get the expected view of the nodes:
$ kubectl get nodes -A -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master-1 Ready <none> 117m v1.24.1 192.168.150.50 <none> Ubuntu 20.04.4 LTS 5.4.0-109-generic containerd://1.5.9
worker-1 Ready <none> 116m v1.24.1 192.168.150.51 <none> Ubuntu 20.04.4 LTS 5.4.0-109-generic containerd://1.5.9
worker-2 Ready <none> 116m v1.24.1 192.168.150.52 <none> Ubuntu 20.04.4 LTS 5.4.0-109-generic containerd://1.5.9
worker-3 Ready <none> 116m v1.24.1 192.168.150.53 <none> Ubuntu 20.04.4 LTS 5.4.0-109-generic containerd://1.5.9
I'm still looking for the root cause for this behavior, please let me know if I'm missing anything here.
Can you run `juju run --unit kubernetes-worker/2 -- network-get kube-control`? This should show you the ingress addresses that the charm sees. The charm chooses the first ingress address and passes that to kubelet via the `--node-ip` config option. I don't think this is the issue, but it would help if you can rule it out.
I suspect you're right that openstack- cloud-controlle r-manager is responsible for adding the other addresses. It looks like this behavior can be controlled in openstack- cloud-controlle r-manager by setting the internal- network- name option[1]. Sadly, our charms don't support this in the generated config[2], so there's no way for you to set it. You won't be able to manually edit the cloud config; cdk-addons will revert your changes every 5 minutes.
I can't think of a good workaround to recommend, but I'm guessing it could be fixed by adding support for the internal- network- name option to our charms. It would probably need to be a config option on the openstack- integrator charm that gets passed through to kubernetes- control- plane.
[1]: https:/ /github. com/kubernetes/ cloud-provider- openstack/ blob/master/ docs/openstack- cloud-controlle r-manager/ using-openstack -cloud- controller- manager. md#networking /github. com/charmed- kubernetes/ layer-kubernete s-common/ blob/1df6fc7fd0 8b14324d993e64f 9b6459020229df0 /lib/charms/ layer/kubernete s_common. py#L550- L606
[2]: https:/