forked from kgateway-dev/kgateway
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only add istio automtls when label has value (#10574)
- Loading branch information
Showing
3 changed files
with
45 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
// 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 | ||
} |