Feat: Expose configurable iptables backend (IPTABLES_CMD) for proxy-init#432
Merged
Merged
Conversation
Adds an optional ProxyConfig.IptablesCmd that the webhook injects as the
IPTABLES_CMD env var on the proxy-init init container (both redirect and
enforce-redirect modes). Empty by default — proxy-init then auto-detects
the backend from /proc/modules (kagenti-extensions#518). The override is
the deterministic, per-platform escape hatch: set it to "iptables" (nft)
on nft-only platforms (OpenShift/ROSA) or "iptables-legacy" to force a
backend where auto-detection is wrong or undesired.
- config: ProxyConfig.IptablesCmd (json/yaml tags), empty compiled default,
logged in logConfig.
- injector: append IPTABLES_CMD env only when non-empty, after the mode
switch so both modes are covered; default injection stays unchanged.
- chart: defaults.proxy.iptablesCmd ("") in values.yaml, documented.
- tests: assert IPTABLES_CMD is absent by default and present with the
configured value in both modes.
Companion to kagenti-extensions#518 (the script-side /proc/modules
detection + loud-fail). The script is self-sufficient without this; this
gives operators a deterministic per-platform override. Pre-existing
golangci-lint findings in untouched files (pod_mutator.go,
volume_builder_test.go) are out of scope.
Refs kagenti-extensions#518, kagenti-extensions#502
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
Reject an unrecognized proxy.iptablesCmd in PlatformConfig.Validate() so a
chart typo fails fast at operator startup (and is retained-safe on hot
reload) rather than surfacing as a per-injected-pod proxy-init crash.
Allowed set is the binaries shipped in the proxy-init image plus ""
(auto-detect): iptables, iptables-nft, iptables-legacy. Note iptables-nft
is included — it is a documented IPTABLES_CMD override value in
kagenti-extensions, so the stricter {iptables, iptables-legacy} set
suggested in review would reject a valid value.
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
4 tasks
esnible
approved these changes
Jun 16, 2026
esnible
left a comment
Member
There was a problem hiding this comment.
Clean, well-scoped PR. Adds an optional ProxyConfig.IptablesCmd knob injecting IPTABLES_CMD into the proxy-init container (both modes, omitted when empty) as the deterministic operator-side companion to the /proc/modules auto-detection in kagenti-extensions#518.
Verified:
- End-to-end wiring:
values.yamldefaults.proxy.iptablesCmd→configmap-platform-defaults.yaml(.Values.defaults | toYaml) →yaml.Unmarshal(loader honors the new json/yaml tags) →ProxyConfig.IptablesCmd→ env injection. - Validation whitelist matches real binaries:
iptables,iptables-nft,iptables-legacyall exist in the proxy-init image (confirmediptables-nftships in the Alpine 3.23iptablespackage at/usr/sbin/iptables-nft;iptables-legacyvia its own package per ext-518 Dockerfile). The Validate() check genuinely prevents the per-injected-pod init crash it documents. - Script contract: ext-518's
detect_iptables_cmd()short-circuits on a non-emptyIPTABLES_CMD, else falls back to/proc/modules. Matches. - Dual-mode parity:
IPTABLES_CMDappended after the mode switch, same config source for bothredirectandenforce-redirect; the new test asserts this across both modes. - Tests are assertive: default-absent, configured-present (both modes), and validation accept/reject incl. typo rejection.
All 16 CI checks pass; both commits signed off and use Assisted-By. No blocking, suggestion, or nit issues.
Assisted-By: Claude Code
varshaprasad96
added a commit
to varshaprasad96/kagenti-operator
that referenced
this pull request
Jun 18, 2026
Add missing workloadKind parameter to 10 InjectAuthBridge test calls introduced by upstream PRs (rossoctl#436 egress enforcement, rossoctl#434 namespace realm, rossoctl#432 iptables backend) that merged after this branch diverged. Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com> Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Exposes an optional, configurable iptables backend for the injected
proxy-initcontainer. New
ProxyConfig.IptablesCmdis injected as theIPTABLES_CMDenvvar (both
redirectandenforce-redirectmodes), omitted when empty.Why
Companion to rossoctl/cortex#518, which switches
proxy-init'sdetect_iptables_cmd()to a/proc/modulesfunctional check (iptable_natloaded → legacy, as on Kind/kubeadm; absent → nft, as on OpenShift/ROSA) and
adds loud-fail on misprogram. That script change is self-sufficient — it
auto-detects correctly without operator input. This PR adds the deterministic
per-platform override: an operator/admin can pin the backend (e.g.
iptableson nft-only platforms) where auto-detection is wrong or undesired,without rebuilding the image.
Default is empty, so behavior is unchanged unless explicitly set.
Changes
config:ProxyConfig.IptablesCmd(json/yaml tags), empty compiled default, logged inlogConfig.injector: appendIPTABLES_CMDenv only when non-empty, after the mode switch (covers both modes); default injection unchanged.chart:defaults.proxy.iptablesCmd: ""invalues.yaml, documented.tests:IPTABLES_CMDabsent by default; present with the configured value in both modes.Testing
go build ./...,go vet ./internal/webhook/...,go test ./internal/webhook/{config,injector}/...— all pass (incl. the newTestBuildProxyInitContainer_IptablesCmd).gofmtclean;helm lint charts/kagenti-operatorpasses.pod_mutator.go/volume_builder_test.goare out of scope.)Notes
container_t→ nf_tables SELinux denial; the SELinux/SCC track is separate (kagenti-extensions#502).iptableswhen the operator detects OpenShift (detection already exists ininternal/bootstrap/otel.go), but it's intentionally left as an explicit knob here since the script auto-detects.Refs rossoctl/cortex#518, rossoctl/cortex#502
Assisted-By: Claude (Anthropic AI) noreply@anthropic.com