Skip to content

feat: Make OUTBOUND_PORTS_EXCLUDE configurable via annotation or ConfigMap #235

Closed

Description

@mrsabath

Problem

The proxy-init init container has OUTBOUND_PORTS_EXCLUDE hardcoded to 8080 (Keycloak port) in container_builder.go. When agents need to reach services that don't participate in token exchange — such as a local Ollama instance on port 11434 — the traffic gets intercepted by Envoy and fails.

Currently, the only workaround is manually patching the deployment after each deploy:

kubectl patch deployment <agent> -n <ns> --type=json \
  -p='[{"op":"replace","path":"/spec/template/spec/initContainers/0/env/3/value","value":"8080,11434"}]'

This patch is lost every time the agent is redeployed via the Kagenti UI.

Proposal

Make OUTBOUND_PORTS_EXCLUDE configurable through one or more of:

  1. Pod annotation (most flexible, per-workload):

    annotations:
      kagenti.io/outbound-ports-exclude: "8080,11434"
  2. authbridge-config ConfigMap (namespace-wide default):

    OUTBOUND_PORTS_EXCLUDE: "8080,11434"
  3. Helm values (cluster-wide default):

    webhook:
      proxyInit:
        outboundPortsExclude: "8080,11434"

The webhook should merge the configured exclusions with the mandatory 8080 (Keycloak) exclusion so that 8080 is always excluded.

Use Case

The GitHub Issue Agent demo uses a local Ollama instance (host.docker.internal:11434) for LLM inference. Without excluding port 11434 from the iptables redirect, the Ollama HTTP calls are intercepted by Envoy and fail with Connection refused.

This affects any agent using a non-Keycloak HTTP service that doesn't require token exchange (LLM endpoints, telemetry collectors, etc.).

References

  • Hardcoded value: kagenti-webhook/internal/webhook/injector/container_builder.go line 475-476
  • Related: AuthBridge/AuthProxy/init-iptables.sh (OUTBOUND_PORTS_EXCLUDE env var)
  • Discovered during GitHub Issue Agent demo testing

Activity

  1. added
    enhancement
    on Mar 15, 2026
  2. huang195 commented on Mar 15, 2026

    @huang195
    Member

    Design Analysis

    After reviewing the codebase, here's a refined approach that simplifies the original proposal.

    Drop the authbridge-config ConfigMap tier

    authbridge-config is an auth configuration resource — it holds Keycloak URLs, realm, token policies. Port exclusion is a network interception concern that exists even when token exchange is completely disabled. Any workload with kagenti.io/type: agent gets proxy-init + iptables interception regardless of whether authbridge-config exists. Requiring users to create an auth ConfigMap just to exclude ports conflates two independent concerns.

    Recommended: two tiers instead of three

    1. Helm values / PlatformConfig (cluster-wide default):

      defaults:
        proxy:
          outboundPortsExclude: "11434"

      This uses the existing PlatformConfig system that's already wired into ContainerBuilder with hot-reload support. Add OutboundPortsExclude to ProxyConfig in config/types.go, default to "" in CompiledDefaults(), expose via Helm at defaults.proxy.outboundPortsExclude.

    2. Pod annotation (per-workload override):

      annotations:
        kagenti.io/outbound-ports-exclude: "11434,9200"

      The webhook reads this annotation and uses it instead of the PlatformConfig default when present.

    Keycloak 8080 safety

    Rather than hardcoding 8080 in the shell script or relying on users to include it, BuildProxyInitContainer() always prepends 8080 to whatever user-configured value it receives (from PlatformConfig or annotation). This guarantees the Keycloak port is never accidentally omitted, regardless of configuration source.

    Same approach for INBOUND_PORTS_EXCLUDE

    Apply the same two-tier pattern for INBOUND_PORTS_EXCLUDE (currently not set by the webhook at all) to avoid a separate issue later.

  3. mrsabath commented on Mar 15, 2026

    @mrsabath
    MemberAuthor

    Open PR #158 implements option 1 (annotation-based port exclusion). Review posted with requested changes (DCO fix, input validation, revert personal image). Options 2 (ConfigMap) and 3 (Helm values) can be follow-up PRs once #158 lands.

  4. huang195 commented on Mar 15, 2026

    @huang195
    Member

    @mrsabath regarding option 2 (from above):

    Drop the authbridge-config ConfigMap tier
    authbridge-config is an auth configuration resource — it holds Keycloak URLs, realm, token policies. Port exclusion is a network interception concern that exists even when token exchange is completely disabled. Any workload with kagenti.io/type: agent gets proxy-init + iptables interception regardless of whether authbridge-config exists. Requiring users to create an auth ConfigMap just to exclude ports conflates two independent concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions