67 lines
1.4 KiB
Markdown
67 lines
1.4 KiB
Markdown
|
|
# Platform Templates
|
||
|
|
|
||
|
|
Output templates for generating configuration files in different formats.
|
||
|
|
|
||
|
|
## Template Subdirectories
|
||
|
|
|
||
|
|
### Configs (`configs/`)
|
||
|
|
|
||
|
|
Configuration file format templates:
|
||
|
|
- `toml.j2` - TOML format output
|
||
|
|
- `yaml.j2` - YAML format output
|
||
|
|
- `json.j2` - JSON format output
|
||
|
|
|
||
|
|
These templates convert Nickel configuration objects to format-specific files.
|
||
|
|
|
||
|
|
### Kubernetes (`kubernetes/`)
|
||
|
|
|
||
|
|
Kubernetes manifest templates:
|
||
|
|
- `deployment.yaml.j2` - Deployment manifests
|
||
|
|
- `configmap.yaml.j2` - ConfigMap for configuration
|
||
|
|
- `service.yaml.j2` - Service definitions
|
||
|
|
- `ingress.yaml.j2` - Ingress routing
|
||
|
|
|
||
|
|
### Docker Compose (`docker-compose/`)
|
||
|
|
|
||
|
|
Docker Compose templates:
|
||
|
|
- `docker-compose.yaml.j2` - Complete docker-compose.yml
|
||
|
|
|
||
|
|
## Template Usage
|
||
|
|
|
||
|
|
Templates use Jinja2 syntax for variable substitution:
|
||
|
|
|
||
|
|
```jinja2
|
||
|
|
# Example: toml.j2
|
||
|
|
[backend]
|
||
|
|
host = "{{ backend.host }}"
|
||
|
|
port = {{ backend.port }}
|
||
|
|
workers = {{ backend.workers }}
|
||
|
|
|
||
|
|
[database]
|
||
|
|
url = "{{ database.url }}"
|
||
|
|
pool_size = {{ database.pool_size }}
|
||
|
|
```
|
||
|
|
|
||
|
|
Generate output:
|
||
|
|
```bash
|
||
|
|
# Render TOML template with Nickel data
|
||
|
|
nickel export vapora.solo.ncl | \
|
||
|
|
jinja2 templates/configs/toml.j2 > vapora.solo.toml
|
||
|
|
```
|
||
|
|
|
||
|
|
## Template Rendering Flow
|
||
|
|
|
||
|
|
```
|
||
|
|
Nickel Config (JSON)
|
||
|
|
↓
|
||
|
|
Jinja2 Template
|
||
|
|
↓
|
||
|
|
Output Format (TOML, YAML, JSON, K8s, etc.)
|
||
|
|
```
|
||
|
|
|
||
|
|
## References
|
||
|
|
|
||
|
|
- Parent: `../README.md`
|
||
|
|
- Configs: `../configs/README.md`
|
||
|
|
- Template engine: https://jinja.palletsprojects.com/
|