Skip to content

Commit 6d84c99

Browse files
Merge pull request #1197 from barbacbd/CORS-3907
CORS-3907: Update ingress operator to with custom endpoints
2 parents eae9450 + 95b36d0 commit 6d84c99

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

pkg/dns/gcp/provider.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,30 @@ type Provider struct {
3131
}
3232

3333
type Config struct {
34-
Project string
35-
UserAgent string
36-
CredentialsJSON []byte
34+
Project string
35+
UserAgent string
36+
CredentialsJSON []byte
37+
Endpoints []configv1.GCPServiceEndpoint
38+
GCPCustomEndpointsEnabled bool
3739
}
3840

3941
func New(config Config) (*Provider, error) {
40-
dnsService, err := gdnsv1.NewService(context.TODO(), option.WithCredentialsJSON(config.CredentialsJSON), option.WithUserAgent(config.UserAgent))
42+
options := []option.ClientOption{
43+
option.WithCredentialsJSON(config.CredentialsJSON),
44+
option.WithUserAgent(config.UserAgent),
45+
}
46+
if config.GCPCustomEndpointsEnabled {
47+
for _, endpoint := range config.Endpoints {
48+
if endpoint.Name == configv1.GCPServiceEndpointNameDNS {
49+
// There should be at most 1 endpoint override per service. If there
50+
// is more than one, only use the first instance.
51+
options = append(options, option.WithEndpoint(endpoint.URL))
52+
break
53+
}
54+
}
55+
}
56+
57+
dnsService, err := gdnsv1.NewService(context.TODO(), options...)
4158
if err != nil {
4259
return nil, err
4360
}

pkg/operator/controller/dns/controller.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ type Config struct {
114114
// PrivateHostedZoneAWSEnabled indicates whether the "SharedVPC" feature gate is
115115
// enabled.
116116
PrivateHostedZoneAWSEnabled bool
117+
118+
// GCPCustomEndpointsEnabled indicates whether the "GCPCustomAPIEndpoints"
119+
// feature gate is enabled.
120+
GCPCustomEndpointsEnabled bool
117121
}
118122

119123
type reconciler struct {
@@ -698,9 +702,11 @@ func (r *reconciler) createDNSProvider(dnsConfig *configv1.DNS, platformStatus *
698702
dnsProvider = provider
699703
case configv1.GCPPlatformType:
700704
provider, err := gcpdns.New(gcpdns.Config{
701-
Project: platformStatus.GCP.ProjectID,
702-
CredentialsJSON: creds.Data["service_account.json"],
703-
UserAgent: userAgent,
705+
Project: platformStatus.GCP.ProjectID,
706+
CredentialsJSON: creds.Data["service_account.json"],
707+
UserAgent: userAgent,
708+
Endpoints: platformStatus.GCP.ServiceEndpoints,
709+
GCPCustomEndpointsEnabled: r.config.GCPCustomEndpointsEnabled,
704710
})
705711
if err != nil {
706712
return nil, fmt.Errorf("failed to create GCP DNS provider: %v", err)

pkg/operator/operator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func New(config operatorconfig.Config, kubeConfig *rest.Config) (*Operator, erro
137137
ingressControllerLBSubnetsAWSEnabled := featureGates.Enabled(features.FeatureGateIngressControllerLBSubnetsAWS)
138138
ingressControllerEIPAllocationsAWSEnabled := featureGates.Enabled(features.FeatureGateSetEIPForNLBIngressController)
139139
ingressControllerDCMEnabled := featureGates.Enabled(features.FeatureGateIngressControllerDynamicConfigurationManager)
140+
gcpCustomEndpointsEnabled := featureGates.Enabled(features.FeatureGateGCPCustomAPIEndpoints)
140141

141142
// Set up an operator manager for the operator namespace.
142143
mgr, err := manager.New(kubeConfig, manager.Options{
@@ -256,6 +257,7 @@ func New(config operatorconfig.Config, kubeConfig *rest.Config) (*Operator, erro
256257
OperatorReleaseVersion: config.OperatorReleaseVersion,
257258
AzureWorkloadIdentityEnabled: azureWorkloadIdentityEnabled,
258259
PrivateHostedZoneAWSEnabled: sharedVPCEnabled,
260+
GCPCustomEndpointsEnabled: gcpCustomEndpointsEnabled,
259261
}); err != nil {
260262
return nil, fmt.Errorf("failed to create dns controller: %v", err)
261263
}

0 commit comments

Comments
 (0)