-
Notifications
You must be signed in to change notification settings - Fork 41
feat: default mTLS to permissive and enable card discovery #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -257,7 +257,7 @@ func (m *PodMutator) InjectAuthBridge(ctx context.Context, podSpec *corev1.PodSp | |
| } | ||
| } | ||
| if mtlsMode == "" { | ||
| mtlsMode = MTLSModeDisabled | ||
| mtlsMode = MTLSModePermissive | ||
| mtlsSource = "default" | ||
| } | ||
| // Defense in depth: the CRD enum check rejects unknown values at | ||
|
|
@@ -270,10 +270,10 @@ func (m *PodMutator) InjectAuthBridge(ctx context.Context, podSpec *corev1.PodSp | |
| case MTLSModeDisabled, MTLSModePermissive, MTLSModeStrict: | ||
| // recognized, keep as-is | ||
| default: | ||
| mutatorLog.Info("WARN: unrecognized mtlsMode; defaulting to disabled", | ||
| mutatorLog.Info("WARN: unrecognized mtlsMode; defaulting to permissive", | ||
| "namespace", namespace, "crName", crName, | ||
| "unrecognized", mtlsMode, "source", mtlsSource) | ||
| mtlsMode = MTLSModeDisabled | ||
| mtlsMode = MTLSModePermissive | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: The defense-in-depth fallback for an unrecognized |
||
| mtlsSource = "default-invalid-fallback" | ||
| } | ||
| mutatorLog.Info("resolved mTLS mode", | ||
|
|
@@ -516,6 +516,15 @@ func (m *PodMutator) InjectAuthBridge(ctx context.Context, podSpec *corev1.PodSp | |
| )) | ||
| } | ||
|
|
||
| // Set MTLS_MODE env var on the authbridge container so it knows the | ||
| // resolved mTLS posture at runtime. | ||
| for i := range podSpec.Containers { | ||
| if podSpec.Containers[i].Name == AuthBridgeProxyContainerName { | ||
| setOrAddEnv(&podSpec.Containers[i], "MTLS_MODE", mtlsMode) | ||
| break | ||
| } | ||
| } | ||
|
|
||
| // Inject HTTP_PROXY env vars into all existing app containers | ||
| for i := range podSpec.Containers { | ||
| c := &podSpec.Containers[i] | ||
|
|
@@ -620,6 +629,14 @@ func (m *PodMutator) InjectAuthBridge(ctx context.Context, podSpec *corev1.PodSp | |
| podSpec.Containers = append(podSpec.Containers, builder.BuildEnvoyProxyContainerWithSpireOption(spireEnabled)) | ||
| } | ||
|
|
||
| // Set MTLS_MODE env var on the envoy-sidecar authbridge container. | ||
| for i := range podSpec.Containers { | ||
| if podSpec.Containers[i].Name == EnvoyProxyContainerName { | ||
| setOrAddEnv(&podSpec.Containers[i], "MTLS_MODE", mtlsMode) | ||
| break | ||
| } | ||
| } | ||
|
|
||
| if decision.ProxyInit.Inject && !containerExists(podSpec.InitContainers, ProxyInitContainerName) { | ||
| outboundExclude := annotations[OutboundPortsExcludeAnnotation] | ||
| inboundExclude := annotations[InboundPortsExcludeAnnotation] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: This default flip has a notable upgrade impact worth surfacing. Per the field doc,
mtlsMode != disabledauto-enables SPIRE and changing the mode triggers a pod rollout. So on operator upgrade, every existing AgentRuntime with an unsetmtlsModeflips empty→permissive → SPIRE auto-enabled + pod rollout, fleet-wide. permissive is designed to be safe (accepts/falls back to plaintext), but on clusters without SPIRE this relies entirely on graceful fallback — and the "deploy without SPIRE, verify graceful fallback" E2E box is still unchecked in the test plan. Recommend verifying the no-SPIRE path before merge and calling out the rollout + SPIRE auto-enable in release notes / a prominent startup log (the existing startup logs cover card-discovery/verified-fetch but not the mTLS default change).