ワンクリックで
kcli
// Comprehensive guide for kcli usage. Use when creating VMs, deploying plans, managing clusters, or performing any kcli operations. Covers all common user workflows.
// Comprehensive guide for kcli usage. Use when creating VMs, deploying plans, managing clusters, or performing any kcli operations. Covers all common user workflows.
Guides deployment and management of Kubernetes clusters with kcli. Use when deploying OpenShift, k3s, kubeadm, or other Kubernetes distributions.
Guides kcli configuration and provider setup. Use when setting up ~/.kcli/config.yml, configuring providers (KVM, AWS, GCP, Azure, etc.), or managing profiles.
Guides creation of kcli plan files for deploying VMs, networks, and infrastructure. Use when writing YAML plans with Jinja2 templating or debugging plan execution issues.
Guides implementation of new virtualization providers for kcli. Use when adding support for a new cloud platform, hypervisor, or infrastructure provider.
Guides testing and code quality for kcli. Use when writing tests, running linting, or validating changes before committing.
Guides VM lifecycle operations with kcli. Use when creating, managing, or troubleshooting virtual machines across providers.
| name | kcli |
| description | Comprehensive guide for kcli usage. Use when creating VMs, deploying plans, managing clusters, or performing any kcli operations. Covers all common user workflows. |
kcli is a unified CLI for managing virtual infrastructure across multiple providers (Libvirt/KVM, AWS, GCP, Azure, vSphere, KubeVirt, OpenStack, oVirt, Proxmox, Hetzner, IBM Cloud).
# VM Operations
kcli create vm -i <image> <name> # Create VM
kcli list vm # List VMs
kcli ssh <name> # SSH into VM
kcli console <name> # Graphical console
kcli start/stop/restart vm <name> # Control VM state
kcli delete vm <name> # Delete VM
# Plans (Infrastructure as Code)
kcli create plan -f plan.yml <name> # Deploy plan
kcli list plan # List plans
kcli delete plan <name> # Delete plan and resources
# Kubernetes Clusters
kcli create kube <type> <name> # Deploy cluster
kcli list kube # List clusters
kcli delete kube <name> # Delete cluster
# Images
kcli list available-images # Show downloadable images
kcli download image <name> # Download cloud image
kcli list image # List local images
# Infrastructure
kcli list network / pool / host # List resources
kcli create network -c <cidr> <name> # Create network
kcli create pool -p <path> <name> # Create storage pool
# From cloud image (downloads if needed)
kcli create vm -i fedora40 myvm
# Shorthand (kcli remembers last VM)
kcli ssh # SSH to last created VM
kcli create vm -i centos9stream \
-P memory=4096 \
-P numcpus=4 \
-P disks=[20,50] \
myvm
| Parameter | Default | Description |
|---|---|---|
numcpus | 2 | Number of CPUs |
memory | 512 | Memory in MB |
disks | [10] | Disk sizes in GB |
nets | [default] | Networks to attach |
pool | default | Storage pool |
cloudinit | true | Enable cloud-init |
start | true | Start VM after creation |
keys | [] | SSH public keys to inject |
cmds | [] | Commands to run at boot |
files | [] | Files to inject |
# With static IP
kcli create vm -i centos9stream \
-P nets=['{"name":"default","ip":"192.168.122.100"}'] \
myvm
# With post-boot commands
kcli create vm -i fedora40 \
-P cmds=['dnf -y install nginx','systemctl enable --now nginx'] \
webserver
# From profile
kcli create vm -p myprofile myvm
# Multiple disks with options
kcli create vm -i ubuntu2204 \
-P disks=['{"size":20}','{"size":100,"pool":"data"}'] \
myvm
# List VMs
kcli list vm # Table format
kcli list vm -o yaml # YAML output
kcli list vm -o json # JSON output
# VM Information
kcli info vm myvm # Full details
kcli info vm myvm -f ip # Just IP address
# State Control
kcli start vm myvm
kcli stop vm myvm
kcli restart vm myvm
# Access
kcli ssh myvm # SSH as default user
kcli ssh -u root myvm # SSH as root
kcli console myvm # VNC/SPICE console
kcli console myvm --serial # Serial console
# Modify
kcli update vm myvm -P memory=8192 # Change memory
kcli update vm myvm -P numcpus=8 # Change CPUs
kcli create disk -s 50 myvm # Add 50GB disk
# Snapshots
kcli create snapshot myvm snap1
kcli list snapshot myvm
kcli revert snapshot myvm snap1
kcli delete snapshot myvm snap1
# Delete
kcli delete vm myvm # With confirmation
kcli delete vm myvm --yes # Skip confirmation
Plans are YAML files with Jinja2 templating for deploying complete environments.
# myplan.yml
parameters:
base_image: centos9stream
domain: lab.local
# Network (created first)
labnet:
type: network
cidr: 192.168.100.0/24
dhcp: true
# VM (uses the network)
webserver:
image: {{ base_image }}
memory: 2048
numcpus: 2
nets:
- labnet
cmds:
- dnf -y install nginx
- systemctl enable --now nginx
# Deploy
kcli create plan -f myplan.yml myplan
# Deploy with parameter overrides
kcli create plan -f myplan.yml -P base_image=fedora40 myplan
# List and manage
kcli list plan
kcli info plan myplan
kcli delete plan myplan # Deletes all resources
# Update existing plan
kcli update plan -f myplan.yml myplan
parameters:
cluster_name: web
node_count: 3
{% for i in range(node_count) %}
{{ cluster_name }}-node-{{ i }}:
image: centos9stream
memory: 2048
nets:
- default
{% endfor %}
| Type | Description |
|---|---|
| (none) | VM (default if no type specified) |
network | Virtual network |
pool | Storage pool |
image | Download image from URL |
profile | Reusable VM template |
container | Container workload |
kube | Kubernetes cluster |
generic / kubeadm - Standard Kubernetesopenshift / okd - OpenShiftk3s - Lightweight K3srke2 - Rancher RKE2microshift - Edge MicroShifthypershift - Hosted control planesaks / eks / gke - Cloud managed# Generic Kubernetes
kcli create kube generic -P ctlplanes=1 -P workers=2 myk8s
# K3s (lightweight)
kcli create kube k3s -P ctlplanes=1 -P workers=2 myk3s
# OpenShift (requires pull secret)
kcli create kube openshift \
-P pull_secret=~/pull-secret.json \
-P ctlplanes=3 \
-P workers=2 \
myocp
# List clusters
kcli list kube
# Get kubeconfig
kcli get kubeconfig mycluster
export KUBECONFIG=~/.kcli/clusters/mycluster/kubeconfig
# Scale workers
kcli scale kube generic -P workers=5 mycluster
# Delete
kcli delete kube mycluster
# List available cloud images
kcli list available-images
# Download image
kcli download image fedora40
kcli download image centos9stream
kcli download image ubuntu2204
# List downloaded images
kcli list image
# Delete image
kcli delete image fedora40
Common images: fedora40, centos9stream, ubuntu2204, rhel9, debian12, rocky9, almalinux9
# Create network
kcli create network -c 192.168.100.0/24 mynet
kcli create network -c 10.0.0.0/24 --dhcp --nat privatenet
# List and delete
kcli list network
kcli info network mynet
kcli delete network mynet
# Create pool
kcli create pool -p /var/lib/libvirt/images default
kcli create pool -p /home/vms myvms
# List and delete
kcli list pool
kcli delete pool myvms
# List configured clients
kcli list client
# Switch default client
kcli switch mykvm
# Use specific client for command
kcli -C aws list vm
kcli -C gcp create vm -i ubuntu2204 myvm
# List VMs from all clients
kcli -C all list vm
# Host information
kcli info host
kcli list host
Profiles are reusable VM templates defined in ~/.kcli/profiles.yml:
# ~/.kcli/profiles.yml
small:
numcpus: 1
memory: 1024
disks:
- 10
webserver:
image: centos9stream
numcpus: 2
memory: 4096
cmds:
- dnf -y install nginx
- systemctl enable --now nginx
Usage:
kcli create vm -p webserver myweb
# Debug mode (verbose output)
kcli -d create vm -i fedora40 myvm
kcli -d list vm
# Check VM details
kcli info vm myvm
# Check cloud-init logs (after SSH)
kcli ssh myvm
cat /var/log/cloud-init.log
# Verify provider connectivity
kcli list host
kcli info host
No IP address: Check DHCP on network, wait for cloud-init
kcli info network default
SSH fails: Verify key injection worked
kcli ssh -l myvm # Show SSH command
Permission denied (libvirt): Add user to groups
sudo usermod -aG qemu,libvirt $(id -un)
newgrp libvirt
~/.kcli/
├── config.yml # Client/provider configuration
├── profiles.yml # VM profiles
├── id_rsa # SSH private key (auto-used)
└── clusters/ # Cluster state files
default:
client: local
local:
type: kvm
host: 127.0.0.1
pool: default
Run kcli without installation:
# With libvirt socket
alias kcli='podman run --rm -it \
-v ~/.kcli:/root/.kcli:z \
-v /var/run/libvirt:/var/run/libvirt:z \
quay.io/karmab/kcli'
# Then use normally
kcli list vm
Last VM shortcut: Many commands work without VM name (uses last created)
kcli ssh # SSH to last VM
kcli console # Console of last VM
Output formats: Most list commands support -o yaml or -o json
Parameter files: Use kcli_parameters.yml alongside plans for defaults
Render plans: Preview templated plans before deploying
kcli render -f myplan.yml
Export VMs: Create images from running VMs
kcli export vm myvm