yaml2helm
Convert Kubernetes YAML manifests into Helm charts automatically.
Features
- Multiple input formats: File, directory, stdin, or Kustomize with multi-document YAML support
- Smart value extraction: Automatically extracts common fields (image, replicas, resources, etc.)
- Resource-scoped values: Zero conflicts by organizing values per resource
- CRD support: Separate CRDs into crds/ directory per Helm best practices
- Namespace handling: Template namespaces or preserve originals
- Name templating: Preserve original names or add release name prefix
- Deterministic output: Stable ordering and idempotent reruns
- JSON Schema generation: Optional values.schema.json for validation
- Helm integration: Built-in helm lint and helm template validation
- Kustomize support: Direct integration with kustomize build
- Makefile generation: Optional Makefile with helm workflow targets
- Enhanced helpers: Comprehensive _helpers.tpl with apiVersion helpers
- Comprehensive reporting: Track conversions with detailed statistics
Installation
pip install -e .
For development:
pip install -e ".[dev]"
Usage
Basic conversion
yaml2helm --name myapp --in ./manifests --out ./charts
From stdin
kubectl get deployment nginx -o yaml | yaml2helm --name nginx --out ./charts
From Kustomize
yaml2helm --name myapp --kustomize ./overlays/production --out ./charts
With Makefile generation
yaml2helm --name myapp --in ./manifests --out ./charts --makefile
This creates a Makefile.helm with targets for building and managing your Helm chart:
make -f Makefile.helm help # Show available targets
make -f Makefile.helm helm # Generate chart
make -f Makefile.helm helm-lint # Lint the chart
With CRD separation
yaml2helm --name myapp --in ./manifests --out ./charts --crd-dir
This places CustomResourceDefinitions in crds/ directory per Helm best practices.
Preserve original namespaces
yaml2helm --name myapp --in ./manifests --out ./charts --preserve-ns
Keeps original namespaces instead of templating to {{ .Release.Namespace }}.
Add release name prefix
yaml2helm --name myapp --in ./manifests --out ./charts --prefix-release-name
Prefixes resource names with {{ include "myapp.fullname" . }}.
Advanced options
yaml2helm \
--name myapp \
--in ./manifests \
--out ./charts \
--resource-scoped \
--crd-dir \
--preserve-ns \
--schema \
--strict \
--makefile
CLI Options
| Option | Description | Default |
|---|---|---|
--name, -n |
Chart name (required) | - |
--in, -i |
Input file/directory (stdin if omitted) | stdin |
--kustomize, -k |
Run kustomize build on directory | - |
--out, -o |
Output directory | ./charts |
--resource-scoped/--field-scoped |
Scope values to resources (recommended) | true |
--crd-dir |
Place CRDs in separate crds/ directory | false |
--preserve-ns |
Preserve original namespaces (don't template) | false |
--original-name/--prefix-release-name |
Preserve names or add release prefix | true |
--include-cluster |
Include cluster-specific fields | false |
--schema/--no-schema |
Generate values.schema.json | true |
--lint/--no-lint |
Run helm lint | true |
--template/--no-template |
Run helm template | true |
--strict |
Fail on helm errors | false |
--makefile |
Generate Makefile.helm | false |
Output Structure
charts/
└── myapp/
├── Chart.yaml
├── values.yaml
├── values.schema.json
├── README.md
├── .helmignore
└── templates/
├── _helpers.tpl
├── NOTES.txt
├── 01-deployment-nginx.yaml
└── 02-service-nginx.yaml
Extracted Values
yaml2helm automatically extracts and templates:
- Image: repository and tag
- Replicas: for Deployments, StatefulSets
- Resources: CPU/memory limits and requests
- Service: type and ports
- Ingress: rules and TLS
- Environment variables: from containers
- Node affinity: nodeSelector, tolerations, affinity
- HPA: min/max replicas and target CPU
Examples
Convert a deployment
# Input: deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 3
template:
spec:
containers:
- name: nginx
image: nginx:1.19
# Run conversion
yaml2helm --name nginx --in deployment.yaml --out ./charts
# Output: charts/nginx/values.yaml
image:
repository: nginx
tag: "1.19"
replicas: 3
# Output: charts/nginx/templates/01-deployment-nginx.yaml (templated)
spec:
replicas: {{ .Values.replicas }}
template:
spec:
containers:
- image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
Multi-document YAML
# Input file with multiple resources separated by ---
yaml2helm --name myapp --in multi.yaml --out ./charts
Directory of manifests
# Convert all YAML files in a directory
yaml2helm --name myapp --in ./k8s-manifests --out ./charts
Testing
Run tests:
pytest tests/ -v
With coverage:
pytest tests/ --cov=yaml2helm --cov-report=term-missing
Algorithm
- Discovery: Find YAML files, split multi-docs, parse with ruamel.yaml
- Validation: Check for apiVersion, kind, metadata.name
- Normalization: Sort maps and lists for deterministic output
- Extraction: Extract values per heuristics, replace with Helm templates
- Writing: Generate template files as
NN-<kind>-<name>.yaml - Schema: Create values.schema.json from extracted values
- Validation: Run helm lint and helm template if available
Requirements
- Python 3.11+
- Optional: helm CLI for validation
Dependencies
- typer: CLI framework
- ruamel.yaml: YAML parsing with comments preservation
- jinja2: Template rendering
- jsonschema: Schema validation
- rich: Terminal formatting
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=yaml2helm
# Test with helm integration
yaml2helm --name demo --in tests/data/input --out /tmp/charts
helm lint /tmp/charts/demo
helm template test /tmp/charts/demo
License
MIT
Metadata
Release files for yaml2helm 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yaml2helm-0.1.0.tar.gz | 27.7 kB | Without provenance | Details for yaml2helm-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yaml2helm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for yaml2helm-0.1.0-py3-none-any.whl |
Total release size: 57.1 kB
Release files / yaml2helm-0.1.0.tar.gz
| Download URL | yaml2helm-0.1.0.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7bbbc6a58f9dd8cda4ae7d50eaf0523d7c38452a47502bb2bac090f5984ec643
|
|
BLAKE2b-256 checksum How to use checksums |
edeb2c8e3e13011bab3d250dd4fa3213b13fed2a39aa25292eb02eaae4cffe0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / yaml2helm-0.1.0-py3-none-any.whl
| Download URL | yaml2helm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 29.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c85c683fb719a4331cccab553d1df0de22868ffaa6cbd6370cc086257a3eab6
|
|
BLAKE2b-256 checksum How to use checksums |
dcb8d5bfdbb702030febff3d3889a9b57ad73b2efa1f98ecc70820bd1bd593d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for yaml2helm 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.