Setting Environment Variables
Environment variables in Konduktor can come from multiple sources, depending on how your workload and configuration are defined. When the same variable name is defined in more than one place, Konduktor applies a priority order to decide which value takes precedence.Priority Order
If the same variable appears in multiple places, the highest priority source wins. Priorities from highest to lowest:| Priority | Source | Description |
|---|---|---|
| 1 | CLI | Variables passed directly via the CLI with konduktor launch |
| 2 | Task (task.yaml) | Variables defined under the envs: block of a task.yaml |
| 3 | Environment Secrets (kind=env) | Variables created using konduktor secret create --kind=env |
| 4 | Config (~/.konduktor/config.yaml) | Variables defined globally in the Konduktor configuration file at ~/.konduktor/config.yaml |
| 5 | Other/System Defaults | Variables automatically generated by Konduktor (ex. KONDUKTOR_JOB_NAME, NUM_NODES, etc.). |
export FOO=bar) done inside your run: script happens at runtime and will override the effective value for all subsequent commands in that script. So basically runtime > everything.
Examples
CLI
task.yaml
Env Secret
config.yaml
Accessing Environment Variables
Environment variables can be accessed in several ways:Shell Scripts
Task.yaml:
Python
Task.yaml:
pythonfile.py:
Node.js
Task.yaml:
jsfile.js:
Core Konduktor Environment Variables
These variables are always available in every Konduktor container:Job Information
| Variable | Description | Example Value |
|---|---|---|
KONDUKTOR_JOB_NAME | Unique identifier for the current job | my-training-job-a1b2 |
NUM_NODES | Total number of nodes in the job | 2 |
NUM_GPUS_PER_NODE | Number of GPUs allocated per node | 8 |
Networking Information
| Variable | Description | Example Value |
|---|---|---|
NODE_HOST_IPS | Comma-separated list of all node hostnames | job-123-workers-0-0.job-123,job-123-workers-0-1.job-123 |
MASTER_ADDR | Hostname of the master/rank 0 node | job-123-workers-0-0.job-123 |
LOCAL_ADDR | Pod’s internal IP address | 10.104.2.17 |
RANK | Current node’s rank (0 for master, 1+ for workers) | 0 |
System Configuration
| Variable | Description | Example Value |
|---|---|---|
PYTHONUNBUFFERED | Python output buffering setting | 0 |
JOB_COMPLETION_INDEX | Kubernetes job completion index | 0 |
RESTART_ATTEMPT | Job restart attempt number (0 for first attempt, 1+ for retries) | 0 |
Conditional Environment Variables
These variables are only set when specific features are enabled:Tailscale (when tailscale.secret_name is configured)
| Variable | Description | Example Value |
|---|---|---|
TS_USERSPACE | Tailscale userspace networking flag | true |
TS_AUTHKEY | Tailscale authentication key | tskey-auth-... |
POD_NAME | Kubernetes pod name | job-123-workers-0-0-abc123 |
POD_UID | Kubernetes pod UID | a1b2c3d4-e5f6-7890-abcd-ef1234567890 |
SSH (when ssh.enable is true)
| Variable | Description | Example Value |
|---|---|---|
KONDUKTOR_SSHPUB | Public SSH key for the job | ssh-rsa AAAAB3NzaC1... |
KONDUKTOR_SSHPRIV | Private SSH key for the job | -----BEGIN OPENSSH PRIVATE KEY----- |
KONDUKTOR_SSH_PORT | SSH port number | 2222 |
Git SSH (when git-ssh secret exists)
| Variable | Description | Value |
|---|---|---|
GIT_SSH_COMMAND | SSH command for Git operations | ssh -i /run/konduktor/git-ssh-secret/gitkey -o StrictHostKeyChecking=no |
Default Secrets (when default secrets exist)
| Variable | Description | Value |
|---|---|---|
KONDUKTOR_DEFAULT_SECRETS | Path to mounted default secrets | /konduktor/default-secrets |
Practical Examples
WANDB Integration
Troubleshooting
If an environment variable is not set as expected:- Check if the feature is enabled (e.g., SSH, Tailscale)
- Verify the variable name spelling
- Check the Konduktor logs for any errors
- Ensure you’re running the latest version of Konduktor