Patch Package
Patch Package Documentation
The patch package implements a powerful JSONPath-based declarative patching system for Kubernetes resources. It allows you to modify resources while preserving YAML structure, comments, and formatting.
Documentation
Patch File Format Specification
Complete specification of the .kpatch
file format, including:
- Syntax and structure
- Scope selection
- Operation types
- Examples and best practices
Patch Engine Design
Technical design documentation covering:
- Architecture overview
- Processing pipeline
- Implementation details
- Performance considerations
Path Resolution
Detailed explanation of how paths are resolved:
- JSONPath syntax support
- Array indexing and wildcards
- Complex path expressions
- Resolution algorithm
Error Handling
Comprehensive error handling guide:
- Error types and categories
- Error recovery strategies
- Debugging patch issues
- Common problems and solutions
Quick Example
[Deployment.my-app]
set.spec.replicas = 5
set.metadata.labels.environment = "production"
add.spec.template.spec.containers[name=app].env = [
{ name = "LOG_LEVEL", value = "info" }
]
Features
- Declarative: Define what you want, not how to get there
- Type-safe: Operations are validated against resource schemas
- Preserves formatting: Maintains YAML comments and structure
- Powerful selection: Target resources by kind, name, labels, and more
- Flexible operations: Set, add, replace values with JSONPath precision
Getting Started
- Start with the Patch File Format Specification
- Review examples to see patches in action
- Understand path resolution for complex selections
- Learn about error handling for debugging