-
Notifications
You must be signed in to change notification settings - Fork 6
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
only add istio automtls when label has value #10574
Changes from all commits
2854371
025603e
30dbdb5
712487c
3958c1f
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
changelog: | ||
- type: FIX | ||
issueLink: https://github.com/solo-io/gloo/issues/10575 | ||
resolvesIssue: true | ||
description: | | ||
When a workload has the label `security.istio.io/tlsMode: disabled` | ||
we will no longer attempt to send mTLS to that workload. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package istio_automtls | ||
|
||
import ( | ||
"github.com/solo-io/gloo/projects/gloo/constants" | ||
"google.golang.org/protobuf/types/known/structpb" | ||
|
||
envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" | ||
) | ||
|
||
const EnvoyTransportSocketMatch = "envoy.transport_socket_match" | ||
|
||
// AddIstioAutomtlsMetadata adds metadata used by the transport_socket_match | ||
// to select the mTLS transport socket. The Envoy metadata label is added | ||
// based on the presence of the Istio workload label "security.istio.io/tlsMode=istio". | ||
func AddIstioAutomtlsMetadata( | ||
metadata *envoy_config_core_v3.Metadata, | ||
workloadLabels map[string]string, | ||
enableAutoMtls bool, | ||
) *envoy_config_core_v3.Metadata { | ||
if enableAutoMtls { | ||
// Valid label values are 'istio', 'disabled' | ||
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. is it possible to add a link to the istio ref for these values? I already have forgotten the istio semantics regarding these 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. also just for for clarity i was thinking adding this link to the comment 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. Linked to the Istio API def that outlines it. |
||
// https://github.com/istio/api/blob/5b3f065ee1c2802fb4bc6010ac847c181caa6cc3/label/labels.gen.go#L285 | ||
if value, ok := workloadLabels[constants.IstioTlsModeLabel]; ok && value == constants.IstioMutualTLSModeLabel { | ||
metadata.GetFilterMetadata()[EnvoyTransportSocketMatch] = &structpb.Struct{ | ||
Fields: map[string]*structpb.Value{ | ||
constants.TLSModeLabelShortname: { | ||
Kind: &structpb.Value_StringValue{ | ||
StringValue: constants.IstioMutualTLSModeLabel, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
} | ||
return metadata | ||
} |
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.
nit: I know this is a copy/paste of an existing function, so I'm happy to leave it as is. It feels strange to me that we pass a boolean and only perform an action if that's true. It feels like we could just have the function only be called if the enableAutoMtls value is true
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.
Idk, I'd rather have "pass the global setting in, let some shared code interpret it" than have that conditional in multiple places, as easy as it may be.