Skip to content

Commit 0d25ce8

Browse files
committed
fix(webhook): skip credential annotation pre-population in federated-jwt mode
The webhook pre-populates AnnotationKeycloakClientSecretName so pods can mount the credential Secret before the controller reconciles. In federated-jwt mode no Secret is created, so injecting this annotation leaves pods stuck in Init waiting for a Secret that never appears. Fix: read CLIENT_AUTH_TYPE from authbridge-config before pre-populating the annotation and skip it when federated-jwt is configured. Signed-off-by: Alan Cha <alan.cha@ibm.com> Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Alan Cha <Alan.cha1@ibm.com>
1 parent a820271 commit 0d25ce8

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

kagenti-operator/internal/webhook/v1alpha1/authbridge_webhook.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,23 @@ func (w *AuthBridgeWebhook) Handle(ctx context.Context, req admission.Request) a
9696
// kubelet will wait for the Secret to appear and mount it — no pod restart required.
9797
// Without this, the first pod comes up with an empty /shared/ and envoy returns 503
9898
// "identity not yet configured (credentials pending)" until the user deletes the pod.
99+
//
100+
// Skip in federated-jwt mode: AuthBridge reads JWT-SVIDs from the SPIFFE workload API
101+
// socket directly and no credential Secret is created or needed. Injecting the volume
102+
// mount for a non-existent Secret would leave pods stuck in Init.
99103
if pod.Annotations[injector.AnnotationKeycloakClientSecretName] == "" &&
100104
clientreg.WorkloadWantsOperatorClientReg(pod.Labels, w.Mutator.GetFeatureGates().InjectTools) {
101-
if pod.Annotations == nil {
102-
pod.Annotations = map[string]string{}
105+
nsConfig, _ := injector.ReadNamespaceConfig(ctx, w.Mutator.APIReader, req.Namespace)
106+
if nsConfig == nil || nsConfig.ClientAuthType != injector.ClientAuthTypeFederatedJWT {
107+
if pod.Annotations == nil {
108+
pod.Annotations = map[string]string{}
109+
}
110+
pod.Annotations[injector.AnnotationKeycloakClientSecretName] =
111+
clientreg.KeycloakClientCredentialsSecretName(req.Namespace, resourceName)
112+
authbridgelog.Info("pre-populated Keycloak client credentials annotation",
113+
"namespace", req.Namespace, "name", resourceName,
114+
"secret", pod.Annotations[injector.AnnotationKeycloakClientSecretName])
103115
}
104-
pod.Annotations[injector.AnnotationKeycloakClientSecretName] =
105-
clientreg.KeycloakClientCredentialsSecretName(req.Namespace, resourceName)
106-
authbridgelog.Info("pre-populated Keycloak client credentials annotation",
107-
"namespace", req.Namespace, "name", resourceName,
108-
"secret", pod.Annotations[injector.AnnotationKeycloakClientSecretName])
109116
}
110117

111118
// Check if already injected (idempotency / reinvocation)

0 commit comments

Comments
 (0)