Hi Everyone,
I got a message from an avid follower who was wondering how they could access the Kubevirt VM that we setup a few episodes ago. I figured this was a good time to dive into that topic as well.
We will install xrdp (like we did for the Rocky Linux VM) in our Lubuntu kubevirt vm.
sudo apt install xrdp -y
sudo systemctl enable xrdp
sudo systemctl start xrdpBut what now? Kubernetes uses its own internal networking, how can I rdp in from my laptop?
For that we will use a standard Kubernetes services (in this case again we will use nodeport).
We could leverage virtctl but at least with my version it won’t allow me to choose which nodeport and that could then change each time I start and star the vm.
virtctl expose virtualmachine lubuntu-vm -n vms --name rdpsvc --port 3389 --target-port 3389 --type NodePortInstead I will simply create a yaml file and hard code the nodeport.
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: vm-rdp-service
namespace: vms
spec:
type: NodePort
selector:
vmi.kubevirt.io/id: lubuntu-vm
ports:
- name: rdp
protocol: TCP
port: 3389
targetPort: 3389
nodePort: 31389
EOF
The key element in this svc definition is the selector vmi.kubevirt.io/id: lubuntu-vm
That is a label on the pod that is running our VM so the service knows which pod to attach to.
After this we should be able to reach our VM through RDP by only changing the port to 31389
