1
// Copyright Istio Authors
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
20
core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
21
tls "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
22
"google.golang.org/protobuf/types/known/durationpb"
26
// SDSClusterName is the name of the cluster for SDS connections
27
SDSClusterName = "sds-grpc"
29
// SDSDefaultResourceName is the default name in sdsconfig, used for fetching normal key/cert.
30
SDSDefaultResourceName = "default"
32
// SDSRootResourceName is the sdsconfig name for root CA, used for fetching root cert.
33
SDSRootResourceName = "ROOTCA"
36
// Preconfigured SDS configs to avoid excessive memory allocations
38
defaultSDSConfig = &tls.SdsSecretConfig{
39
Name: SDSDefaultResourceName,
40
SdsConfig: &core.ConfigSource{
41
ConfigSourceSpecifier: &core.ConfigSource_ApiConfigSource{
42
ApiConfigSource: &core.ApiConfigSource{
43
ApiType: core.ApiConfigSource_GRPC,
44
SetNodeOnFirstMessageOnly: true,
45
TransportApiVersion: core.ApiVersion_V3,
46
GrpcServices: []*core.GrpcService{
48
TargetSpecifier: &core.GrpcService_EnvoyGrpc_{
49
EnvoyGrpc: &core.GrpcService_EnvoyGrpc{ClusterName: SDSClusterName},
55
ResourceApiVersion: core.ApiVersion_V3,
56
InitialFetchTimeout: durationpb.New(time.Second * 0),
59
rootSDSConfig = &tls.SdsSecretConfig{
60
Name: SDSRootResourceName,
61
SdsConfig: &core.ConfigSource{
62
ConfigSourceSpecifier: &core.ConfigSource_ApiConfigSource{
63
ApiConfigSource: &core.ApiConfigSource{
64
ApiType: core.ApiConfigSource_GRPC,
65
SetNodeOnFirstMessageOnly: true,
66
TransportApiVersion: core.ApiVersion_V3,
67
GrpcServices: []*core.GrpcService{
69
TargetSpecifier: &core.GrpcService_EnvoyGrpc_{
70
EnvoyGrpc: &core.GrpcService_EnvoyGrpc{ClusterName: SDSClusterName},
76
ResourceApiVersion: core.ApiVersion_V3,
77
InitialFetchTimeout: durationpb.New(time.Second * 0),
82
// ConstructSdsSecretConfig constructs SDS Secret Configuration for workload proxy.
83
func ConstructSdsSecretConfig(name string) *tls.SdsSecretConfig {
88
if name == SDSDefaultResourceName {
89
return defaultSDSConfig
91
if name == SDSRootResourceName {
95
cfg := &tls.SdsSecretConfig{
97
SdsConfig: &core.ConfigSource{
98
ConfigSourceSpecifier: &core.ConfigSource_ApiConfigSource{
99
ApiConfigSource: &core.ApiConfigSource{
100
SetNodeOnFirstMessageOnly: true,
101
ApiType: core.ApiConfigSource_GRPC,
102
TransportApiVersion: core.ApiVersion_V3,
103
GrpcServices: []*core.GrpcService{
105
TargetSpecifier: &core.GrpcService_EnvoyGrpc_{
106
EnvoyGrpc: &core.GrpcService_EnvoyGrpc{ClusterName: SDSClusterName},
112
ResourceApiVersion: core.ApiVersion_V3,