incus-templated

Config files that follow your Incus instances: a Go template per target, re-rendered and deployed on every instance lifecycle event.

incus-templated watches your Incus fleet via the ievent stream, renders any Go template from instance labels in real time, checks the result with your own format and validate commands, and deploys it directly into persistent storage volumes via Incus SFTP or onto the local filesystem. The built-in Caddy preset does this for Caddyfiles, as shown below; Prometheus file_sd needs only a template, and Templates covers anything else.

flowchart TD
    Incus["Incus API (Events & Control)"] -->|instance events| Chain["ievent Chain<br/>(source &rarr; debounce &rarr; enricher)"]
    Chain --> Plugin["incus-templated Plugin"]

    subgraph Storage["Incus Storage Pool"]
        Vol[("custom/caddy-config volume<br/>mounted at /config")]
    end

    subgraph Caddy["Serving Caddy Container"]
        CaddyProc["caddy:2.11.4-alpine<br/>(admin localhost:2019)"]
    end

    Plugin -->|"1. SFTP write (Caddyfile.tmp)"| Vol
    Plugin -->|"2. Incus exec ('caddy fmt')"| CaddyProc
    Plugin -->|"3. SFTP atomic rename (Caddyfile.tmp &rarr; Caddyfile)"| Vol
    Plugin -->|"4. Incus exec ('caddy reload')"| CaddyProc

Quick Example

With the Caddy preset, define Caddy and your backend application in compose.yaml:

services:
  caddy:
    image: docker.io/library/caddy:2.11.4-alpine
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - config:/config
      - data:/data

  api:
    image: docker.io/library/busybox:latest
    command: httpd -f -p 8080
    labels:
      edge: "api.example.com,upstream=8080"

volumes:
  config:
  data:

When incus-templated runs with --target edge,preset=caddy,instance=caddy,project=default, it automatically discovers api, resolves its Incus bridge IPv4 address, and renders the reverse proxy block into Caddy:

{
	admin localhost:2019
}

api.example.com {
	reverse_proxy 10.0.1.42:8080
}

When you scale, stop, start, or rename instances, Caddy reloads within milliseconds of the Incus event.


Key Highlights


Documentation Navigation