Skip to content

feat: Platform-Wide Configuration via Helm Values + ConfigMap #97

Closed

Description

@cwiklik

Problem Statement *

The kagenti-webhook currently has hardcoded values throughout the codebase for container images, resource limits, proxy settings, and other configuration:

const (
    DefaultEnvoyImage     = "ghcr.io/kagenti/kagenti-extensions/envoy-with-processor:latest"
    DefaultProxyInitImage = "ghcr.io/kagenti/kagenti-extensions/proxy-init:latest"
    EnvoyProxyUID  = 1337
    EnvoyProxyPort = 15123
)

// Resource limits scattered in Build*Container functions
Resources: corev1.ResourceRequirements{
    Limits: corev1.ResourceList{
        corev1.ResourceCPU:    resource.MustParse("200m"),   // Hardcoded
        corev1.ResourceMemory: resource.MustParse("256Mi"),  // Hardcoded
    },
}

This creates several issues:

  • No environment differentiation - Production and development use identical settings
  • Image updates require code changes - Upgrading sidecar versions means rebuilding the webhook
  • Resource tuning is impossible - Operators cannot easily adjust CPU/memory

Proposed Solution *

Implement a ConfigMap-based configuration system with values managed through Helm:

flowchart LR
    A["values.yaml(per env)"] --> B["ConfigMap"] --> C["Webhook loads config"]
Loading

Configuration Hierarchy

  1. Platform ConfigMap (from Helm) ◄── Operator-controlled defaults
    │
    ▼
  2. Compiled Defaults (in code) ◄── Fallback if ConfigMap missing

Note: Per-workload overrides via TokenExchange CR are addressed in a separate proposal: rossoctl/rossoctl#531

charts/kagenti-webhook/values.yaml

defaults:
  images:
    envoyProxy: ghcr.io/kagenti/kagenti-extensions/envoy-with-processor:v1.0.0
    proxyInit: ghcr.io/kagenti/kagenti-extensions/proxy-init:v1.0.0
    spiffeHelper: ghcr.io/spiffe/spiffe-helper:0.8.0
    clientRegistration: ghcr.io/kagenti/kagenti-extensions/client-registration:v1.0.0
    pullPolicy: IfNotPresent

  proxy:
    port: 15123
    uid: 1337
    excludePorts:
      - 8080
      - 9901
    adminPort: 9901

  resources:
    envoyProxy:
      requests:
        cpu: 50m
        memory: 64Mi
      limits:
        cpu: 200m
        memory: 256Mi
    proxyInit:
      requests:
        cpu: 10m
        memory: 10Mi
      limits:
        cpu: 10m
        memory: 10Mi
    spiffeHelper:
      requests:
        cpu: 50m
        memory: 64Mi
      limits:
        cpu: 100m
        memory: 128Mi
    clientRegistration:
      requests:
        cpu: 50m
        memory: 64Mi
      limits:
        cpu: 100m
        memory: 128Mi

  tokenExchange:
    tokenUrl: ""
    defaultAudience: ""
    defaultScopes:
      - openid

  spiffe:
    trustDomain: cluster.local
    socketPath: unix:///spiffe-workload-api/spire-agent.sock

Environment Overrides

charts/kagenti-webhook/
├── templates/
│ └── configmap-defaults.yaml ◄── ONE template (same for all envs)
└── values.yaml ◄── Base defaults

environments/
├── production/values.yaml ◄── Overrides for prod
├── staging/values.yaml ◄── Overrides for staging
└── development/values.yaml ◄── Overrides for dev

Development (environments/development/values.yaml):

defaults:
  images:
    envoyProxy: ghcr.io/kagenti/kagenti-extensions/envoy-with-processor:latest
    proxyInit: ghcr.io/kagenti/kagenti-extensions/proxy-init:latest
    pullPolicy: Always

  resources:
    envoyProxy:
      requests:
        cpu: 10m
        memory: 32Mi
      limits:
        cpu: 100m
        memory: 128Mi

  tokenExchange:
    tokenUrl: http://keycloak.keycloak.svc:8080/realms/dev/protocol/openid-connect/token
    defaultAudience: dev-services

ConfigMap

# charts/kagenti-webhook/templates/configmap-defaults.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "kagenti-webhook.fullname" . }}-defaults
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "kagenti-webhook.labels" . | nindent 4 }}
    app.kubernetes.io/component: config
data:
  config.yaml: |
{{- .Values.defaults | toYaml | nindent 4 }}

Deployment

# Production
helm upgrade --install kagenti-webhook ./charts/kagenti-webhook \
  -n kagenti-system \
  -f environments/production/values.yaml

# Development
helm upgrade --install kagenti-webhook ./charts/kagenti-webhook \
  -n kagenti-system \
  -f environments/development/values.yaml

Alternatives Considered

No response

Additional Context

No response

Priority

None

Contribution

  • I am willing to submit a pull request for this feature

Activity

  1. self-assigned this
    on Feb 4, 2026
  2. added
    enhancement
    on Feb 4, 2026
  3. added theissue type on Feb 4, 2026
  4. huang195 commented on Feb 6, 2026

    @huang195
    Member

    @cwiklik the motivation makes sense to me why we need this to make configuration dynamic. I'm not sure if per-environment configuration is the right abstraction here though. I can see use cases where even in the same namespace, we could have agents running that require different sidecar configurations.

    Additionally, requiring helm is a bit heavy handed for agent developers who might be just using kubectl to deploy. I'm wondering if some annotations or labels, or even per-namespace configmap (overriding global configmap, at least in the initial stage) would be easier from usability point of view.

  5. cwiklik commented on Feb 6, 2026

    @cwiklik
    CollaboratorAuthor

    @huang195 thanks for the comments. Devs will use TokenExchange CR to override defaults in workloads(as described here: rossoctl/rossoctl#531). The kagenti installer would install reasonable defaults via helm. Perhaps for simplicity, we start with one set of defaults instead of having one per env.

  6. cwiklik commented on Feb 9, 2026

    @cwiklik
    CollaboratorAuthor

    Multi-Layer Configuration & Precedence Design

    Building on the platform defaults ConfigMap described in this issue, the below description is a broader multi-layer configuration system that governs both sidecar enablement and configuration resolution across different scopes.

    Configuration Layers (highest to lowest precedence)

    Layer Scope Mechanism Purpose
    Global Feature Gates Cluster-wide Separate ConfigMap (kagenti-webhook-feature-gates) Kill switch to disable sidecars globally (per-sidecar + master off)
    Namespace Opt-in Namespace Namespace label (inject=true) Gate — prerequisite for any injection
    Workload Labels Workload Pod/Deployment labels Lightweight per-sidecar disable toggle
    TokenExchange CRD Workload TokenExchange CR → ConfigMap (via operator/controller) Per-workload configuration overrides and per-sidecar disable
    Platform Defaults Cluster-wide kagenti-webhook-defaults ConfigMap (this issue) Base defaults for images, resources, proxy settings, etc.

    Injection Decision (per sidecar, per workload)

    The webhook evaluates these gates top-down. The first decisive "no" short-circuits:

    1. Global feature gate says sidecar is disabled → skip (no lower layer can override)
    2. Namespace missing inject=true → skip
    3. Workload label says sidecar is disabled → skip
    4. TokenExchange CRD says sidecar is disabled → skip
    5. Platform defaults say sidecar is disabled → skip
    6. Otherwise → inject

    The global kill switch is the highest authority and cannot be overridden. This is intentional — it's the "break glass" mechanism for incidents or bad rollouts.

    Configuration Resolution (when injecting)

    Once the decision to inject is made, configuration is merged bottom-up:

    Start with: Platform Defaults ConfigMap (this issue)
    Overlay:    TokenExchange CRD fields (only fields explicitly set)
    Result:     Final sidecar spec
    

    Workload labels do not participate in configuration — they are purely enablement toggles.

    Separation of Feature Gates from Defaults

    The global enable/disable controls will live in a separate ConfigMap (kagenti-webhook-feature-gates) rather than in the defaults ConfigMap described in this issue. Rationale:

    • Separation of concerns — operational kill switches vs. configuration defaults are different concerns with different change frequencies
    • RBAC — feature gates can have tighter permissions (e.g., SRE-only) while defaults may be more broadly editable
    • Safety — a Helm upgrade to change a default image tag cannot accidentally flip a sidecar off
    • No additional complexity — the webhook already watches ConfigMaps, so watching one more is trivial

    Overlap Between Workload Labels and TokenExchange CRD

    Both workload labels and the TokenExchange CRD can disable individual sidecars at the workload level. This is intentional:

    • Labels are the lightweight, quick escape hatch — a developer can disable a sidecar without creating a CR
    • TokenExchange CRD is the richer mechanism for full configuration control, managed by the operator/controller which produces a ConfigMap the webhook monitors

    If either mechanism says a sidecar is disabled, it is not injected. This keeps the behavior simple and predictable — any explicit "off" is honored.

  7. cwiklik commented on Feb 10, 2026

    @cwiklik
    CollaboratorAuthor

    Orthogonal Concern: Runtime Reaction to Feature-Gate Changes

    During the design of the multi-layer precedence model (see comment above), an orthogonal concern surfaced that requires its own design and issue.

    The feature-gate ConfigMap and the precedence logic described here operate at admission time — the webhook evaluates them when a workload is being created. However, when an admin flips a feature gate to disable a running sidecar fleet-wide (the "nuclear option"), existing pods are unaffected. The disabled sidecar continues running in all current pods until they are recreated. Note: k8s does not support stopping individual containers within a pod, so a mechanism of disabling a sidecar needs to be designed

    This is a runtime sidecar lifecycle management problem and is fundamentally different from the configuration and precedence concerns addressed in this issue. It involves questions like how running sidecars detect gate changes, whether they can go into a passthrough/dormant mode, and whether pod rolling restarts should be triggered automatically.

  8. cwiklik commented on Feb 10, 2026

    @cwiklik
    CollaboratorAuthor

    Orthogonal Concern: Sidecar Status Observability

    As the multi-layer configuration system grows (platform defaults, feature gates, TokenExchange CRDs, namespace labels, workload labels), it becomes increasingly difficult to answer a simple question: which sidecars are actually enabled for a given workload, and why?

    Today, the only way to determine this is to inspect the running pod spec and reverse-engineer which sidecars were injected. There is no way to see:

    • Which sidecars the webhook would inject for a workload before it's deployed
    • Why a particular sidecar was or wasn't injected (which layer in the precedence chain made the decision)
    • Whether a running sidecar is in active or passthrough mode (once runtime reconfiguration is supported)
    • A fleet-wide view of sidecar injection state across namespaces and workloads
  9. cwiklik commented on Mar 2, 2026

    @cwiklik
    CollaboratorAuthor

    Closing as duplicate of #109

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

Metadata

Metadata

Assignees

Labels

enhancement

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions