Secrets and templates
Inject secrets and environment values at runtime.
Pipeline files need bootstrap servers, SASL credentials, and license tokens, but those values should not live in source control. Because K2K reads configuration at startup, we can resolve secrets from the environment before the YAML is parsed.
K2K evaluates ${...} template expressions at startup. Load secrets from environment variables or files, and layer a secrets_overrides.yml over a base pipeline so the structure stays the same across environments. See Loading pipeline files. To include a literal ${ in a value, write $${ — it renders as ${ without being resolved.
Prerequisites
Pipeline files that reference template variables
Secrets available as environment variables or files at deploy time
Example
name: "my_pipeline"
license:
acceptEula: true
token: "${env:K2K_LICENSE_TOKEN}"
source:
kafka:
common:
"bootstrap.servers": "${env:KAFKA_SOURCE_BOOTSTRAP}"
"sasl.jaas.config": "${file:raw:/secrets/jaas.conf}"
consumer:
"group.id": "my-k2k-group"
target:
kafka:
common:
"bootstrap.servers": "${env:KAFKA_TARGET_BOOTSTRAP}"
replication:
- source:
topic: "orders.*"
- sink:
topic: source
partition: sourceStart with multiple files so secrets override the base definition:
The template engine is enabled by default. Disable it with -g disabled or --template-engine disabled. The flag accepts only enabled or disabled.
Variable syntax
Variables use the form ${loader:mapper:name}. Shorthand forms:
${name}
Environment variable (same as ${env:name})
${mapper:name}
Environment variable with mapper applied
${loader:name}
Value loaded by loader
Mappers can be chained: ${env:raw:base64:MY_SECRET} or ${file:raw:/path/to/secret}.
Loaders
env
Read from an environment variable
file
Read from a file path
Mappers
string
Escape and wrap value in double quotes (for YAML strings)
raw
Use value as is, no escaping
base64
Base64 decode, then escape and wrap in double quotes
number
Use value as a numeric literal
Examples
Environment variable
Pipeline:
Environment:
Rendered value:
File loader
Pipeline:
File /secrets/jaas.conf:
Rendered value (inserted as is):
String mapper
Pipeline:
Environment:
Rendered value:
Last updated
Was this helpful?

