karmab / kcli

Management tool for virtualization and kubernetes platforms
https://kcli.readthedocs.io/en/latest/
Apache License 2.0
502 stars 138 forks source link

[Available parameters for client/profile/plan files] example for the keywords #717

Closed BurlyLuo closed 2 weeks ago

BurlyLuo commented 3 weeks ago

Hello team: can we add an example for the item: https://kcli.readthedocs.io/en/latest/#available-parameters-for-client-profile-plan-files like cpupinning. we only get it's a list. but can't know how to add the parameter. have read the source code but not get the clue. so if we can add an example for each parameter, it will be nice for the beginner.

[root@rowan> kcli]# kcli -d create vm -i centos9stream -P memory=4096 -P numcpus=4 -P disks=[50] -P rootpassword=hive -P nets='[{"name":"brnet","ip":"192.168.2.200","netmask":"24","gateway":"192.168.2.1"},{"name":"vppdpdk5"},{"name":"vppdpdk8"},{"name":"vppdpdk9"}]' -P cmds='["yum -y install nc", "yum -y install net-tools", "yum -y install pciutils", "yum -y install wget", "wget http://192.168.2.100/kvm/tools/lseth -P /usr/bin/" , "chmod +x /usr/bin/lseth" , "yum -y install lrzsz"]' vm1 -s
karmab commented 3 weeks ago

you have a point. In the meantime, you can check in the samples repo, in particular in https://github.com/karmab/kcli-plan-samples/blob/main/cputuning/cpu.yml

BurlyLuo commented 3 weeks ago

From the demo we can see it with yaml format.

cpu:
  memory: 512
  cpumodel: core2duo
  cpuflags:
   - name: arat
     enable: false
   - name: avx2
     enable: true
  numcpus: 2
  nets: 
   - default
  pool: default
  image: centos8stream

but how do we trans to cmds format? and which parameter show the cpuping cpu?
cpuping is really needed for the kvm vm. do we need a pr to triggered the case?

[root@rowan> kcli]# kcli create vm -i centos9stream -P memory=4096 -P numcpus=4 -P cpupinning=['"vcpus": "0-1", hostcpus: "0"'] -P disks=[50] -P rootpassword=hive -P nets='[{"name":"brnet","ip":"192.168.2.200","netmask":"24","gateway":"192.168.2.1"}]' vm1
Deploying vm vm1 from image centos9stream...
vm1 not created because Can't process entry 0 in numa block
[root@rowan> kcli]# 
karmab commented 3 weeks ago

for cpupinning, you have an example at https://github.com/karmab/kcli-plan-samples/blob/main/cputuning/numa.yml I ll add a single sample yaml file with all the parameters showcased.

Regarding using command line, while I dont really recommend it when you have more complex data structures, here's how it would transcribe:

 kcli create vm -i centos9stream -P cpupinning=['{"vcpus": "0-6", "hostcpus": 0}','{"vcpus": 7, "hostcpus": 0}'] -P numcpus=8
BurlyLuo commented 3 weeks ago

for cpupinning, you have an example at https://github.com/karmab/kcli-plan-samples/blob/main/cputuning/numa.yml I ll add a single sample yaml file with all the parameters showcased.

Regarding using command line, while I dont really recommend it when you have more complex data structures, here's how it would transcribe:

 kcli create vm -i centos9stream -P cpupinning=['{"vcpus": "0-6", "hostcpus": 0}','{"vcpus": 7, "hostcpus": 0}'] -P numcpus=8
 kcli create vm -i centos9stream -P cpupinning=['{"vcpus": "0", "hostcpus": "0"}','{"vcpus": "1", "hostcpus": "1"}','{"vcpus": "2", "hostcpus": "2"}','{"vcpus": 3, "hostcpus": 3}'] -P numcpus=4 myvm

yes. agree with you. but if we can set by cmd method, it nice to setup the environment directly rather than maintain a template. What you see is what you get is important and direct. So i still do recommend that we can add one item to place one example for every sub-parameter. i am glad to test the func if needed. https://kcli.readthedocs.io/en/latest/#available-parameters-for-client-profile-plan-files thanks for your efforts about the nice project @karmab .

karmab commented 2 weeks ago

so I addressed that in two ways:

BurlyLuo commented 1 week ago

so I addressed that in two ways:

[root@rowan> LabasCode]# kcli render -f all_parameters.yml -
usage: kcli [-h] [-C CLIENT] [--containerclient CONTAINERCLIENT] [--dnsclient DNSCLIENT] [-d] [-n NAMESPACE] [-o {json,jsoncompact,name,yaml}] [-r REGION] [-z ZONE]
            ...
kcli: error: unrecognized arguments: -
karmab commented 1 week ago

it should be -c

BurlyLuo commented 6 days ago

There is no such option.

[root@rowan> LabasCode]# kcli render -f all_p.yaml -c 
usage: kcli [-h] [-C CLIENT] [--containerclient CONTAINERCLIENT] [--dnsclient DNSCLIENT] [-d] [-n NAMESPACE] [-o {json,jsoncompact,name,yaml}] [-r REGION] [-z ZONE]
            ...
kcli: error: unrecognized arguments: -c
[root@rowan> LabasCode]# 

so I addressed that in two ways:

[root@rowan> LabasCode]# kcli render -f all_parameters.yml -
usage: kcli [-h] [-C CLIENT] [--containerclient CONTAINERCLIENT] [--dnsclient DNSCLIENT] [-d] [-n NAMESPACE] [-o {json,jsoncompact,name,yaml}] [-r REGION] [-z ZONE]
            ...
kcli: error: unrecognized arguments: -
karmab commented 6 days ago

make sure to update kcli, as I've added in a recent commit

BurlyLuo commented 5 days ago

yes, with latest kcli, it works fine. but issue with: kcli create image -P url=

[root@rowan> LabasCode]# kcli download image http://192.168.2.100/Rocky9.qcow2
Image http://192.168.2.100/Rocky9.qcow2 has no associated url
[root@rowan> LabasCode]# kcli create image -P url=https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20210603.0.x86_64.qcow2 myimage
usage: kcli create [-h]  ...
kcli create: error: argument : invalid choice: 'image' (choose from 'app', 'apps', 'operator', 'operators', 'bucket', 'bucket-file', 'clusterprofile', 'cluster-profile', 'kube-profile', 'kubeprofile', 'confpool', 'container', 'dns', 'host', 'client', 'kube', 'cluster', 'lb', 'loadbalancer', 'network', 'net', 'openshift-registry', 'openshift-disconnected', 'openshift-iso', 'openshift-sno', 'plan', 'plan-data', 'plan-template', 'plan-snapshot', 'pool', 'product', 'profile', 'provider', 'repo', 'security-group', 'sg', 'firewall', 'subnet', 'sushy-service', 'sushy', 'ksushy', 'ksushy-service', 'vm', 'vm-data', 'vm-disk', 'disk', 'vm-nic', 'nic', 'vm-snapshot', 'snapshot', 'web-service', 'web', 'workflow')
[root@rowan> LabasCode]# kcli version 
version: 99.0 commit: 9e18d09 2024/09/24 Available Updates: False
[root@rowan> LabasCode]# 
karmab commented 5 days ago

it should be

kcli download image -u http://192.168.2.100/Rocky9.qcow2 rocky9
BurlyLuo commented 4 days ago

it should be

kcli download image -u http://192.168.2.100/Rocky9.qcow2 rocky9
[root@rowan> ~]# kcli download image -u http://192.168.2.100/Rocky9.qcow2 rocky9
usage: kcli [-h] [-C CLIENT] [--containerclient CONTAINERCLIENT] [--dnsclient DNSCLIENT] [-d] [-n NAMESPACE] [-o {json,jsoncompact,name,yaml}] [-r REGION] [-z ZONE]
            ...
kcli: error: unrecognized arguments: -u rocky9
[root@rowan> ~]# 
karmab commented 4 days ago

my bad :)

kcli download image -P url=http://192.168.2.100/Rocky9.qcow2 rocky9
BurlyLuo commented 4 days ago

my bad :)

kcli download image -P url=http://192.168.2.100/Rocky9.qcow2 rocky9

yes.

[root@rowan> images]# kcli download image -P url=http://192.168.2.100/Rocky9.qcow2 rocky9

can we set it into available-images? if yes, we can use such image directly.

[root@rowan> images]# kcli list  available-images
+-----------------+
| Images          |
+-----------------+
| almalinux8      |
| almalinux9      |
| arch            |
| centos7         |
| centos8stream   |
| centos9stream   |
| cirros          |
| debian10        |
| debian11        |
| debian12        |
| fcos            |
| fedora37        |
| fedora38        |
| fedora39        |
| fedora40        |
| fedoralatest    |
| freebsd122      |
| freebsd130      |
| netbsd82        |
| netbsd92        |
| openbsd71       |
| openbsd72       |
| dragonflybsd601 |
| dragonflybsd622 |
| gentoo          |
| opensuse155     |
| opensuse156     |
| rhcos410        |
| rhcos411        |
| rhcos412        |
| rhcos413        |
| rhcos414        |
| rhcos415        |
| rhcos416        |
| rhcoslatest     |
| rhel7           |
| rhel8           |
| rhel9           |
| ubuntu1804      |
| ubuntu2004      |
| ubuntu2204      |
| ubuntu2304      |
| ubuntu2310      |
| ubuntu2404      |
| rockylinux8     |
| rockylinux9     |
+-----------------+
[root@rowan> images]#
karmab commented 4 days ago

it's already there as rockylinux9

BurlyLuo commented 4 days ago

it's already there as rockylinux9

i mean custom image name. which like self_rocky9