Using Variables

Use variables to manage configuration and secrets in integration flows

Variables let you store configuration values and secrets outside of your code. You shouldn’t be hardcoding database passwords or API keys in your integration YAML files anyway.

Variable Syntax

Integrations pull in variables using Apache Camel’s system properties syntax inside application.properties files:

# Database configuration
database.url={{sys:DATABASE_CONNECTION}}
database.username={{sys:DB_USERNAME}}
database.password={{sys:DB_PASSWORD}}

# API configuration
api.key={{sys:EXTERNAL_API_KEY}}
api.endpoint={{sys:API_ENDPOINT}}

System Variables

The platform automatically provides a few system variables to all integration flows:

Variable NameDescription
weikio.agent.idThe unique identifier of the agent running the integration flow
weikio.nats.urlThe URL of the NATS server (defaults to localhost if not configured)
weikio.nats.usernameThe username for NATS authentication
weikio.nats.passwordThe password for NATS authentication
weikio.nats.credentialsfilepathThe file path to NATS credentials file

Using System Variables

You can reference system variables directly in your integration flow configurations:

apiVersion: weik.io/v1alpha1
kind: IntegrationFlow
metadata:
  name: nats-publisher
spec:
  source:
    uri: "timer:publish?period=5000"
  steps:
    - uri: "nats:events?servers={{sys:weikio.nats.url}}"

Or map them in application.properties:

# NATS connection configuration
nats.url={{sys:weikio.nats.url}}
nats.username={{sys:weikio.nats.username}}
nats.password={{sys:weikio.nats.password}}

# Agent identification
agent.id={{sys:weikio.agent.id}}

Creating Variables

You define custom variables using YAML manifests:

apiVersion: weik.io/v1alpha1
kind: Variable
metadata:
  name: DATABASE_PASSWORD
  description: PostgreSQL database password for production environment
spec:
  value: "your-secure-password-here"
  isSecret: true  # Optional, defaults to false

Apply the configuration using the CLI:

weikio config apply variable.yaml

Using Variables in Integration Flows

Variables are resolved at runtime when the integration starts:

apiVersion: weik.io/v1alpha1
kind: IntegrationFlow
metadata:
  name: database-sync
spec:
  source:
    uri: "postgresql:{{DATABASE_CONNECTION}}"
    parameters:
      apiKey: "{{EXTERNAL_API_KEY}}"
      enableFeatures: "{{ENABLE_BETA_FEATURES}}"

Example application.properties:

# Database configuration
database.url={{sys:DATABASE_CONNECTION}}
database.username={{sys:DB_USERNAME}}
database.password={{sys:DB_PASSWORD}}

# Feature flags
features.beta={{sys:ENABLE_BETA_FEATURES}}

Variable Resolution Process

When an integration flow boots up, the runner looks for variable references in your routes and properties. It fetches the matching values from Weik.io, injects them as environment variables, and lets Apache Camel handle the final resolution.

This keeps your secrets out of source control while still letting Camel behave exactly how you expect it to.

Common Examples

Database Connection

apiVersion: weik.io/v1alpha1
kind: Variable
metadata:
  name: DATABASE_CONNECTION
  description: PostgreSQL connection string for production database
spec:
  value: "Server=prod-db.example.com;Port=5432;Database=myapp;User Id=app_user;Password=secret;"
  isSecret: true

API Key

apiVersion: weik.io/v1alpha1
kind: Variable
metadata:
  name: EXTERNAL_API_KEY
  description: Authentication key for external service
spec:
  value: "ak_live_12345abcdef"
  isSecret: true

Feature Flag

apiVersion: weik.io/v1alpha1
kind: Variable
metadata:
  name: ENABLE_BETA_FEATURES
  description: Toggle for beta features in production
spec:
  value: "true"
  isSecret: false

Managing Variables

List All Variables

Use the API endpoint to view all variables (secret values are hidden):

GET /variables

Get Specific Variable

Retrieve a specific variable by name:

GET /variables/{name}

What’s Next