Auto-generate Helm charts from Docker Compose files
Project description
Helmgen
Auto-generate Helm charts from Docker Compose files.
HelmGen is a Python CLI tool that automatically converts your docker-compose.yml into a fully structured Helm chart — including Deployments, Services, PVCs, Ingress, and Secrets (internal or ExternalSecrets).
Features:
- Convert Docker Compose files directly into Helm charts
- Auto-detect databases → generate StatefulSets + PVCs
- Auto-generate Kubernetes Secrets or ExternalSecrets
- Support for Vault, AWS Secrets Manager, or ExternalSecrets Operator
- Generate SecretStore or ClusterSecretStore automatically
- Auto-generate Ingress resources for web services
- Replace hardcoded secrets with safe placeholders in
values.yaml - Detect whether secrets should be env vars or mounted files
- CLI support for flexible options and overrides
Installation
From source (recommended for development)
git clone https://github.com/yourusername/helmgen.git
cd helmgen
pip install -e .
- Then you can run it as a command:
helmgen --help
Usage
helmgen docker-compose.yml [options]
Example
helmgen docker-compose.yml \
--output ./charts/myapp \
--secret-provider externalsecret \
--store-scope cluster \
--reuse-store global-vault-store
- This generates
charts/myapp/
├── Chart.yaml
├── values.yaml
└── templates/
├── deployment.yaml
├── service.yaml
├── pvc.yaml
├── ingress.yaml
├── secrets.yaml
├── externalsecret.yaml
└── secretstore.yaml
- Then you can deploy
helm install myapp ./charts/myapp
CLI options
| Option | Description | Default |
|---|---|---|
--output, -o |
Directory for generated Helm chart | ./generated-chart |
--secret-provider, -s |
internal (Helm Secret) or externalsecret |
internal |
--store-scope |
namespace or cluster SecretStore |
namespace |
--reuse-store |
Name of existing SecretStore/ClusterSecretStore | None |
Example
version: "3.8"
services:
web:
image: nginx:alpine
ports:
- "8080:80"
environment:
APP_ENV: production
SECRET_KEY: supersecret
db:
image: postgres:14
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: pass123
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
volumes:
db-data:
-
This will generate a Helm Chart with
- StatefulSet for Postgres
- Deployment for web
- Secrets/ExternalSecrets for passwords
- PVC for db-data
- Ingress if ports are exposed
-
In this example the sensitive data is hard coded in the compose file with is a very bad practice but it's being used only for purpose of the example demonstration
Secret management
- There are 2 options
- Internal (default helm secret)
- External
if you want to run it as a python script (not recommended)
python3 generator.py docker-compose.yml \
--output ./charts/myapp \
--secret-provider externalsecret \
--store-scope cluster \
--reuse-store global-vault-store
This will create a complete Helm chart with:
charts/myapp/
├── Chart.yaml
├── values.yaml
└── templates/
├── deployment.yaml
├── service.yaml
├── pvc.yaml
├── ingress.yaml
├── secrets.yaml
├── externalsecret.yaml
└── secretstore.yaml
Templates
helm_templates/
├── deployment.yaml
├── service.yaml
├── pvc.yaml
├── ingress.yaml
├── secrets.yaml
├── externalsecret.yaml
└── secretstore.yaml
Summary
Files and templates directory:
-
generator.py → generates chart structure and populates values.yaml.
-
helm_templates/ → reusable Jinja-style templates compatible with Helm.
-
Seamless handling of:
- Secrets and ExternalSecrets
- Databases as StatefulSets (via PVC)
- Ingress auto-detection
- ClusterSecretStore / SecretStore support
Run this version
- Generate files and templates from compose file:
python3 generator.py docker-compose.yml --output ./charts/myapp --secret-provider externalsecret
- Then install chart:
helm install myapp ./charts/myapp
Dependencies
| Package | Purpose |
|---|---|
| PyYAML | Primary YAML parser for reading docker-compose.yml. |
| ruamel.yaml | More advanced YAML manipulation (preserves comments, ordering). |
| jinja2 | Template rendering for Helm YAML files (used when writing templates/). |
| click | Optional CLI framework (if you upgrade from argparse later for nicer commands). |
| rich | Optional but recommended — adds colored console output, status spinners, and better error formatting. |
Install dependencies
pip install -r requirements.txt
Update to run it as a CLI tool
- Usage
helmgen docker-compose.yml --output ./charts/myapp
How it works
- project.scripts exposes a command called helmgen
- That command runs the main() function inside your generator.py
- Everything else is metadata (version, author, URLs, etc.)
- Dependencies match the ones from your requirements.txt
Project layout
helmgen/
├── generator.py
├── pyproject.toml
├── README.md
├── requirements.txt
└── helm_templates/
├── deployment.yaml
├── service.yaml
├── pvc.yaml
├── ingress.yaml
├── secrets.yaml
├── externalsecret.yaml
└── secretstore.yaml
Install locally for development
- From the folder containing pyproject.toml:
pip install -e .
Then you can run it directly:
helmgen docker-compose.yml --output ./charts/myapp
Build a distributable package
- to share it or publish it to PyPI (optional):
python -m build
- and it generates
dist/
├── helmgen-0.1.0-py3-none-any.whl
└── helmgen-0.1.0.tar.gz
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file helmgen-0.1.0.tar.gz.
File metadata
- Download URL: helmgen-0.1.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ce6c75afd33551a3295009b576e12fae86d540cb19203cd1fa813681293b4d5
|
|
| MD5 |
25fce8cea22790f8ce6e16a39d3d6527
|
|
| BLAKE2b-256 |
88fbec954aba5a074f9b340a856811f25835938b10210de47db2c8f8a6a038ae
|
File details
Details for the file helmgen-0.1.0-py3-none-any.whl.
File metadata
- Download URL: helmgen-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55550a6127e5839d10d7f0dab2519b7aab2e5d25662ab2890e41fe43f547bd7f
|
|
| MD5 |
304b14fbb58aa1eebee7223c488829a4
|
|
| BLAKE2b-256 |
63917c66cad1442ee1bf3eb58fcffad6903843c28afd2c64c09ca5303f8d62ba
|