Creating Templates
Learn how to create your own Conjure templates from scratch.
Creating templates allows you to codify your infrastructure and application configurations as reusable blueprints. This guide walks you through building templates step by step.
By the end of this guide, you'll have created a complete template that:
- Generates a Kubernetes Deployment manifest
- Accepts customizable variables
- Includes proper metadata and documentation
Every template is organized in a versioned directory structure containing:
- Template file (
template.tmpl) - Contains the template with placeholders - Metadata file (
conjure.json) - Defines version, type, variables, and documentation
Templates follow the directory pattern: templates/{name}/{version}/
Navigate to your templates directory:
cd ~/conjure-workspace/templates
Create the versioned template directory:
mkdir -p deployment/1.0.0
Create the template files:
touch deployment/1.0.0/template.tmpl
touch deployment/1.0.0/conjure.json
Open deployment/1.0.0/template.tmpl and add the template content:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.app_name}}-deployment
namespace: {{.namespace}}
labels:
app: {{.app_name}}
spec:
replicas: {{.replicas}}
selector:
matchLabels:
app: {{.app_name}}
template:
metadata:
labels:
app: {{.app_name}}
spec:
containers:
- name: {{.app_name}}
image: {{.image}}
ports:
- containerPort: {{.port}}
resources:
requests:
cpu: {{.cpu_request}}
memory: {{.memory_request}}
limits:
cpu: {{.cpu_limit}}
memory: {{.memory_limit}}
Open deployment/1.0.0/conjure.json and add the variable definitions:
{
"schema_version": "v1",
"version": "1.0.0",
"template_name": "deployment",
"template_type": "yaml",
"template_description": "Kubernetes Deployment manifest with configurable resources",
"variables": [
{
"name": "app_name",
"description": "Application name",
"type": "string",
"default": ""
},
{
"name": "namespace",
"description": "Kubernetes namespace",
"type": "string",
"default": "default"
},
{
"name": "image",
"description": "Container image (e.g., nginx:latest)",
"type": "string",
"default": ""
},
{
"name": "replicas",
"description": "Number of pod replicas",
"type": "int",
"default": "3"
},
{
"name": "port",
"description": "Container port",
"type": "int",
"default": "8080"
},
{
"name": "cpu_request",
"description": "CPU request (e.g., 100m)",
"type": "string",
"default": "100m"
},
{
"name": "cpu_limit",
"description": "CPU limit (e.g., 500m)",
"type": "string",
"default": "500m"
},
{
"name": "memory_request",
"description": "Memory request (e.g., 128Mi)",
"type": "string",
"default": "128Mi"
},
{
"name": "memory_limit",
"description": "Memory limit (e.g., 512Mi)",
"type": "string",
"default": "512Mi"
}
]
}
All template metadata files (conjure.json) must include these required fields:
{
"schema_version": "v1",
"template_name": "deployment",
"template_type": "yaml",
"template_description": "Template description",
"variables": []
}
- schema_version - Currently only "v1" is supported
- template_name - Template identifier used in commands
- template_type - Classification type (e.g., "yaml", "json", "kubernetes", "terraform")
- template_description - Describes the purpose of the template
- variables - Array of variable definitions (can be empty)
The version field is optional. Version is determined by the directory name (e.g., 1.0.0/).
All variables must include three required fields:
name - The variable identifier used in templates type - Must be one of: "string", "int", or "bool" description - Helps users understand the variable's purpose
Variables with "default": "" are required. The user must provide a value via CLI flags, values files, or interactive prompts. Variables with non-empty defaults are optional for users to overide.
{
"name": "app_name",
"description": "Application name",
"type": "string",
"default": ""
}
# Navigate to workspace
cd ~/conjure-workspace
# Test with interactive mode
conjure template deployment -o test-deployment.yaml
# Or test with variables
conjure template deployment -o test-deployment.yaml \
--var app_name=test-app \
--var image=nginx:latest
Verify the output:
cat test-deployment.yaml
touch test-values.yaml
Add test values:
app_name: test-app
namespace: testing
image: nginx:latest
replicas: 2
port: 80
cpu_request: 100m
cpu_limit: 200m
memory_request: 64Mi
memory_limit: 128Mi
# Generate
conjure template deployment -o test-deployment.yaml -f test-values.yaml
# Validate with kubectl (if available)
kubectl apply --dry-run=client -f test-deployment.yaml