knot.template

The knot.template library provides template management functions. Templates define the configuration for creating spaces.


Functions

Function Description
list() List all templates
get(template_id) Get template by ID or name
create(name, ...) Create a new template
update(template_id, ...) Update template properties
delete(template_id) Delete a template
get_icons() Get list of available icons

Usage

import knot.template as template

# List all templates
templates = template.list()
for t in templates:
    print(f"{t['name']}: {t['platform']}")

# Get a template
t = template.get("ubuntu")
print(t['description'])

# Get available icons
icons = template.get_icons()
print(icons)

Template Properties

list() returns summary objects containing:

  • id - Template ID
  • name - Template name
  • description - Description
  • platform - Platform (e.g., “linux/amd64”)
  • active - Whether the template is active
  • usage - Current usage count
  • deployed - Number of deployed spaces

get() returns the full template including all of the above plus:

  • job - Job definition
  • volumes - Volume definitions
  • is_managed - Whether managed by the system
  • compute_units - Compute units quota
  • storage_units - Storage units quota
  • hash - Template hash
  • with_terminal - Terminal access enabled
  • with_vscode_tunnel - VS Code tunnel enabled
  • with_code_server - Code Server enabled
  • with_ssh - SSH access enabled
  • with_run_command - Run command enabled
  • allow_node_migration - Whether stopped spaces created from this local-container template can be reassigned to another node. Combined with health_check_auto_restart, automatic failed-node recovery is available in Knot Pro Pro
  • schedule_enabled - Schedule enabled
  • auto_start - Auto-start enabled
  • max_uptime - Maximum uptime value
  • max_uptime_unit - Maximum uptime unit
  • icon_url - Icon URL
  • groups - List of group IDs
  • zones - List of zone names
  • schedule - List of schedule day dicts (enabled, from, to)
  • custom_fields - List of custom field dicts (name, description)
  • health_check_type - Health check type (none, agent, tcp, http, program, or custom)
  • health_check_config - Health check target, command, or custom script depending on type
  • health_check_skip_ssl_verify - Skip TLS verification for HTTP health checks
  • health_check_timeout - Health check timeout in seconds
  • health_check_interval - Health check interval in seconds
  • health_check_max_failures - Number of consecutive failures before the space is considered unhealthy
  • health_check_auto_restart - Automatically restart when the health check fails. For agent, this restarts local-container and Nomad spaces when the agent stops transmitting. Combined with allow_node_migration, automatic failed-node recovery is available in Knot Pro Pro
  • disable_user_activity - Whether filesystem user activity collection is disabled for spaces created from this template Pro
  • ports - List of port dicts (name, port, protocol) defining the web ports exposed by spaces created from this template. These are injected as KNOT_HTTP_PORT, KNOT_HTTPS_PORT, and KNOT_TCP_PORT environment variables.

create() and update() also accept paths, either as a string or list of strings. These are appended to the template volume definition as managed paths entries.

For health_check_type="agent", no health_check_config value is required.