Preset format¶
A preset is a JSON file listing components and their field values. It is read by kikx setup and kikx apply, and written and read by the dashboard. kikx also ships built-in templates in this format. Schema source: backend/core/src/presets/manifest.rs.
The dashboard names the file <project name>.kikx-preset.json, or kikx-project.kikx-preset.json when the project has no name. The CLI accepts any file name.
Location¶
A reference is checked in this order:
Reference |
Loaded from |
|---|---|
Name of a built-in template |
The template embedded in |
Starts with |
HTTP |
Existing local file |
The file, relative to the current directory |
Anything else |
Error: |
A template name wins over a local file with the same name. Use ./<name> to load the file instead.
Manifest¶
Key |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string |
no |
|
Preset name. For a built-in template, the name that |
|
string |
no |
|
Display title, shown by |
|
string |
no |
|
Preset description. Not used when rendering |
|
no |
absent |
Project settings |
|
|
array of Component |
yes |
— |
Components, rendered in order |
Unknown keys are ignored.
Project¶
Key |
Type |
Required |
Default |
Used by |
|---|---|---|---|---|
|
string |
no |
name of the current directory |
|
|
string |
no |
|
|
|
string |
no |
|
|
When project is absent, setup uses the current directory name, default and k8s, and apply uses default.
Component¶
Key |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string |
yes |
— |
Component reference. See Registry item format |
|
string |
yes |
— |
|
|
object of string to string |
no |
|
Field values. Every value must be a JSON string |
|
object of string to string |
no |
|
Labels. |
A field listed in Components as JSON-valued is stored as a string containing JSON, for example "hosts": "[{\"group\": \"web\"}]". A non-string value fails with <reference> is not a valid kikx preset manifest and invalid type: integer `8080`, expected a string.
A namespace key in fields overrides the project namespace for that component.
Minimal example¶
{
"components": [
{"reference": "k8s/service", "name": "web"}
]
}
kikx setup writes k8s/web-service.yaml and:
[project]
name = "<current directory name>"
default_namespace = "default"
output_dir = "k8s"
Full example¶
{
"name": "platform",
"description": "Web tier with an inventory, a playbook and a Kubernetes deployment.",
"project": {
"name": "platform",
"namespace": "platform",
"outputDir": "infra"
},
"components": [
{
"reference": "ansible/inventory",
"name": "platform",
"fields": {
"hosts": "[{\"group\": \"web\", \"members\": [{\"name\": \"web-01\", \"ansible_host\": \"192.0.2.10\"}]}]",
"default_user": "deploy"
}
},
{
"reference": "ansible/playbook",
"name": "web",
"fields": {
"folder": "playbooks",
"plays": "[{\"hosts\": \"web\", \"roles\": [\"nginx\"]}]"
}
},
{
"reference": "ansible/role",
"name": "nginx"
},
{
"reference": "k8s/deployment",
"name": "web",
"fields": {
"image": "nginx:1.27",
"replicas": "2"
},
"labels": {
"tier": "frontend"
}
}
]
}
kikx setup writes these files under infra/:
platform-inventory.ini
playbooks/web.yml
roles/nginx/tasks/main.yml
roles/nginx/defaults/main.yml
roles/nginx/handlers/main.yml
roles/nginx/meta/main.yml
web-deployment.yaml
A larger preset with 35 components is the multi-tier-platform template.
Built-in templates¶
kikx ships five presets, embedded in kikx-core at build time. Their source files are in backend/core/presets/, one <name>.kikx-preset.json per template. They are listed by kikx presets and GET /api/presets, and shown on the dashboard home page under Start from a template.
Name |
Title |
Components |
Output directory |
Namespace |
Contents |
|---|---|---|---|---|---|
|
Kubernetes web app |
7 |
|
|
A web frontend and an API behind ingresses, plus a background worker. |
|
Single server with Ansible |
7 |
|
|
One DigitalOcean droplet, configured by a common role through a site playbook. |
|
Kubernetes cluster with kubeadm |
11 |
|
|
Hetzner servers bootstrapped into a three-node control plane and three workers. |
|
Web servers and a database |
13 |
|
|
Existing servers split into a web tier and a PostgreSQL primary with a replica. |
|
Multi-tier platform |
35 |
|
|
A storefront platform: edge load balancers, web/app tiers, PostgreSQL primary + replicas, Redis, monitoring and a Kubernetes cluster. |
Every template that contains Ansible components also contains an ansible/config component, so ansible-playbook site.yml finds the inventory and the roles from the output directory.
A template is an ordinary preset: rendering it gives editable files with no link back to the template.
Rendering rules¶
All components are rendered before any file is written. The run stops with no file written when:
a component fails to render;
two components render the same path;
a rendered path is absolute or leaves the target directory;
a target file exists and
--forceis not passed.