Skip to content

Commit daab7e7

Browse files
author
aalexand
committed
Rebase
1 parent 7db0e58 commit daab7e7

File tree

9 files changed

+172
-123
lines changed

9 files changed

+172
-123
lines changed

charts/cluster-registry-client/crds/registry.ethos.adobe.com_clusters.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ spec:
239239
- Running
240240
- Upgrading
241241
type: string
242+
publicIPs:
243+
description: PublicIPs cluster public IPs
244+
items:
245+
type: string
246+
type: array
242247
region:
243248
description: Cluster internal region name
244249
type: string

cmd/client/client.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ import (
1818
"fmt"
1919
registryv1alpha1 "github.com/adobe/cluster-registry/pkg/api/registry/v1alpha1"
2020
"github.com/adobe/cluster-registry/pkg/client/controllers"
21+
"github.com/adobe/cluster-registry/pkg/client/publicip"
2122
"github.com/adobe/cluster-registry/pkg/config"
2223
monitoring "github.com/adobe/cluster-registry/pkg/monitoring/client"
2324
"github.com/adobe/cluster-registry/pkg/sqs"
25+
"github.com/go-co-op/gocron/v2"
2426
"github.com/prometheus/client_golang/prometheus/promhttp"
2527
"k8s.io/apimachinery/pkg/runtime/schema"
2628
"k8s.io/client-go/discovery"
2729
"k8s.io/client-go/tools/leaderelection/resourcelock"
2830
"net/http"
2931
"os"
3032
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
33+
"time"
3134

3235
configv1 "github.com/adobe/cluster-registry/pkg/api/config/v1"
3336
registryv1 "github.com/adobe/cluster-registry/pkg/api/registry/v1"
@@ -199,6 +202,46 @@ func main() {
199202
os.Exit(1)
200203
}
201204
}()
205+
go func() {
206+
scanInterval := 60 * time.Second
207+
208+
setupLog.Info("starting public IP scanner",
209+
"interval", fmt.Sprintf("%s", scanInterval))
210+
scheduler, err := gocron.NewScheduler(gocron.WithLocation(time.UTC))
211+
defer func() { _ = scheduler.Shutdown() }()
212+
213+
if err != nil {
214+
setupLog.Error(err, "failed to create scheduler")
215+
os.Exit(1)
216+
}
217+
218+
scanner, err := publicip.NewScanner(func(o *publicip.Options) {
219+
o.Client = mgr.GetClient()
220+
o.Logger = ctrl.Log.WithName("publicip-scanner")
221+
o.Namespace = clientConfig.Namespace
222+
})
223+
224+
if err != nil {
225+
setupLog.Error(err, "failed to create public IP scanner")
226+
os.Exit(1)
227+
}
228+
229+
job, err := scheduler.NewJob(
230+
gocron.DurationJob(scanInterval),
231+
gocron.NewTask(scanner.Run, ctx),
232+
)
233+
234+
if err != nil {
235+
setupLog.Error(err, "failed to schedule public IP scanner job")
236+
os.Exit(1)
237+
}
238+
239+
scheduler.Start()
240+
setupLog.Info("started public IP scanner job",
241+
"id", job.ID(),
242+
"interval", fmt.Sprintf("%s", scanInterval))
243+
select {}
244+
}()
202245

203246
setupLog.Info("starting cluster-registry-client")
204247
if err := mgr.Start(ctx); err != nil {

config/crd/bases/registry.ethos.adobe.com_clusters.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ spec:
239239
- Running
240240
- Upgrading
241241
type: string
242+
publicIPs:
243+
description: PublicIPs cluster public IPs
244+
items:
245+
type: string
246+
type: array
242247
region:
243248
description: Cluster internal region name
244249
type: string

go.mod

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/adobe/cluster-registry
22

3-
go 1.23.0
4-
5-
toolchain go1.23.4
3+
go 1.23.4
64

75
require (
86
dario.cat/mergo v1.0.1
@@ -12,6 +10,7 @@ require (
1210
github.com/eko/gocache/lib/v4 v4.1.6
1311
github.com/eko/gocache/store/redis/v4 v4.2.2
1412
github.com/evanphx/json-patch/v5 v5.9.0
13+
github.com/go-co-op/gocron/v2 v2.12.4
1514
github.com/go-jose/go-jose/v3 v3.0.3
1615
github.com/go-logr/logr v1.4.2
1716
github.com/go-redis/redismock/v9 v9.2.0
@@ -85,16 +84,14 @@ require (
8584
github.com/go-playground/locales v0.14.1 // indirect
8685
github.com/go-playground/universal-translator v0.18.1 // indirect
8786
github.com/gogo/protobuf v1.3.2 // indirect
88-
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
8987
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
90-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
9188
github.com/golang/mock v1.6.0 // indirect
9289
github.com/golang/protobuf v1.5.4 // indirect
9390
github.com/google/gnostic-models v0.6.8 // indirect
9491
github.com/google/go-cmp v0.6.0 // indirect
9592
github.com/google/gofuzz v1.2.0 // indirect
96-
github.com/imdario/mergo v0.3.6 // indirect
9793
github.com/jmespath/go-jmespath v0.4.0 // indirect
94+
github.com/jonboulle/clockwork v0.4.0 // indirect
9895
github.com/josharian/intern v1.0.0 // indirect
9996
github.com/klauspost/compress v1.17.9 // indirect
10097
github.com/kylelemons/godebug v1.1.0 // indirect
@@ -116,7 +113,6 @@ require (
116113
github.com/morikuni/aec v1.0.0 // indirect
117114
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
118115
github.com/nxadm/tail v1.4.8 // indirect
119-
github.com/onsi/ginkgo/v2 v2.21.0 // indirect
120116
github.com/opencontainers/go-digest v1.0.0 // indirect
121117
github.com/opencontainers/image-spec v1.1.0 // indirect
122118
github.com/pkg/errors v0.9.1 // indirect
@@ -125,6 +121,7 @@ require (
125121
github.com/prometheus/client_model v0.6.1 // indirect
126122
github.com/prometheus/common v0.55.0 // indirect
127123
github.com/prometheus/procfs v0.15.1 // indirect
124+
github.com/robfig/cron/v3 v3.0.1 // indirect
128125
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
129126
github.com/shoenig/go-m1cpu v0.1.6 // indirect
130127
github.com/sirupsen/logrus v1.9.3 // indirect
@@ -151,7 +148,6 @@ require (
151148
golang.org/x/time v0.8.0 // indirect
152149
golang.org/x/tools v0.28.0 // indirect
153150
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
154-
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect
155151
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
156152
google.golang.org/grpc v1.66.2 // indirect
157153
google.golang.org/protobuf v1.35.1 // indirect

0 commit comments

Comments
 (0)