一键导入
kcli-plan-authoring
// 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 creation of kcli plan files for deploying VMs, networks, and infrastructure. Use when writing YAML plans with Jinja2 templating or debugging plan execution issues.
| name | kcli-plan-authoring |
| description | 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. |
Plans are YAML files with Jinja2 templating. Resources are defined as top-level keys with a type field.
parameters:
param1: value1
param2: value2
resourcename:
type: resourcetype
key1: value1
key2: {{ param1 }}
myvm:
image: fedora40
memory: 4096
numcpus: 2
disks:
- size: 20
- size: 10
pool: otherpool
nets:
- name: default
- name: mynet
ip: 192.168.1.10
netmask: 255.255.255.0
gateway: 192.168.1.1
cmds:
- echo hello > /tmp/test
files:
- path: /etc/myconfig
content: |
key=value
myprofile:
type: profile
image: centos9stream
memory: 2048
numcpus: 2
disks:
- 10
nets:
- default
mynetwork:
type: network
cidr: 192.168.100.0/24
dhcp: true
nat: true
domain: mylab.local
myimage:
type: image
url: https://example.com/image.qcow2
pool: default
mycontainer:
type: container
image: nginx:latest
ports:
- 8080:80
parameters:
cluster_name: mycluster
worker_count: 3
{{ cluster_name }}-master:
image: rhcos
{% for i in range(worker_count) %}
{{ cluster_name }}-worker-{{ i }}:
image: rhcos
{% endfor %}
parameters:
enable_storage: true
myvm:
image: fedora40
{% if enable_storage %}
disks:
- size: 100
{% endif %}
kcli provides custom Jinja2 filters in kvirt/jinjafilters/jinjafilters.py:
Path/File Filters:
basename - Get filename from pathdirname - Get directory from pathdiskpath - Convert to /dev/ path if neededexists - Check if file/path existspwd_path - Handle workdir paths in containersreal_path - Get real/absolute pathread_file - Read file contentsString/Data Filters:
none - Return empty string if Nonetype - Return type name (string, int, dict, list)base64 - Base64 encode valuecertificate - Wrap in BEGIN/END CERTIFICATE if neededcount - Count occurrences of characterKubernetes/Cluster Filters:
kubenodes - Generate node names for clusterdefaultnodes - Generate default node listhas_ctlplane - Check if list has ctlplane/master entriesVersion/Release Filters:
github_version - Get latest version from GitHub releasesmin_ocp_version - Compare OpenShift versions (minimum)max_ocp_version - Compare OpenShift versions (maximum)Network Filters:
local_ip - Get local IP for network interfacenetwork_ip - Get IP from network CIDRipv6_wrap - Wrap IPv6 addresses in bracketsUtility Filters:
kcli_info - Get VM info via kcli commandfind_manifests - Find YAML manifests in directorywait_crd - Generate wait script for CRD creationwait_csv - Generate wait script for CSV readinessfilter_bgp_peers - Filter BGP peer listStandard Jinja2 filters (default, join, upper, lower, etc.) also work
Create kcli_parameters.yml alongside your plan:
cluster_name: prod
worker_count: 5
memory: 8192
Override at runtime:
kcli create plan -f myplan.yml -P worker_count=10 myplan
| Parameter | Default | Description |
|---|---|---|
numcpus | 2 | Number of CPUs |
memory | 512 | Memory in MB |
pool | default | Storage pool |
image | None | Base image name |
nets | [default] | Network list |
disks | [{size:10}] | Disk list |
cmds | [] | Post-boot commands |
files | [] | Files to inject |
keys | [] | SSH public keys |
start | true | Auto-start VM |
cloudinit | true | Enable cloud-init |
# Create plan
kcli create plan -f myplan.yml myplanname
# Create with parameter overrides
kcli create plan -f myplan.yml -P memory=4096 -P image=fedora40 myplanname
# List plans
kcli list plan
# Get plan info
kcli info plan myplanname
# Delete plan (and all its resources)
kcli delete plan myplanname
# Update existing plan
kcli update plan -f myplan.yml myplanname
python -c "import yaml; yaml.safe_load(open('plan.yml'))"{{ }} or {% %}kcli -d create plan -f plan.yml testparameters:
domain: lab.local
base_image: centos9stream
labnetwork:
type: network
cidr: 10.0.0.0/24
dhcp: true
domain: {{ domain }}
webserver:
image: {{ base_image }}
memory: 2048
nets:
- labnetwork
cmds:
- dnf -y install nginx
- systemctl enable --now nginx
database:
image: {{ base_image }}
memory: 4096
disks:
- size: 20
- size: 50
nets:
- labnetwork
cmds:
- dnf -y install postgresql-server
- postgresql-setup --initdb
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 implementation of new virtualization providers for kcli. Use when adding support for a new cloud platform, hypervisor, or infrastructure provider.
Comprehensive guide for kcli usage. Use when creating VMs, deploying plans, managing clusters, or performing any kcli operations. Covers all common user workflows.
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.