belgaied2 / harvester-cli

Harvester CLI is a project that aims to provide an opinionated CLI tool to easily manage VMs on Harvester, the promising HCI solution created by Rancher Labs/SUSE
Apache License 2.0
28 stars 9 forks source link

issues when using template with --user-data-file / --user-data-filepath - always uses hostname "ranchergui" and doesn't apply config #36

Open ne0YT opened 1 year ago

ne0YT commented 1 year ago

I tried to deploy a vm like this:

harvester-cli vm create --template ubuntu2204cloudinit caddy --user-data-filepath 002_ubuntu2204_cloudconfig_CADDY.yaml --network-data-filepath 002_ubuntu2204_cloudconfig_CADDY_NETWORK.yaml

it will always set the hostname "ranchergui" even though I defined "caddy".

I also tried using "--user-data-file". and I also tried using ./002_ubuntu2204_cloudconfig_CADDY.yaml (the files are in the same path as I'm in when running the command)

when I use the yaml-data manually and just paste it in the regaridng fields it works without any problem.

ne0YT commented 1 year ago

I built from sources using "go install" in ubuntu 22.04

ne0YT commented 1 year ago

when I check cloudconfig in harvester gui it shows the one from the template. and it alos runs it instea dof replacing it and it also doesn't use the vlaues from --disk-size, --cpus, --memory,

ne0YT commented 1 year ago

the issue also occurs when using the full path to the .yaml -files.

ne0YT commented 1 year ago

@belgaied2 Hey there :) Just wanted to ask if it's going to happen :)

belgaied2 commented 1 year ago

Hi @ne0YT , sorry for not replying since a long time. I have been very busy with my work, and did not spend time on Harvester CLI. So, it looks like my latest implementations did not work correctly. I will try to reproduce this and let you know.

belgaied2 commented 1 year ago

I think I figured out your issue @ne0YT. You are putting the name of the VM too early. In my case, if I do this:

go run main.go vm create --template ubuntu-template:1 hello-world --disk-size 50Gi -c 4 -m 8Gi

Harvester CLI would completely ignore the --disk-size 50Gi -c 4 -m 8Gi and would create in my case a VM with 25Gi disk, 2 CPUs and 4 Gi RAM. However, if I run it with

go run main.go vm create --template ubuntu-template:1 --disk-size 50Gi -c 4 -m 8Gi hello-world-2

image

More information about this, refer to this issue in upstream urfave/cli, which was closed without resolution.

ne0YT commented 1 year ago

hey there. Thank you, it seems to fix that part but smh I cannot use cloudinit with it rn;

harvester-cli vm create --template ubuntu2204cloudinit --user-data-filepath ./004_ubuntu2204_cloudconfig_Nextcloud.yaml --network-data-filepath ./004_ubuntu2204_cloudconfig_Nextcloud_NETWORK.yaml --disk-size 100Gi -c 12 -m 12Gi nextcloud
WARN[0000] You are using a template flag, please be aware that:
Flags: --disk-size, --cpus, --memory, --user-data-* and --network-data-* will override the template.
Any other flag will be IGNORED! 
FATA[0000] admission webhook "virtualmachine-validator.kubevirt.io" denied the request: spec.template.spec.volumes[1].cloudInitNoCloud must have only one userdatasource set., spec.template.spec.volumes[1].cloudInitNoCloud must have only one networkdata source set.

and --namespace only works if the template is in the same namespace too right?

ne0YT commented 1 year ago

@belgaied2 were you able to use "--user-data-*" yourself?

ne0YT commented 1 year ago

@belgaied2 did you test the vm migration part?

ne0YT commented 1 year ago

@belgaied2 hey there will you continue this project, or should I check for another way of interacting using scripts with harvester? maybe you can direct me somewhere :)