kubevirt: Cannot Connect to VM over NodePort service after VM restart
Is this a BUG REPORT or FEATURE REQUEST?:
Uncomment only one, leave it on its own line:
/kind bug
/kind enhancement
What happened: Create a VM and a corresponding ssh NodePort Service. Then Restart the VM by deleting the pod. What you expected to happen: After VM starts back up I expected to reconnect to the VM How to reproduce it (as minimally and precisely as possible): Using an ubuntu image, but any image should do. Just create a vm listed on a NodePort then once the vm has started up fully delete the pod and have it start back up. Give it a few minutes then try to ssh into the vm. You should get a connection timeout.
Anything else we need to know?: I am able to see that the vm endpoints are being updated in Kubernetes I am also able to see tcpdump traffic coming into the container, but not making it to the VM. Is it possible the container is not building that network back up correctly when a NodePort is listed as the service type? ubuntu-20.04-minimal-cloudimg-amd64.img
Environment:
- KubeVirt version (use
virtctl version): v0.45.0 - Kubernetes version (use
kubectl version): v1.20.6 - VM or VMI specifications: Can’t copy paste this, but the VM works
- Cloud provider or hardware configuration: Hardware, can’t list specifications
- OS (e.g. from /etc/os-release): Ubuntu is loaded on the hardware
- Kernel (e.g.
uname -a): cannot list - Install tools: the vm is deployed by helm chart, but cannot list
- Others:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 54 (31 by maintainers)
Commits related to this issue
- templates,persistent-storage: configure static mac address Without having static mac address, the VMIs with persistent storage fail to get the same IP address after a reboot. See https://github.com/k... — committed to rhrazdil/cluster-api-provider-kubevirt by deleted user 2 years ago
- templates,persistent-storage: configure static mac address Without having static mac address, the VMIs with persistent storage fail to get the same IP address after a reboot. See https://github.com/k... — committed to rhrazdil/cluster-api-provider-kubevirt by deleted user 2 years ago
- templates,persistent-storage: configure static mac address Without having static mac address, the VMIs with persistent storage fail to get the same IP address after a reboot. See https://github.com/k... — committed to qinqon/cluster-api-provider-kubevirt by deleted user 2 years ago
I think it would be great if we get an out-of-the box improvement for that too, but great to hear that it works for you.
So to wrap this up, the issue was not in NodePort forwarding, nor in the network binding of VMs, but in the fact that the guest received a different MAC than it remembered from the previous run. Would that be correct @mjschmidt? And so the solution for this is one of:
Yes the reason your’s was working is because you were not maintaining VM persistence and each VM was like deploying a new VM
Most of the time it is related to mac address changes on restarts. Many init procedures take the mac address as the device identifier. If it changes, even if the eth name stays the same, they will not treat the eth device as the same again. Setting a mac address on the outside should resolve that, if that is the case. In many cases also a early-boot init script which deletes the mac from config files in the guest helps. Then the init systems normally fall back to the device name (and will then write the new mac into their configs, ugh … 😉 ).
something like this ^