Skip to content

sync: add envVars injection for host-synced pods - #4281

Closed
dlenrow wants to merge 1 commit into
loft-sh:mainfrom
dlenrow:sync-envvars-injection
Closed

dlenrow wants to merge 1 commit into
loft-sh:mainfrom
dlenrow:sync-envvars-injection

Conversation

@dlenrow

@dlenrow dlenrow commented Nov 14, 2026 •

Copy link
Copy Markdown

Closed — will use existing sync.toHost.pods.patches mechanism instead.

Add sync.toHost.pods.envVars — a list of corev1.EnvVar entries injected
into every container of pods synced from the virtual cluster to the host.
Pod-authored env vars with the same name take precedence.

This is the env-var equivalent of the existing enforceTolerations field.
It lets host administrators inject node-level configuration into all
tenant pods without requiring Pro-tier patches or a separate
MutatingAdmissionWebhook.

A concrete use case: RDMA-capable clusters where libibverbs and NIXL
authorization plugins (IBV_AUTH_PLUGIN, NIXL_AUTH_PLUGIN) gate queue
pair creation and cross-agent connections. Without these env vars, any
process on the InfiniBand fabric can create QPs and access remote GPU
memory regardless of Kubernetes RBAC or tenant isolation.

Signed-off-by: Dave Lenrow <david.lenrow@illumio.com>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WcTnFKb9kfvByuu3uhPeSH
Signed-off-by: Dave Lenrow <david.lenrow@illumio.com>
@dlenrow
dlenrow requested review from a team as code owners November 14, 2026 21:13

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4fcd26b. Configure here.

injectEnforcedEnvVars(pPod.Spec.Containers, t.enforcedEnvVars)
injectEnforcedEnvVars(pPod.Spec.InitContainers, t.enforcedEnvVars)
injectEphemeralEnforcedEnvVars(pPod.Spec.EphemeralContainers, t.enforcedEnvVars)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ephemeral containers skip env injection

Medium Severity

Runtime-added ephemeral containers never receive sync.toHost.pods.envVars. Injection runs only inside Translate, while syncEphemeralContainers translates env through TranslateContainerEnv and never applies the enforced list, so later debug containers omit host-required variables.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4fcd26b. Configure here.

Comment thread config/config.go
// name take precedence. This is useful for node-level security hooks that must be
// present on all workload pods (e.g., IBV_AUTH_PLUGIN for RDMA QP creation gating).
// +optional
EnvVars []corev1.EnvVar `json:"envVars,omitempty"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config uses concrete EnvVar type

Medium Severity

EnvVars is typed as []corev1.EnvVar rather than []map[string]interface{} used by the other env fields in this package. Schema generation then emits a Quantity object with only Format, so Helm rejects valid resourceFieldRef.divisor strings.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4fcd26b. Configure here.

@dlenrow
dlenrow marked this pull request as draft November 14, 2026 21:36
@matskiv

matskiv commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

As you've described, there are ways to do this now - sync.toHost.pods.patches or a MutatingAdmissionWebhook.
IMO there is no need to add a 3rd way...

@dlenrow dlenrow closed this Nov 16, 2026
@dlenrow
dlenrow deleted the sync-envvars-injection branch November 16, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants