Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
aalexand committed Dec 18, 2024
1 parent 7db0e58 commit daab7e7
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ spec:
- Running
- Upgrading
type: string
publicIPs:
description: PublicIPs cluster public IPs
items:
type: string
type: array
region:
description: Cluster internal region name
type: string
Expand Down
43 changes: 43 additions & 0 deletions cmd/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ import (
"fmt"
registryv1alpha1 "github.com/adobe/cluster-registry/pkg/api/registry/v1alpha1"
"github.com/adobe/cluster-registry/pkg/client/controllers"
"github.com/adobe/cluster-registry/pkg/client/publicip"
"github.com/adobe/cluster-registry/pkg/config"
monitoring "github.com/adobe/cluster-registry/pkg/monitoring/client"
"github.com/adobe/cluster-registry/pkg/sqs"
"github.com/go-co-op/gocron/v2"
"github.com/prometheus/client_golang/prometheus/promhttp"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/discovery"
"k8s.io/client-go/tools/leaderelection/resourcelock"
"net/http"
"os"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"time"

configv1 "github.com/adobe/cluster-registry/pkg/api/config/v1"
registryv1 "github.com/adobe/cluster-registry/pkg/api/registry/v1"
Expand Down Expand Up @@ -199,6 +202,46 @@ func main() {
os.Exit(1)
}
}()
go func() {
scanInterval := 60 * time.Second

setupLog.Info("starting public IP scanner",
"interval", fmt.Sprintf("%s", scanInterval))
scheduler, err := gocron.NewScheduler(gocron.WithLocation(time.UTC))
defer func() { _ = scheduler.Shutdown() }()

if err != nil {
setupLog.Error(err, "failed to create scheduler")
os.Exit(1)
}

scanner, err := publicip.NewScanner(func(o *publicip.Options) {
o.Client = mgr.GetClient()
o.Logger = ctrl.Log.WithName("publicip-scanner")
o.Namespace = clientConfig.Namespace
})

if err != nil {
setupLog.Error(err, "failed to create public IP scanner")
os.Exit(1)
}

job, err := scheduler.NewJob(
gocron.DurationJob(scanInterval),
gocron.NewTask(scanner.Run, ctx),
)

if err != nil {
setupLog.Error(err, "failed to schedule public IP scanner job")
os.Exit(1)
}

scheduler.Start()
setupLog.Info("started public IP scanner job",
"id", job.ID(),
"interval", fmt.Sprintf("%s", scanInterval))
select {}
}()

setupLog.Info("starting cluster-registry-client")
if err := mgr.Start(ctx); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/registry.ethos.adobe.com_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ spec:
- Running
- Upgrading
type: string
publicIPs:
description: PublicIPs cluster public IPs
items:
type: string
type: array
region:
description: Cluster internal region name
type: string
Expand Down
12 changes: 4 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/adobe/cluster-registry

go 1.23.0

toolchain go1.23.4
go 1.23.4

require (
dario.cat/mergo v1.0.1
Expand All @@ -12,6 +10,7 @@ require (
github.com/eko/gocache/lib/v4 v4.1.6
github.com/eko/gocache/store/redis/v4 v4.2.2
github.com/evanphx/json-patch/v5 v5.9.0
github.com/go-co-op/gocron/v2 v2.12.4
github.com/go-jose/go-jose/v3 v3.0.3
github.com/go-logr/logr v1.4.2
github.com/go-redis/redismock/v9 v9.2.0
Expand Down Expand Up @@ -85,16 +84,14 @@ require (
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
Expand All @@ -116,7 +113,6 @@ require (
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo/v2 v2.21.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -125,6 +121,7 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
Expand All @@ -151,7 +148,6 @@ require (
golang.org/x/time v0.8.0 // indirect
golang.org/x/tools v0.28.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.66.2 // indirect
google.golang.org/protobuf v1.35.1 // indirect
Expand Down
Loading

0 comments on commit daab7e7

Please sign in to comment.