@@ -63,6 +63,10 @@ const (
6363 // Value is a JSON array of skill names, set by the kagenti backend or the user.
6464 AnnotationSkills = "kagenti.io/skills"
6565
66+ // AnnotationMTLSMode is the annotation applied to PodTemplateSpec to advertise the
67+ // resolved mTLS posture. Read by authbridge sidecars for observability.
68+ AnnotationMTLSMode = "kagenti.io/mtls-mode"
69+
6670 // AnnotationRestartPending marks a Sandbox that was scaled to 0 and needs
6771 // to be scaled back to 1 on the next reconcile cycle. Two-phase restart
6872 // avoids a race with the Sandbox controller's pod-name annotation.
@@ -72,6 +76,7 @@ const (
7276 ConditionTypeReady = "Ready"
7377 ConditionTypeTargetResolved = "TargetResolved"
7478 ConditionTypeConfigResolved = "ConfigResolved"
79+ ConditionTypeMTLSReady = "MTLSReady"
7580
7681 // AnnotationLastCardFetchHash stores the change-detection key used to skip
7782 // redundant card fetches when the workload's pod template has not changed.
@@ -333,6 +338,12 @@ func (r *AgentRuntimeReconciler) applyWorkloadConfig(ctx context.Context, rt *ag
333338
334339 key := types.NamespacedName {Name : ref .Name , Namespace : rt .Namespace }
335340
341+ // Resolve mTLS mode: CR value takes precedence, default to "permissive".
342+ mtlsMode := rt .Spec .MTLSMode
343+ if mtlsMode == "" {
344+ mtlsMode = "permissive"
345+ }
346+
336347 var configHashChanged bool
337348
338349 err := retry .RetryOnConflict (retry .DefaultRetry , func () error {
@@ -348,7 +359,8 @@ func (r *AgentRuntimeReconciler) applyWorkloadConfig(ctx context.Context, rt *ag
348359 alreadyConfigured := currentWorkloadLabels [LabelAgentType ] == string (rt .Spec .Type ) &&
349360 currentWorkloadLabels [LabelManagedBy ] == LabelManagedByValue &&
350361 currentPodLabels [LabelAgentType ] == string (rt .Spec .Type ) &&
351- currentPodAnnotations [AnnotationConfigHash ] == configHash
362+ currentPodAnnotations [AnnotationConfigHash ] == configHash &&
363+ currentPodAnnotations [AnnotationMTLSMode ] == mtlsMode
352364
353365 if alreadyConfigured {
354366 return nil
@@ -375,19 +387,21 @@ func (r *AgentRuntimeReconciler) applyWorkloadConfig(ctx context.Context, rt *ag
375387 podLabels [LabelAgentType ] = string (rt .Spec .Type )
376388 acc .setPodLabels (acc .obj , podLabels )
377389
378- // Apply config-hash annotation to PodTemplateSpec
390+ // Apply config-hash and mtls-mode annotations to PodTemplateSpec
379391 podAnnotations := acc .getPodAnnotations (acc .obj )
380392 if podAnnotations == nil {
381393 podAnnotations = make (map [string ]string )
382394 }
383395 podAnnotations [AnnotationConfigHash ] = configHash
396+ podAnnotations [AnnotationMTLSMode ] = mtlsMode
384397 acc .setPodAnnotations (acc .obj , podAnnotations )
385398
386399 logger .Info ("Applying config to workload" ,
387400 "workload" , ref .Name ,
388401 "kind" , ref .Kind ,
389402 "type" , string (rt .Spec .Type ),
390- "configHash" , configHash [:12 ])
403+ "configHash" , configHash [:12 ],
404+ "mtlsMode" , mtlsMode )
391405
392406 return r .Update (ctx , acc .obj )
393407 })
@@ -725,11 +739,12 @@ func (r *AgentRuntimeReconciler) handleDeletion(ctx context.Context, rt *agentv1
725739 delete (podLabels , LabelAgentType )
726740 acc .setPodLabels (acc .obj , podLabels )
727741
728- // Remove kagenti.io/config-hash from PodTemplateSpec pod annotations.
729- // This triggers the rolling update that replaces existing injected pods,
730- // and leaves the workload annotation-clean for any future AR.
742+ // Remove kagenti.io/config-hash and kagenti.io/mtls-mode from PodTemplateSpec
743+ // pod annotations. This triggers the rolling update that replaces existing
744+ // injected pods, and leaves the workload annotation-clean for any future AR.
731745 podAnnotations := acc .getPodAnnotations (acc .obj )
732746 delete (podAnnotations , AnnotationConfigHash )
747+ delete (podAnnotations , AnnotationMTLSMode )
733748 acc .setPodAnnotations (acc .obj , podAnnotations )
734749
735750 logger .Info ("Removed kagenti labels and config-hash from workload on AgentRuntime deletion" ,
0 commit comments