knlcli
Overview
knlcli is the command line tool to manage KNL labs.
Installation
Shell completion
knlcli supports bash completion, enable it via following:
Create a lab
knlcli create <labdef.yaml>, this is equivalent to kubectl apply -f <labdef.yaml>.
List existing labs
knlcli show by default list name of existing labs:
knlcli show <labname> -v show lab details:
Access a lab node via shell command
knlcli shell <lab> <node>
- vSIM, VSR, MAG-c, SR-SIM, SRLinux: this command creates a SSH session to the control card (e.g. CPM).
- General VM: this command creates a SSH sesion to the VM
- General pod: this command command trys to execute bash inside the pod
Run a command on a lab node
knlcli exec <lab> <node> "<cmd>" [--username <user>] [--passwd <pass>]
Run a single command on the specified node, print its output, and exit. Unlike shell, this does not open an interactive session. Quote the command when it contains spaces.
| Node type | Transport | CLI / shell | Default credentials |
|---|---|---|---|
| vSIM, VSRI | SSH to CPM | MD-CLI | admin / admin |
| MAG-c | SSH to CPM | Classic CLI | admin / admin |
| SR-SIM | SSH to pod | MD-CLI | admin / admin |
| SRLinux | SSH | SRLinux CLI | admin / NokiaSrl1! |
| General VM | SSH | OS shell | from VM spec (user / password) |
| General pod | kubectl exec | sh -c | none |
--usernameand--passwdoverride the defaults above (same flags asshell).- General pod requires
kubectlon the client machine (same dependency asconsolefor pod types).
Access a lab node via console command
knlcli console <lab> <node>
- vSIM, VSR, MAG-c: this command creates a console session to the control card (e.g. CPM).
- General VM: this command creates a console sesion to the VM
- SR-SIM, SRLinux, general pod: this command command trys to execute bash inside the pod
Remove lab
knlcli remove <lab>: remove the specified labknlcli remove --all: remove all labsNote
Note
Removing a lab won’t remove the perisisten storage of nodes in the lab.
Lab save/load
see Lab save/load
Export General VM disk
knlcli export-disk <lab.yaml> <node> --worker <k8s-node> --host-dir <abs-dir> [-o <file.qcow2>] [--image <helper>]
Export the persistent disk of a General VM node to a qcow2 file on a worker node’s local filesystem. The lab YAML resolves the lab name, namespace, and node type; the disk is read from the CDI PVC in the cluster ({lab}-{node}). A helper pod runs on --worker, converts with qemu-img, and writes the result into --host-dir via a hostPath mount (no stream through the API server).
Prerequisite: the VMI must not be running. Typically remove the lab first (knlcli rm <lab>); the DataVolume/PVC remains after lab deletion. Choose a worker with enough local disk space for the output qcow2.
Collect the file from the worker (for example with scp or by reading the path on that host):
--worker: Kubernetes node name where the helper pod runs and where the file is written (spec.nodeName)--host-dir: absolute directory on that worker; created if missing (hostPathDirectoryOrCreate); mounted at/outin the helper pod-o/--output: output filename under--host-dir(default:<node>.qcow2)--image: helper container image withqemu-img(default:ghcr.io/hujun-open/knlcli-export:latest)
Show lab topology
knlcli topo <lab> displays lab topology in following formats:
- visualization render in ASCII format (this requires installation of D2 command line):
knlcli topo <lab> - D2 file:
knlcli topo <lab> --render=false