Skip to content

Commit ed8e256

Browse files
committed
Add Gateway/ListenerSet controller and DNS service scaffold
- Add GatewayReconciler for K8s Gateway API: handles create/update/delete of DNS records via DNSRecordService - Add ListenerSet event handler to trigger Gateway reconciliation on ListenerSet changes - Add cmd/main.go wiring for GatewayReconciler and DNSRecordService initialization - Add DNSRecordService with public API (CreateOrUpdateDNSRecords, DeleteDNSRecordsByOwner, DeleteAllDNSRecordsInGateway, DeleteOrphanedDNSRecordsInGateway, ListGatewayNamespacedName) - Add DNSRecordStore and DNSZoneStore with indexers for owner UID and gateway namespaced name - Add unit tests for controller flow and DNS service components; E2E tests are deferred to a follow-up change This change also bump up go version to 1.25
1 parent 5434566 commit ed8e256

File tree

16 files changed

+1865
-153
lines changed

16 files changed

+1865
-153
lines changed

.github/workflows/makefile.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
runs-on: ubuntu-latest
1818

1919
steps:
20-
- uses: actions/checkout@v2
21-
20+
- uses: actions/checkout@v4
21+
2222
- name: Set up Go
23-
uses: actions/setup-go@v2
23+
uses: actions/setup-go@v5
2424
with:
25-
go-version: 1.23.1
25+
go-version-file: go.mod
2626

2727
- name: Run golangci-lint
2828
run: make golangci

cmd/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ import (
2323
"sigs.k8s.io/controller-runtime/pkg/manager"
2424
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
2525
"sigs.k8s.io/controller-runtime/pkg/webhook"
26+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
2627

2728
"github.com/vmware-tanzu/nsx-operator/pkg/apis/legacy/v1alpha1"
2829
crdv1alpha1 "github.com/vmware-tanzu/nsx-operator/pkg/apis/vpc/v1alpha1"
2930
"github.com/vmware-tanzu/nsx-operator/pkg/config"
31+
"github.com/vmware-tanzu/nsx-operator/pkg/controllers/gateway"
3032
"github.com/vmware-tanzu/nsx-operator/pkg/controllers/inventory"
3133
"github.com/vmware-tanzu/nsx-operator/pkg/controllers/ipaddressallocation"
3234
namespacecontroller "github.com/vmware-tanzu/nsx-operator/pkg/controllers/namespace"
@@ -42,6 +44,7 @@ import (
4244
subnetipreservationcontroller "github.com/vmware-tanzu/nsx-operator/pkg/controllers/subnetipreservation"
4345
"github.com/vmware-tanzu/nsx-operator/pkg/controllers/subnetport"
4446
"github.com/vmware-tanzu/nsx-operator/pkg/controllers/subnetset"
47+
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/dns"
4548
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/health"
4649
inventoryservice "github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/inventory"
4750
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/ipblocksinfo"
@@ -81,6 +84,7 @@ func init() {
8184
utilruntime.Must(crdv1alpha1.AddToScheme(scheme))
8285
utilruntime.Must(v1alpha1.AddToScheme(scheme))
8386
utilruntime.Must(vmv1alpha1.AddToScheme(scheme))
87+
utilruntime.Must(gatewayv1.AddToScheme(scheme))
8488
config.AddFlags()
8589

8690
cf, err = config.NewNSXOperatorConfigFromFile()
@@ -191,6 +195,11 @@ func startServiceController(mgr manager.Manager, nsxClient *nsx.Client) {
191195
log.Error(err, "Failed to initialize staticroute commonService", "controller", "StaticRoute")
192196
os.Exit(1)
193197
}
198+
dnsRecordService, err := dns.InitializeDNSRecordService(commonService, vpcService)
199+
if err != nil {
200+
log.Error(err, "Failed to initialize DNS record service", "controller", "DNS")
201+
os.Exit(1)
202+
}
194203
ipblocksInfoService := ipblocksinfo.InitializeIPBlocksInfoService(commonService, subnetService)
195204

196205
subnetBindingService, err := subnetbindingservice.InitializeService(commonService)
@@ -241,6 +250,7 @@ func startServiceController(mgr manager.Manager, nsxClient *nsx.Client) {
241250
pod.NewPodReconciler(mgr, subnetPortService, subnetService, vpcService, nodeService),
242251
networkpolicycontroller.NewNetworkPolicyReconciler(mgr, commonService, vpcService),
243252
service.NewServiceLbReconciler(mgr, commonService),
253+
gateway.NewGatewayReconciler(mgr, dnsRecordService),
244254
subnetbindingcontroller.NewReconciler(mgr, subnetService, subnetBindingService),
245255
subnetipreservationcontroller.NewReconciler(mgr, subnetIPReservationService, subnetService),
246256
)

go.mod

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/vmware-tanzu/nsx-operator
22

3-
go 1.23.1
3+
go 1.25.0
44

55
replace (
66
github.com/agiledragon/gomonkey => github.com/agiledragon/gomonkey/v2 v2.11.0
@@ -14,7 +14,7 @@ require (
1414
github.com/antihax/optional v1.0.0
1515
github.com/apparentlymart/go-cidr v1.1.0
1616
github.com/deckarep/golang-set v1.8.0
17-
github.com/go-logr/logr v1.4.2
17+
github.com/go-logr/logr v1.4.3
1818
github.com/go-logr/zerologr v1.2.3
1919
github.com/golang-jwt/jwt/v4 v4.5.2
2020
github.com/golang/mock v1.6.0
@@ -24,7 +24,7 @@ require (
2424
github.com/prometheus/client_golang v1.19.1
2525
github.com/rs/zerolog v1.34.0
2626
github.com/sirupsen/logrus v1.9.3
27-
github.com/stretchr/testify v1.9.0
27+
github.com/stretchr/testify v1.11.1
2828
github.com/vmware-tanzu/nsx-operator/pkg/apis v0.0.0-20241113082223-673d2e7ca974
2929
github.com/vmware-tanzu/nsx-operator/pkg/client v0.0.0-20240102061654-537b080e159f
3030
github.com/vmware-tanzu/vm-operator/api v1.8.2
@@ -36,79 +36,79 @@ require (
3636
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.0.0-20251214130913-3e87ca3a7aed
3737
go.uber.org/automaxprocs v1.5.3
3838
go.uber.org/zap v1.26.0
39-
golang.org/x/crypto v0.24.0
40-
golang.org/x/time v0.3.0
39+
golang.org/x/crypto v0.47.0
40+
golang.org/x/sync v0.19.0
41+
golang.org/x/time v0.14.0
4142
gopkg.in/ini.v1 v1.66.4
4243
gopkg.in/yaml.v2 v2.4.0
43-
k8s.io/api v0.31.2
44-
k8s.io/apimachinery v0.31.2
45-
k8s.io/client-go v0.31.2
44+
k8s.io/api v0.35.1
45+
k8s.io/apimachinery v0.35.1
46+
k8s.io/client-go v0.35.1
4647
k8s.io/code-generator v0.31.0
47-
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
48+
k8s.io/utils v0.0.0-20260108192941-914a6e750570
4849
sigs.k8s.io/controller-runtime v0.19.0
50+
sigs.k8s.io/gateway-api v1.5.0
4951
)
5052

5153
require (
5254
github.com/beevik/etree v1.1.0 // indirect
5355
github.com/beorn7/perks v1.0.1 // indirect
5456
github.com/cespare/xxhash/v2 v2.3.0 // indirect
5557
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
56-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
58+
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
5759
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
5860
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
5961
github.com/fsnotify/fsnotify v1.7.0 // indirect
60-
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
62+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
6163
github.com/gibson042/canonicaljson-go v1.0.3 // indirect
6264
github.com/go-logr/zapr v1.3.0 // indirect
63-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
64-
github.com/go-openapi/jsonreference v0.20.2 // indirect
65-
github.com/go-openapi/swag v0.22.4 // indirect
65+
github.com/go-openapi/jsonpointer v0.21.2 // indirect
66+
github.com/go-openapi/jsonreference v0.21.0 // indirect
67+
github.com/go-openapi/swag v0.23.1 // indirect
6668
github.com/gogo/protobuf v1.3.2 // indirect
67-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
68-
github.com/golang/protobuf v1.5.4 // indirect
69-
github.com/google/gnostic-models v0.6.8 // indirect
70-
github.com/google/go-cmp v0.6.0 // indirect
71-
github.com/google/gofuzz v1.2.0 // indirect
72-
github.com/gorilla/websocket v1.5.0 // indirect
73-
github.com/imdario/mergo v0.3.6 // indirect
69+
github.com/google/gnostic-models v0.7.0 // indirect
70+
github.com/google/go-cmp v0.7.0 // indirect
71+
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
7472
github.com/josharian/intern v1.0.0 // indirect
7573
github.com/json-iterator/go v1.1.12 // indirect
76-
github.com/mailru/easyjson v0.7.7 // indirect
74+
github.com/mailru/easyjson v0.9.1 // indirect
7775
github.com/mattn/go-colorable v0.1.13 // indirect
7876
github.com/mattn/go-isatty v0.0.19 // indirect
79-
github.com/moby/spdystream v0.4.0 // indirect
77+
github.com/moby/spdystream v0.5.0 // indirect
8078
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
81-
github.com/modern-go/reflect2 v1.0.2 // indirect
79+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
8280
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
8381
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
8482
github.com/pkg/errors v0.9.1 // indirect
8583
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
8684
github.com/prometheus/client_model v0.6.1 // indirect
8785
github.com/prometheus/common v0.55.0 // indirect
8886
github.com/prometheus/procfs v0.15.1 // indirect
89-
github.com/spf13/pflag v1.0.5 // indirect
87+
github.com/spf13/pflag v1.0.10 // indirect
9088
github.com/stretchr/objx v0.5.2 // indirect
9189
github.com/x448/float16 v0.8.4 // indirect
9290
go.uber.org/multierr v1.11.0 // indirect
91+
go.yaml.in/yaml/v2 v2.4.3 // indirect
92+
go.yaml.in/yaml/v3 v3.0.4 // indirect
9393
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
94-
golang.org/x/mod v0.18.0 // indirect
95-
golang.org/x/net v0.26.0 // indirect
96-
golang.org/x/oauth2 v0.21.0 // indirect
97-
golang.org/x/sync v0.7.0 // indirect
98-
golang.org/x/sys v0.21.0 // indirect
99-
golang.org/x/term v0.21.0 // indirect
100-
golang.org/x/text v0.16.0 // indirect
101-
golang.org/x/tools v0.22.0 // indirect
94+
golang.org/x/mod v0.31.0 // indirect
95+
golang.org/x/net v0.49.0 // indirect
96+
golang.org/x/oauth2 v0.34.0 // indirect
97+
golang.org/x/sys v0.40.0 // indirect
98+
golang.org/x/term v0.39.0 // indirect
99+
golang.org/x/text v0.33.0 // indirect
100+
golang.org/x/tools v0.40.0 // indirect
102101
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
103-
google.golang.org/protobuf v1.34.2 // indirect
104-
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
102+
google.golang.org/protobuf v1.36.11 // indirect
103+
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
105104
gopkg.in/inf.v0 v0.9.1 // indirect
106105
gopkg.in/yaml.v3 v3.0.1 // indirect
107106
k8s.io/apiextensions-apiserver v0.31.0 // indirect
108-
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
107+
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f // indirect
109108
k8s.io/klog/v2 v2.130.1 // indirect
110-
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
111-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
112-
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
113-
sigs.k8s.io/yaml v1.4.0 // indirect
109+
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
110+
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
111+
sigs.k8s.io/randfill v1.0.0 // indirect
112+
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
113+
sigs.k8s.io/yaml v1.6.0 // indirect
114114
)

0 commit comments

Comments
 (0)