Skip to content
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

How to manage the VM in older version Kubernetes #89

Open
dyoung23 opened this issue Mar 25, 2023 · 17 comments
Open

How to manage the VM in older version Kubernetes #89

dyoung23 opened this issue Mar 25, 2023 · 17 comments

Comments

@dyoung23
Copy link

dyoung23 commented Mar 25, 2023

Hi @fengye87 .I am using virtink v0.13.0 and Kubernetes v1.20.9 which have no --subresource option.
So how I can use it to manage the VM because I can't use kubectl patch vm $VM_NAME --subresource=status --type=merge -p "{\"status\":{\"powerAction\":\"$POWER_ACTION\"}}"

@dyoung23
Copy link
Author

And how can I access a VM from a node out of Kubernetes cluster?

@fengye87
Copy link
Contributor

Hi @dyoung23 , could you try with newer versions of kubectl, for example v1.21.x? There's a chance that this is a limitation of v1.20.x's kubectl, but the API is OK. But that's just my guess. Otherwise, I'm afraid there's no easy way to do this for now.

To access a VM outside the Kubernetes cluster, it's pretty much same as accessing a Pod. You can forward SSH port using kubectl, or using NodePort or LB service to expose SSH port.

@dyoung23
Copy link
Author

@fengye87 Thanks for you reply. I updated my Kubernetes to v1.24.0,so I can manage the vm like Readme and I am looking if the API can manage the VM.
But I try to manage the VM using kubectl patch ... and find that when I Shutdown or Reset the vm,nothing happend,I can still ssh to the vm just get some new events in virtualmachine CRD like that.

Events:
  Type    Reason        Age                  From             Message
  ----    ------        ----                 ----             -------
  Normal  CreatedVMPod  25m                  virt-controller  Created VM Pod "vm-ubuntu-container-rootfs-9rmwk"
  Normal  Paused        8m43s                virt-daemon      Paused VM
  Normal  Resumed       7m53s                virt-daemon      Resumed VM
  Normal  Rebooted      7m9s                 virt-daemon      Rebooted VM
  Normal  PoweredOff    5m32s                virt-daemon      Powered off VM
  Normal  DeletedVMPod  5m32s                virt-controller  Deleted VM Pod "vm-ubuntu-container-rootfs-9rmwk"
  Normal  CreatedVMPod  5m18s                virt-controller  Created VM Pod "vm-ubuntu-container-rootfs-jbpmd"
  Normal  Shutdown      67s (x2 over 2m18s)  virt-daemon      Shutdown VM
  Normal  Reset         14s                  virt-daemon      Reset VM

@fengye87
Copy link
Contributor

@dyoung23 Shutdown is ACPI shutdown, it requires OS's support to work. Reset should work, are you sure nothing happened?

@dyoung23
Copy link
Author

@fengye87 I create a file in my vm and Reset.After that I can still ssh to this vm and see the file.

@fengye87
Copy link
Contributor

@dyoung23 Reset is like force reboot, it will not reset VM's hard disk.

@dyoung23
Copy link
Author

@fengye87 I see.Maybe it be reset really fast,so I can ssh to the vm all the time.

@fengye87
Copy link
Contributor

@dyoung23 If you reset the VM while SSH logged in, it should log you out. Otherwise, there's something wrong with the reset action.

@dyoung23
Copy link
Author

@fengye87 Yes,It really log out

@fengye87
Copy link
Contributor

@dyoung23 Then it means your VM really got reset.

@dyoung23
Copy link
Author

@fengye87 Yes.Thank you.

I thought how to manage VM using API,do we provide an official API or client to access Virtink?

@fengye87
Copy link
Contributor

@dyoung23 Yes, there's a plan to add direct API support for VM power actions. It should arrive in the next release.

@dyoung23
Copy link
Author

Hope the next release coming soon with a officail dashboard better.

@dyoung23
Copy link
Author

@fengye87 I doubt how can I get the vm status using kubectl except from Events which will clear after a long time.

@fengye87
Copy link
Contributor

@dyoung23 The VM's status have a phase field, you can get VM status (like if the VM is running) from this field.

@dyoung23
Copy link
Author

@fengye87 But this phase field is really different with the power action.For example,I pause a vm,I only can get Running status,but I can't know it's paused from the status.

@fengye87
Copy link
Contributor

@dyoung23 Good point. We shall improve this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants