KYAML - Kubernetes YAML Validator
A Visual Studio Code extension that provides schema validation and syntax highlighting for KYAML (Kubernetes safer YAML subset).
What is KYAML?
KYAML is a safer, less ambiguous subset of YAML designed specifically for Kubernetes configurations. It addresses common YAML pitfalls:
- No implicit type coercion - Values like
yes, no, on, off won't be silently converted to booleans
- Flow-style syntax - Uses
{} and [] instead of indentation, eliminating whitespace-related errors
- Explicit strings - All string values must be double-quoted, preventing ambiguity
KYAML Example
---
{
apiVersion: "v1",
kind: "Pod",
metadata: {
name: "my-pod",
labels: {
app: "demo"
}
},
spec: {
containers: [{
name: "nginx",
image: "nginx:1.20"
}]
}
}
Features
- Real-time validation - Validates KYAML files as you type
- Syntax highlighting - Full syntax highlighting for
.kyaml and .kyml files
- Quick fixes - Automatic fixes for common issues (e.g., quoting strings)
- YAML to KYAML conversion - Convert existing YAML files to KYAML format
- Kubernetes manifest detection - Optionally validates YAML files containing Kubernetes manifests
Validation Rules
The extension checks for:
- Flow-style syntax - Documents must use
{} and [] for structure
- Quoted strings - All string values must be double-quoted
- Document markers - Documents should start with
---
- Ambiguous values - Warns about values that might cause type coercion issues
- Indentation structure - Flags traditional YAML indentation-based syntax
Commands
KYAML: Validate Current File - Manually trigger validation
KYAML: Convert YAML to KYAML - Convert the current YAML document to KYAML format
Configuration
| Setting |
Default |
Description |
kyaml.validate |
true |
Enable/disable KYAML validation |
kyaml.validateOnSave |
true |
Validate files on save |
kyaml.validateOnType |
true |
Validate files while typing |
kyaml.strictMode |
true |
Enforce strict KYAML rules |
File Extensions
The extension automatically activates for:
.kyaml files
.kyml files
- YAML files containing Kubernetes manifests (when strict mode allows)
Installation
From Source
- Clone this repository
- Run
bun install
- Run
bun run compile
- Press F5 to launch the extension in debug mode
Package VSIX
vsce package
From VSIX
- Download the
.vsix file
- Run
code --install-extension vscode-kyaml-x.x.x.vsix
Development
# Install dependencies
bun install
# Compile TypeScript
bun run compile
# Watch for changes
bun run watch
# Run linting
bun run lint
License
MIT
| |