Repository navigation
Description
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"]
Configuration Hierarchy
- Platform ConfigMap (from Helm) ◄── Operator-controlled defaults
│
▼ - 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
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
huang195 commentedon Feb 6, 2026
@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
kubectlto 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.cwiklik commentedon Feb 6, 2026
@huang195 thanks for the comments. Devs will use
TokenExchange CRto 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.cwiklik commentedon Feb 9, 2026
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)
kagenti-webhook-feature-gates)inject=true)kagenti-webhook-defaultsConfigMap (this issue)Injection Decision (per sidecar, per workload)
The webhook evaluates these gates top-down. The first decisive "no" short-circuits:
inject=true→ skipThe 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:
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: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:
If either mechanism says a sidecar is disabled, it is not injected. This keeps the behavior simple and predictable — any explicit "off" is honored.
cwiklik commentedon Feb 10, 2026
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.
cwiklik commentedon Feb 10, 2026
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:
cwiklik commentedon Mar 2, 2026
Closing as duplicate of #109