istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pilot/pkg/bootstrap/discovery.go (about) 1 // Copyright Istio Authors 2 // 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 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 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. 14 15 package bootstrap 16 17 import ( 18 "net/http" 19 20 "istio.io/istio/pilot/pkg/model" 21 "istio.io/istio/pilot/pkg/networking/apigen" 22 "istio.io/istio/pilot/pkg/networking/core" 23 "istio.io/istio/pilot/pkg/networking/grpcgen" 24 "istio.io/istio/pilot/pkg/xds" 25 v3 "istio.io/istio/pilot/pkg/xds/v3" 26 "istio.io/istio/pkg/cluster" 27 ) 28 29 func InitGenerators( 30 s *xds.DiscoveryServer, 31 cg core.ConfigGenerator, 32 systemNameSpace string, 33 clusterID cluster.ID, 34 internalDebugMux *http.ServeMux, 35 ) { 36 env := s.Env 37 generators := map[string]model.XdsResourceGenerator{} 38 edsGen := &xds.EdsGenerator{Cache: s.Cache, EndpointIndex: env.EndpointIndex} 39 generators[v3.ClusterType] = &xds.CdsGenerator{ConfigGenerator: cg} 40 generators[v3.ListenerType] = &xds.LdsGenerator{ConfigGenerator: cg} 41 generators[v3.RouteType] = &xds.RdsGenerator{ConfigGenerator: cg} 42 generators[v3.EndpointType] = edsGen 43 ecdsGen := &xds.EcdsGenerator{ConfigGenerator: cg} 44 if env.CredentialsController != nil { 45 generators[v3.SecretType] = xds.NewSecretGen(env.CredentialsController, s.Cache, clusterID, env.Mesh()) 46 ecdsGen.SetCredController(env.CredentialsController) 47 } 48 generators[v3.ExtensionConfigurationType] = ecdsGen 49 generators[v3.NameTableType] = &xds.NdsGenerator{ConfigGenerator: cg} 50 generators[v3.ProxyConfigType] = &xds.PcdsGenerator{TrustBundle: env.TrustBundle} 51 52 workloadGen := &xds.WorkloadGenerator{Server: s} 53 generators[v3.AddressType] = workloadGen 54 generators[v3.WorkloadType] = workloadGen 55 generators[v3.WorkloadAuthorizationType] = &xds.WorkloadRBACGenerator{Server: s} 56 57 generators["grpc"] = &grpcgen.GrpcConfigGenerator{} 58 generators["grpc/"+v3.EndpointType] = edsGen 59 generators["grpc/"+v3.ListenerType] = generators["grpc"] 60 generators["grpc/"+v3.RouteType] = generators["grpc"] 61 generators["grpc/"+v3.ClusterType] = generators["grpc"] 62 63 generators["api"] = apigen.NewGenerator(env.ConfigStore) 64 generators["api/"+v3.EndpointType] = edsGen 65 66 generators["event"] = xds.NewStatusGen(s) 67 generators[v3.DebugType] = xds.NewDebugGen(s, systemNameSpace, internalDebugMux) 68 s.Generators = generators 69 }