Declarative Configuration
KSail uses declarative YAML configuration files for reproducible cluster setup. This page describes ksail.yaml β the project-level configuration file that defines your clusterβs desired state.
What is ksail.yaml?
Each KSail project includes a ksail.yaml file describing the cluster and workload configuration. Run ksail cluster init to generate this file, which can be committed to version control and shared with your team.
The configuration file uses the ksail.io/v1alpha1 API version and follows the Cluster kind schema. It defines:
- Cluster settings: distribution, networking, components
- Connection details: kubeconfig path, context, timeouts
- Workload configuration: manifest directory, validation preferences
- Editor preferences: for interactive workflows
Minimal Example
# yaml-language-server: $schema=https://raw.githubusercontent.com/devantler-tech/ksail/main/schemas/ksail-config.schema.json
apiVersion: ksail.io/v1alpha1
kind: Cluster
spec:
cluster:
distribution: Vanilla
distributionConfig: kind.yaml
This minimal configuration creates a Vanilla cluster (implemented with Kind) using defaults for all other settings.
Complete Example
# yaml-language-server: $schema=https://raw.githubusercontent.com/devantler-tech/ksail/main/schemas/ksail-config.schema.json
apiVersion: ksail.io/v1alpha1
kind: Cluster
spec:
editor: code --wait
cluster:
distribution: Vanilla
distributionConfig: kind.yaml
connection:
kubeconfig: ~/.kube/config
context: kind-kind
timeout: 5m
cni: Cilium
# CSI "Default" uses the distribution's built-in storage behavior:
# - K3s: includes local-path-provisioner by default
# - Vanilla and Talos: no CSI installed; use LocalPathStorage if needed
csi: Default
metricsServer: Enabled
certManager: Enabled
policyEngine: Kyverno
localRegistry: Enabled
gitOpsEngine: Flux
localRegistryOptions:
hostPort: 5050
workload:
sourceDirectory: k8s
validateOnPush: true
Configuration Reference
Top-Level Fields
| Field | Type | Required | Description |
|---|---|---|---|
apiVersion | string | Yes | Must be ksail.io/v1alpha1 |
kind | string | Yes | Must be Cluster |
spec | object | Yes | Cluster and workload specification (see below) |
spec
The spec field is a Spec object that defines editor, cluster, and workload configuration.
| Field | Type | Default | Description |
|---|---|---|---|
editor | string | β | Editor command for interactive workflows |
cluster | ClusterSpec | β | Cluster configuration (distribution, components) |
workload | WorkloadSpec | β | Workload manifest configuration |
spec.editor
Editor command used by KSail for interactive workflows like ksail cipher edit or ksail workload edit.
Examples: code --wait, vim, nano
If not specified, KSail falls back to standard editor environment variables (SOPS_EDITOR, KUBE_EDITOR, EDITOR, VISUAL) or system defaults (vim, nano, vi).
spec.cluster (ClusterSpec)
| Field | Type | Default | Description |
|---|---|---|---|
distribution | enum | Vanilla | Kubernetes distribution to use |
provider | enum | Docker | Infrastructure provider (Docker, Hetzner) |
distributionConfig | string | (see below) | Path to distribution-specific configuration |
connection | Connection | β | Cluster connection settings |
cni | enum | Default | Container Network Interface |
csi | enum | Default | Container Storage Interface |
metricsServer | enum | Default | Install metrics-server |
certManager | enum | Disabled | Install cert-manager |
policyEngine | enum | None | Policy engine to install |
localRegistry | LocalRegistry | β | Registry configuration (see below) |
gitOpsEngine | enum | None | GitOps engine to install |
mirrorRegistries | []string | β | Mirror registry specifications |
kind | object | β | Kind-specific options (Vanilla distribution) |
k3d | object | β | K3d-specific options (K3s distribution) |
talos | object | β | Talos-specific options |
hetzner | object | β | Hetzner Cloud provider options |
cilium | object | β | Cilium CNI options |
calico | object | β | Calico CNI options |
flux | object | β | Flux GitOps options |
argocd | object | β | ArgoCD GitOps options |
helm | object | β | Helm tool options (reserved) |
kustomize | object | β | Kustomize tool options (reserved) |
distribution
Kubernetes distribution to use for the local cluster. See Distributions for detailed information about each distribution.
Valid values:
Vanilla(default) β Standard upstream Kubernetes (implemented with Kind)K3sβ Lightweight Kubernetes (implemented with K3d)Talosβ Talos Linux in Docker containers or Hetzner Cloud servers
provider
Infrastructure provider for running cluster nodes. See Providers for more details.
Valid values:
Docker(default) β Run nodes as Docker containers (local development)Hetznerβ Run nodes on Hetzner Cloud servers (requiresHCLOUD_TOKEN)
Note: Hetzner provider is only supported with the Talos distribution.
distributionConfig
Path to the distribution-specific configuration file or directory. This tells KSail where to find settings like node counts, port mappings, and distribution-specific features.
Default values by distribution:
Vanillaβkind.yamlK3sβk3d.yamlTalosβtalos/(directory)
See Distribution Configuration below for details on each format.
connection (Connection)
| Field | Type | Default | Description |
|---|---|---|---|
kubeconfig | string | ~/.kube/config | Path to kubeconfig file |
context | string | (derived) | Kubeconfig context name |
timeout | duration | β | Timeout for cluster operations |
Context defaults by distribution:
Vanillaβkind-kindK3sβk3d-k3d-defaultTalosβadmin@talos-default
Timeout format: Go duration string (e.g., 30s, 5m, 1h)
cni
Container Network Interface to install. See CNI for more details.
Valid values:
Defaultβ Uses the distributionβs built-in CNI (kindnetdfor Vanilla,flannelfor K3s)Ciliumβ Installs Cilium for advanced networking and observabilityCalicoβ Installs Calico for network policies
csi
Container Storage Interface to install. See CSI for more details.
Valid values:
Defaultβ Uses the distributionβs built-in storage (K3s includes local-path-provisioner; Vanilla does not)LocalPathStorageβ Explicitly installs local-path-provisioner
metricsServer
Whether to install metrics-server for resource metrics.
Valid values:
Default(default) β Uses distributionβs default behavior (K3s includes metrics-server; Vanilla and Talos do not)Enabledβ Install metrics-serverDisabledβ Skip installation
When metrics-server is enabled on Vanilla or Talos, KSail automatically:
- Configures kubelet certificate rotation (
serverTLSBootstrap: true) - Installs kubelet-csr-approver to approve certificate requests
- Deploys metrics-server with secure TLS communication
Note: K3s includes metrics-server by default, so this setting has no effect on K3s.
certManager
Whether to install cert-manager for TLS certificate management.
Valid values:
Enabledβ Install cert-managerDisabled(default) β Skip installation
policyEngine
Policy engine to install for enforcing security, compliance, and best practices. See Policy Engines for more details about Kyverno and Gatekeeper.
Valid values:
None(default) β No policy engineKyvernoβ Install Kyverno for Kubernetes-native policy managementGatekeeperβ Install OPA Gatekeeper for OPA-based policy enforcement
localRegistry
Registry configuration for GitOps workflows. Supports local Docker registries or external registries with authentication.
Format: [user:pass@]host[:port][/path]
Examples:
localhost:5050β Local Docker registryghcr.io/myorg/myrepoβ GitHub Container Registry${USER}:${PASS}@ghcr.io:443/myorgβ With credentials from environment variables
Note: Credentials support ${ENV_VAR} placeholders for secure handling.
gitOpsEngine
GitOps engine to install for continuous deployment workflows. See GitOps for more details about Flux and ArgoCD. When set to Flux or ArgoCD, KSail scaffolds a GitOps CR (FluxInstance or ArgoCD Application) into your source directory at gitops/flux/flux-instance.yaml or gitops/argocd/application.yaml.
Valid values:
None(default) β No GitOps engineFluxβ Install Flux CD and scaffold FluxInstance CRArgoCDβ Install Argo CD and scaffold Application CR
Distribution and Tool Options
Advanced configuration options are direct fields under spec.cluster. See Schema Support for the complete structure.
Talos options (spec.cluster.talos):
controlPlanesβ Number of control-plane nodes (default:1)workersβ Number of worker nodes (default:0)configβ Path to talosconfig file (default:~/.talos/config)isoβ Cloud provider ISO/image ID for Talos Linux (default:122630for x86)
Hetzner options (spec.cluster.hetzner):
controlPlaneServerTypeβ Server type for control-plane nodes (default:cx23)workerServerTypeβ Server type for worker nodes (default:cx23)locationβ Datacenter location:fsn1,nbg1,hel1(default:fsn1)networkNameβ Private network name (default:<cluster>-network)networkCidrβ Network CIDR block (default:10.0.0.0/16)sshKeyNameβ SSH key name for server access (optional)tokenEnvVarβ Environment variable for API token (default:HCLOUD_TOKEN)
Kind options (spec.cluster.kind):
mirrorsDirβ Directory for containerd host mirror configuration
spec.workload (WorkloadSpec)
| Field | Type | Default | Description |
|---|---|---|---|
sourceDirectory | string | k8s | Directory containing Kubernetes manifests |
validateOnPush | boolean | false | Validate manifests before pushing to registry |
Distribution Configuration
KSail references distribution-specific configuration files to customize cluster behavior. The path to these files is set via spec.cluster.distributionConfig.
Vanilla (implemented with Kind) Configuration
Default: kind.yaml
The Vanilla distribution is configured via a YAML file following the Kind configuration schema. This allows you to customize:
- Node images and versions
- Extra port mappings
- Extra mounts
- Networking settings
Documentation: Kind Configuration
Example:
# kind.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30000
hostPort: 30000
K3s (implemented with K3d) Configuration
Default: k3d.yaml
The K3s distribution is configured via a YAML file following the K3d configuration schema. This allows you to customize:
- Server and agent counts
- Port mappings
- Volume mounts
- Registry configurations
Documentation: K3d Configuration
Example:
# k3d.yaml
apiVersion: k3d.io/v1alpha5
kind: Simple
servers: 1
agents: 2
ports:
- port: 8080:80
nodeFilters:
- loadbalancer
Talos Configuration
Default: talos/ directory
Talos uses a directory structure for Talos machine configuration patches. Each directory contains YAML patch files that modify the Talos machine configuration.
Documentation: Talos Configuration Reference
Directory structure and examples:
# talos/cluster/kubelet.yaml
# Patches applied to all nodes
machine:
kubelet:
extraArgs:
max-pods: "250"
# talos/control-planes/api.yaml
# Patches for control-plane nodes only
machine:
kubelet:
extraArgs:
feature-gates: "EphemeralContainers=true"
# talos/workers/custom.yaml
# Patches for worker nodes only
machine:
sysctls:
net.core.somaxconn: "65535"
Use spec.cluster.talos to configure node counts:
spec:
cluster:
distribution: Talos
distributionConfig: talos
talos:
controlPlanes: 3
workers: 2
Schema Support
KSail provides a JSON Schema for IDE validation and autocompletion. Reference it at the top of your ksail.yaml:
# yaml-language-server: $schema=https://raw.githubusercontent.com/devantler-tech/ksail/main/schemas/ksail-config.schema.json
apiVersion: ksail.io/v1alpha1
kind: Cluster
spec:
# ...
IDEs with YAML language support (like VS Code with the Red Hat YAML extension) will provide:
- Field autocompletion
- Inline documentation
- Validation errors for invalid values
- Enum suggestions for fields like
distribution,cni, etc.