@@ -3,26 +3,21 @@ package controller
3
3
import (
4
4
"context"
5
5
6
- "k8s.io/client-go/rest"
7
- "k8s.io/utils/ptr"
8
- "sigs.k8s.io/controller-runtime/pkg/config"
9
-
6
+ envoycache "github.com/envoyproxy/go-control-plane/pkg/cache/v3"
10
7
"github.com/solo-io/go-utils/contextutils"
11
-
12
- glooschemes "github.com/kgateway-dev/kgateway/v2/pkg/schemes"
13
-
8
+ uzap "go.uber.org/zap"
9
+ istiokube "istio.io/istio/pkg/kube"
10
+ "istio.io/istio/pkg/kube/krt"
11
+ istiolog "istio.io/istio/pkg/log"
12
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
13
"k8s.io/apimachinery/pkg/util/sets"
14
+ "k8s.io/client-go/rest"
15
+ "k8s.io/utils/ptr"
15
16
ctrl "sigs.k8s.io/controller-runtime"
16
-
17
+ "sigs.k8s.io/controller-runtime/pkg/config"
17
18
"sigs.k8s.io/controller-runtime/pkg/healthz"
18
19
czap "sigs.k8s.io/controller-runtime/pkg/log/zap"
19
20
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
20
-
21
- envoycache "github.com/envoyproxy/go-control-plane/pkg/cache/v3"
22
- uzap "go.uber.org/zap"
23
- istiokube "istio.io/istio/pkg/kube"
24
- "istio.io/istio/pkg/kube/krt"
25
- istiolog "istio.io/istio/pkg/log"
26
21
apiv1 "sigs.k8s.io/gateway-api/apis/v1"
27
22
28
23
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/deployer"
@@ -37,6 +32,9 @@ import (
37
32
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/utils/krtutil"
38
33
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/wellknown"
39
34
"github.com/kgateway-dev/kgateway/v2/pkg/client/clientset/versioned"
35
+ glooschemes "github.com/kgateway-dev/kgateway/v2/pkg/schemes"
36
+ "github.com/kgateway-dev/kgateway/v2/pkg/utils/kubeutils"
37
+ "github.com/kgateway-dev/kgateway/v2/pkg/utils/namespaces"
40
38
)
41
39
42
40
const (
@@ -51,8 +49,8 @@ type SetupOpts struct {
51
49
52
50
KrtDebugger * krt.DebugHandler
53
51
54
- XdsHost string
55
- XdsPort int32
52
+ // static set of global Settings
53
+ GlobalSettings * settings. Settings
56
54
}
57
55
58
56
var setupLog = ctrl .Log .WithName ("setup" )
@@ -81,7 +79,6 @@ type ControllerBuilder struct {
81
79
cfg StartConfig
82
80
mgr ctrl.Manager
83
81
isOurGw func (gw * apiv1.Gateway ) bool
84
- settings settings.Settings
85
82
}
86
83
87
84
func NewControllerBuilder (ctx context.Context , cfg StartConfig ) (* ControllerBuilder , error ) {
@@ -139,6 +136,7 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil
139
136
cfg .Client ,
140
137
cli ,
141
138
setupLog ,
139
+ * cfg .SetupOpts .GlobalSettings ,
142
140
)
143
141
gwClasses := sets .New (append (cfg .SetupOpts .ExtraGatewayClasses , wellknown .GatewayClassName )... )
144
142
isOurGw := func (gw * apiv1.Gateway ) bool {
@@ -169,7 +167,6 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil
169
167
cfg : cfg ,
170
168
mgr : mgr ,
171
169
isOurGw : isOurGw ,
172
- settings : commoncol .Settings ,
173
170
}, nil
174
171
}
175
172
@@ -185,21 +182,22 @@ func pluginFactoryWithBuiltin(extraPlugins []extensionsplug.Plugin) extensions2.
185
182
func (c * ControllerBuilder ) Start (ctx context.Context ) error {
186
183
logger := contextutils .LoggerFrom (ctx ).Desugar ()
187
184
logger .Info ("starting gateway controller" )
188
- // GetXdsAddress waits for gloo-edge to populate the xds address of the server.
189
- // in the future this logic may move here and be duplicated.
190
- xdsHost , xdsPort := c .cfg .SetupOpts .XdsHost , c .cfg .SetupOpts .XdsPort
191
- if xdsHost == "" {
192
- return ctx .Err ()
193
- }
194
185
195
- logger .Info ("got xds address for deployer" , uzap .String ("xds_host" , xdsHost ), uzap .Int32 ("xds_port" , xdsPort ))
186
+ globalSettings := c .cfg .SetupOpts .GlobalSettings
187
+
188
+ xdsHost := kubeutils .ServiceFQDN (metav1.ObjectMeta {
189
+ Name : globalSettings .XdsServiceName ,
190
+ Namespace : namespaces .GetPodNamespace (),
191
+ })
192
+ xdsPort := globalSettings .XdsServicePort
193
+ logger .Info ("got xds address for deployer" , uzap .String ("xds_host" , xdsHost ), uzap .Uint32 ("xds_port" , xdsPort ))
196
194
197
- integrationEnabled := c . settings .EnableIstioIntegration
195
+ integrationEnabled := globalSettings .EnableIstioIntegration
198
196
199
197
// copy over relevant aws options (if any) from Settings
200
198
var awsInfo * deployer.AwsInfo
201
- stsCluster := c . settings .StsClusterName
202
- stsUri := c . settings .StsUri
199
+ stsCluster := globalSettings .StsClusterName
200
+ stsUri := globalSettings .StsUri
203
201
if stsCluster != "" && stsUri != "" {
204
202
awsInfo = & deployer.AwsInfo {
205
203
EnableServiceAccountCredentials : true ,
0 commit comments