Using Variables

Use variables to manage configuration and secrets in integration flows

Variables allow you to store and manage configuration values and secrets that can be used across your integration flows. This enables secure handling of sensitive information, environment-specific configurations, and centralized management of shared values.

Variable Syntax

Integration flows reference variables using Apache Camel’s system properties syntax in 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

System variables are automatically provided by the platform and available to all integration flows without manual setup:

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

Reference system variables 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 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

Variables are configured using YAML files:

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 Weikio CLI:

weikio config apply variable.yaml

Using Variables in Integration Flows

Variables are referenced in application.properties files and automatically resolved at runtime:

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 starts:

  1. Integration runner detects variable references in routes and properties
  2. Variables are fetched from the Variables system
  3. Values are set as environment variables
  4. Apache Camel automatically resolves the variables during runtime

This provides:

  • Secure handling of sensitive information
  • Environment-specific configurations
  • Centralized management of shared values
  • Native integration with Apache Camel

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