Configuration Files¶
Helm-me allows you to declare configuration files directly alongside your application spec. When defined, these files are seamlessly converted into Kubernetes ConfigMap resources, securely mounted as subPath volumes directly into the specified paths within your component containers.
Using the files property allows you to avoid baking dynamic configurations into your Docker image.
Defining Files¶
You can provide either inline string content or an explicit fromFile
reference for local files.
components:
frontend:
type: web
image: nginx:alpine
port: 80
files:
# Inline configuration content
"/etc/nginx/conf.d/default.conf": |
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
# Or read directly from a local file next to the spec
"/etc/nginx/nginx.conf":
fromFile: "./configs/nginx.conf"
```python from helm_me import App, web, image
class MyApp(App): name = "demo"
frontend = web(
image=image("nginx:alpine"),
port=80,
files={
"/etc/nginx/conf.d/default.conf": '''
server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } } ''', "/etc/nginx/nginx.conf": "./configs/nginx.conf" } ) ```
Local File Paths¶
For YAML and TOML specs, local file reads must be explicit. Use fromFile and
make the path relative to the spec file directory.
Plain string values are treated as literal content and are never auto-read as paths in declarative configs.
Python specs still support the convenient shorthand of passing a relative file
path string in files={...}.
How it works¶
Behind the scenes, Helm-me translates the files mapping into a single Kubernetes ConfigMap named <app-name>-<component-name>-files.
It then modifies your component's Kubernetes Deployment (or Job/CronJob) by adding individual subPath volume mounts, ensuring that only the specific file is mounted, without overriding the rest of the parent directory.
You can combine files with all types of workloads: web, worker, job, and cronjob.