Not able virctl console or ssh a fedora-vmi.

682 views
Skip to first unread message

Kunal Kushwaha

unread,
Feb 20, 2019, 9:34:17 PM2/20/19
to kubevirt-dev
Hi,

My Kubevirt setup is v0.14.0 on vanilla kubernetes v1.12.2.

I have created vmi with fedora demo image of kubevirt : kubevirt/fedora-cloud-container-disk-demo:latest
the vmi is created successfully and I am able to ping the machine(pod) too.

events too show successful start

  Type    Reason            Age                From                       Message
  ----    ------            ----               ----                       -------
  Normal  SuccessfulCreate  31s                virtualmachine-controller  Created virtual machine pod virt-launcher-vm-fedora-h9njg
  Normal  Created           18s (x3 over 18s)  virt-handler, kube-node    VirtualMachineInstance defined.
  Normal  Started           18s                virt-handler, kube-node    VirtualMachineInstance started.



Now if I try to virtctl console vm-fedora,

[root@kube-master ~]# virtctl console vm-fedora                                                                                                                                               
Successfully connected to vm-fedora console. The escape sequence is ^]

It show above message and then hangs. I am able to exit using ^] keys.
If I try to connect immediately of VM starts, it shows fedora boot messages, but again it hang after that.

Whereas in case of kubevirt/cirros-container-disk-demo image, I am able to virtctl console is successful.

[root@kube-master ~]# virtctl console vm-cirros
Successfully connected to vm-cirros console. The escape sequence is ^]

login as 'cirros' user. default password: 'gocubsgo'. use 'sudo' for root.
vm-cirros login: cirros
Password:


My doubt is: Is anything special requires while creating image to able to console VMI? (which is missing in fedora-image)
- I have created a VM image (apache on Centos7) kunalkushwaha/vm-postgres:latest and migrated to KubeVirt and facing same issue as of fedora image.

Part#2 ssh on fedora-vm.
-----------------------------------
I exposed the port 22 on fedora-vm by adding following entry to yaml file along with network as default pod network.
   
      interfaces:
          - name: default
            bridge: {} # connect through a bridge
            ports:
            - name: ssh
              port: 22



[root@kube-master ~]# kubectl get vmi
NAME               AGE   PHASE     IP          NODENAME
vm-fedora          4m    Running   10.44.0.7   kube-node


Once VM is running, I expose the port using virtctl expose.


[root@kube-master ~]# virtctl expose vmi vm-fedora --port=22 --name=ssh-fedora --type=NodePort
Service ssh-fedora successfully exposed for vmi vm-fedora
[root@kube-master ~]# kubectl get service
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP        7d
ssh-fedora   NodePort    10.101.122.137   <none>        22:30941/TCP   24s


But It fails while trying to ssh.

[root@kube-master ~]# ssh ro...@10.101.122.137 -p 30941
ssh: connect to host 10.101.122.137 port 30941: Connection refused

Also, I Service IP 10.101.122.137 cannot be ping. What I am missing here?


Best Regards,
Kunal


Kunal Kushwaha

unread,
Feb 21, 2019, 1:01:10 AM2/21/19
to kubevirt-dev


Please Ignore the part#2.
I understood the issue. --port flag should be on host not VM's exposed port, whereas --target-port is VM's exposed port.

Roman Mohr

unread,
Feb 21, 2019, 2:10:27 AM2/21/19
to Kunal Kushwaha, kubevirt-dev


Am Do., 21. Feb. 2019, 03:34 hat Kunal Kushwaha <kunal.k...@gmail.com> geschrieben:
Hi,

My Kubevirt setup is v0.14.0 on vanilla kubernetes v1.12.2.

I have created vmi with fedora demo image of kubevirt : kubevirt/fedora-cloud-container-disk-demo:latest
the vmi is created successfully and I am able to ping the machine(pod) too.

events too show successful start

  Type    Reason            Age                From                       Message
  ----    ------            ----               ----                       -------
  Normal  SuccessfulCreate  31s                virtualmachine-controller  Created virtual machine pod virt-launcher-vm-fedora-h9njg
  Normal  Created           18s (x3 over 18s)  virt-handler, kube-node    VirtualMachineInstance defined.
  Normal  Started           18s                virt-handler, kube-node    VirtualMachineInstance started.



Now if I try to virtctl console vm-fedora,

[root@kube-master ~]# virtctl console vm-fedora                                                                                                                                               
Successfully connected to vm-fedora console. The escape sequence is ^]

It show above message and then hangs. I am able to exit using ^] keys.
If I try to connect immediately of VM starts, it shows fedora boot messages, but again it hang after that.

Very likely that the vmi does not boot. Can you check `virtctl vnc`? On the serial console you would only see output, if it actually boots the kernel and if your kernel writes something to the serial device. That is normally the case but could be disabled. 

Best Regards, 
Roman 
--
You received this message because you are subscribed to the Google Groups "kubevirt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubevirt-dev...@googlegroups.com.
To post to this group, send email to kubevi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubevirt-dev/5c353e7a-860a-4c3d-9ab4-807bcd1ea35a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kunal Kushwaha

unread,
Feb 21, 2019, 2:38:39 AM2/21/19
to kubevirt-dev


On Thursday, February 21, 2019 at 4:10:27 PM UTC+9, Roman Mohr wrote:


Am Do., 21. Feb. 2019, 03:34 hat Kunal Kushwaha <kunal.k...@gmail.com> geschrieben:
Hi,

My Kubevirt setup is v0.14.0 on vanilla kubernetes v1.12.2.

I have created vmi with fedora demo image of kubevirt : kubevirt/fedora-cloud-container-disk-demo:latest
the vmi is created successfully and I am able to ping the machine(pod) too.

events too show successful start

  Type    Reason            Age                From                       Message
  ----    ------            ----               ----                       -------
  Normal  SuccessfulCreate  31s                virtualmachine-controller  Created virtual machine pod virt-launcher-vm-fedora-h9njg
  Normal  Created           18s (x3 over 18s)  virt-handler, kube-node    VirtualMachineInstance defined.
  Normal  Started           18s                virt-handler, kube-node    VirtualMachineInstance started.



Now if I try to virtctl console vm-fedora,

[root@kube-master ~]# virtctl console vm-fedora                                                                                                                                               
Successfully connected to vm-fedora console. The escape sequence is ^]

It show above message and then hangs. I am able to exit using ^] keys.
If I try to connect immediately of VM starts, it shows fedora boot messages, but again it hang after that.

Very likely that the vmi does not boot. Can you check `virtctl vnc`? On the serial console you would only see output, if it actually boots the kernel and if your kernel writes something to the serial device. That is normally the case but could be disabled. 


Have not tried VNC, but VMI boots properly.
With my CentOS VM, I am able to ssh, but console hangs.

[root@kube-master ~]# kubectl get vmi
NAME               AGE   PHASE     IP          NODENAME
testvmi-postgres   3h    Running   10.44.0.6   kube-node
[root@kube-master ~]# ssh ro...@10.44.0.6
ro...@10.44.0.6's password:
Last login: Thu Feb 21 15:00:31 2019 from 10.32.0.1
[root@standalone-vm ~]# ls
anaconda-ks.cfg  get-pip.py  httpd.conf.backup  trac-project
[root@standalone-vm ~]# exit
logout
Connection to 10.44.0.6 closed.
[root@kube-master ~]# virtctl console testvmi-postgres
Successfully connected to testvmi-postgres console. The escape sequence is ^]


 

Kunal Kushwaha

unread,
Feb 22, 2019, 3:01:41 AM2/22/19
to kubevirt-dev
Just wanted to confirm, using vnc it is working for fedora and my migrated vm.

Thanks,
Kunal

silentda...@gmail.com

unread,
Feb 4, 2020, 12:22:54 PM2/4/20
to kubevirt-dev
I'm trying to run a web server inside a windows VM and accessing it from my minikube cluster host.

I use virtctl expose

virtctl expose vmi vmi-windows --port=9090 --target-port=80 --name=nginxwebvm --type=NodePort

But when I try a simple curl http://$(minikube ip):9090 I get a connection refused.

Any insight why this doesn't work?

Inside the VM the nginx server is up and working. And I can access it with vnc.

Marc Sluiter

unread,
Feb 5, 2020, 5:11:46 AM2/5/20
to silentda...@gmail.com, kubevirt-dev
On Tue, Feb 4, 2020 at 6:32 PM <silentda...@gmail.com> wrote:
I'm trying to run a web server inside a windows VM and accessing it from my minikube cluster host.

I use virtctl expose

virtctl expose vmi vmi-windows --port=9090 --target-port=80 --name=nginxwebvm --type=NodePort

But when I try a simple curl http://$(minikube ip):9090 I get a connection refused.

Hi,

with --port you specify the port on the cluster internal IP address. For connecting to the node's port from outside the cluster, you need to check which NodePort was assigned to the service (e.g. kubectl get svc nginxwebvm -o=yaml | grep nodePort) and connect to that one.

Hope that helps .

Cheers,

Marc

 

Any insight why this doesn't work?

Inside the VM the nginx server is up and working. And I can access it with vnc.

--
You received this message because you are subscribed to the Google Groups "kubevirt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubevirt-dev...@googlegroups.com.

silentda...@gmail.com

unread,
Feb 5, 2020, 6:52:02 AM2/5/20
to kubevirt-dev


On Wednesday, 5 February 2020 11:11:46 UTC+1, Marc Sluiter wrote:

Hi,

with --port you specify the port on the cluster internal IP address. For connecting to the node's port from outside the cluster, you need to check which NodePort was assigned to the service (e.g. kubectl get svc nginxwebvm -o=yaml | grep nodePort) and connect to that one.

Hope that helps .

Cheers,

Marc

 

Thanks for your input:

This is the info on the service:

NAME         TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)
         AGE
nginxwebvm  
NodePort   10.96.82.179   <none>        9090:31998/TCP   48s


I tried:

curl http://$(minikube ip):31988

And it times out.

Is this what you suggested or did I not understand?


Marc Sluiter

unread,
Feb 5, 2020, 7:02:37 AM2/5/20
to silentda...@gmail.com, kubevirt-dev
That is what I suggested. No clue why it still does not work, need to try it myself later today.
 


--
You received this message because you are subscribed to the Google Groups "kubevirt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubevirt-dev...@googlegroups.com.

silentda...@gmail.com

unread,
Feb 5, 2020, 7:50:47 AM2/5/20
to kubevirt-dev
Do you think that minikube is the issue?

Marc Sluiter

unread,
Feb 6, 2020, 4:09:05 AM2/6/20
to kubevirt-dev
On Wed, Feb 5, 2020 at 1:50 PM <silentda...@gmail.com> wrote:
Do you think that minikube is the issue?

No. I did a quick test with a Fedora VM, in which I installed nginx, and it works.

$ ./virtctl expose vm fedora --name fedora --port 80 --target-port=80 --type=NodePort
Service fedora successfully exposed for vm fedora

$ k get svc fedora -o=yaml
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: "2020-02-06T00:01:52Z"
  name: fedora
  namespace: default
  resourceVersion: "62445"
  selfLink: /api/v1/namespaces/default/services/fedora
  uid: cf26bd8f-b425-4c05-ac27-8fbab21b4a4e
spec:
  clusterIP: 10.96.5.210
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 30405
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    vm: test
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}

$ curl http://$(minikube ip):30405
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.16.1</center>
</body>

Is there a Firewall running in your Windows VM?

 

--
You received this message because you are subscribed to the Google Groups "kubevirt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubevirt-dev...@googlegroups.com.

silentda...@gmail.com

unread,
Feb 6, 2020, 5:26:41 AM2/6/20
to kubevirt-dev
In that case, is it windows specific maybe?
To unsubscribe from this group and stop receiving emails from it, send an email to kubevi...@googlegroups.com.

Marc Sluiter

unread,
Feb 6, 2020, 5:47:20 AM2/6/20
to silentda...@gmail.com, kubevirt-dev
On Thu, Feb 6, 2020 at 11:26 AM <silentda...@gmail.com> wrote:
In that case, is it windows specific maybe?

See last line of my previous message: is there are firewall running in the WIndows VM? I'm not familiar with Windows, and how to open a port :)

 
To unsubscribe from this group and stop receiving emails from it, send an email to kubevirt-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubevirt-dev/a3c1352e-e35e-4f63-a07d-6d48bc9538cf%40googlegroups.com.

silentda...@gmail.com

unread,
Feb 6, 2020, 5:58:37 AM2/6/20
to kubevirt-dev
I am not familiar either hence the issue, and this is the windows server core edition. I also thought about the firewall but I'm not yet sure how to figure that out.

I'm gonna try to find something.

silentda...@gmail.com

unread,
Feb 7, 2020, 4:53:27 AM2/7/20
to kubevirt-dev
Ok, what happened is pretty weird.

It was indeed a firewall issue, after enabling all inbound traffic, nginx works on any port I set it.

BUT when I launch a dotnet core web application, the port redirection doesn't work. It times out.

This is a very odd problem and I don't even know how to debug it.

Thank you for your assitance.

silentda...@gmail.com

unread,
Feb 7, 2020, 5:35:50 AM2/7/20
to kubevirt-dev
Nevermind, dumb mistake from my end, the default binding of dotnet is to localhost, which is why it didn't work. I had to bind it to the network's local ip address to make it work.

Marc Sluiter

unread,
Feb 11, 2020, 4:32:39 AM2/11/20
to silentda...@gmail.com, kubevirt-dev
On Fri, Feb 7, 2020 at 11:36 AM <silentda...@gmail.com> wrote:
Nevermind, dumb mistake from my end, the default binding of dotnet is to localhost, which is why it didn't work. I had to bind it to the network's local ip address to make it work.

Nice, glad you figured it all out and it works now :)

Marc
 

On Friday, 7 February 2020 10:53:27 UTC+1, silentda...@gmail.com wrote:
Ok, what happened is pretty weird.

It was indeed a firewall issue, after enabling all inbound traffic, nginx works on any port I set it.

BUT when I launch a dotnet core web application, the port redirection doesn't work. It times out.

This is a very odd problem and I don't even know how to debug it.

Thank you for your assitance.

--
You received this message because you are subscribed to the Google Groups "kubevirt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubevirt-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages