Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
df3ef08
1st test push interface
Janooski Apr 2, 2026
29dbf1f
Merge branch 'dev/autodiscover' into feature/push-interface
Janooski Apr 2, 2026
fe8dc49
change to gin-gonic
Janooski Apr 2, 2026
5e9aedc
change to gin
Janooski Apr 7, 2026
b7e12d7
adding openapi.yaml and generated code, still has bugs
Janooski Apr 8, 2026
5e50aba
add healthz and readyz interfaces to avoid pod crashing
Janooski Apr 8, 2026
0f230c2
move healthz and readyz back to port 8081
Janooski Apr 8, 2026
4d3dc8d
url paths dynamic
Janooski Apr 8, 2026
34be165
improve logging for troubleshooting
Janooski Apr 9, 2026
7c0e2bb
move gin router creation to apiserver package
Janooski Apr 9, 2026
4dd7c8c
small refactor
Janooski Apr 9, 2026
e76c6f3
restructure discovery structs
denyost Apr 17, 2026
3c18fb5
offload sending logic from loader implementation
denyost Apr 17, 2026
86ab0f3
implement type assertion based on received message
denyost Apr 17, 2026
efbf727
add http_push skeleton
denyost Apr 17, 2026
60a5eb3
refactor targetsource_controller.go
denyost Apr 17, 2026
1bc5d2b
remove targetsource ressource to not impact main
denyost Apr 17, 2026
14e7765
add batching to DiscoveryEvent's
denyost Apr 17, 2026
b4337ea
refactored sender.go
denyost Apr 17, 2026
30f3ecb
load buffer and chunk size from env variable
denyost Apr 17, 2026
fa8540b
Merge branch 'feature/target-loading-architecture' into feature/push-…
Janooski Apr 20, 2026
dbbcb4f
can start push loader
Janooski Apr 20, 2026
201ccb3
Merge branch 'feature/targetsource-crd-fields' into feature/limit-tar…
mcdillson Apr 21, 2026
3aae153
pass discovery message to loader
Janooski Apr 22, 2026
c8dfdf1
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost Apr 22, 2026
6cc0eb1
Merge branch 'feature/target-loading-architecture' of https://github.…
denyost Apr 22, 2026
586001e
rename file to helpers
denyost Apr 22, 2026
7430815
rebuild and reformat
denyost Apr 22, 2026
255a1f3
consolidate pull and push to http
denyost Apr 23, 2026
9316ca3
create multiple core.DiscoveredTarget
Janooski Apr 23, 2026
ffc2054
Merge branch 'feature/limit-target-loading' into feature/push-interface
Janooski Apr 23, 2026
005f961
Merge branch 'feature/limit-target-loading' into feature/push-interface
Janooski Apr 23, 2026
bd2b45f
rename target manager to target applier
denyost Apr 23, 2026
5a561a7
implement a generic registry
denyost Apr 23, 2026
f5481b8
add a discoveryTegistry to share targetchannel between apiserver and …
denyost Apr 23, 2026
e73a253
pull interface only in apiserver
Janooski Apr 23, 2026
452a71a
Merge branch 'feature/limit-target-loading' into feature/push-interface
Janooski Apr 23, 2026
32cb077
add core.SendEvents, ShouldBindJSON doesn't work
Janooski Apr 23, 2026
8b4f5c9
tests with ShouldBindBodyJSON
Janooski Apr 23, 2026
22683f4
remove unused event action from DiscoverySnapshot
denyost Apr 23, 2026
922bbc6
rename target manager to target applier
denyost Apr 24, 2026
733927f
implement key for registry as a comparable
denyost Apr 24, 2026
9d30560
fix error message and add a word of caution for key comparables
denyost Apr 24, 2026
dafa82b
consistently use namespaced name as refference to the targetsource
denyost Apr 24, 2026
2973c03
improve context cancling and error handling
denyost Apr 24, 2026
c95bdaf
add supervised goroutines
denyost Apr 24, 2026
0aa883d
refactor target applier
denyost Apr 24, 2026
27b2b1f
add supervisor for the discovery pipelines
denyost Apr 24, 2026
22fe2d8
improve readability
denyost Apr 24, 2026
58538c7
remove side-effects from getter getTargetSource
denyost Apr 24, 2026
4f0457e
redesign supervisor
denyost Apr 24, 2026
60491be
add dependency handling of discovery pipeline components
denyost Apr 25, 2026
b8a6d27
refactor code
denyost Apr 25, 2026
eedfedf
improve context handling of and target applier semantics
denyost Apr 25, 2026
ff4f2bb
fix import
Janooski Apr 26, 2026
00e9818
Merge branch 'feature/limit-target-loading' into feature/push-interface
Janooski Apr 26, 2026
ffbfd47
update api contract
Janooski Apr 26, 2026
8d7ee19
CreateTargets works for complete POST request
Janooski Apr 26, 2026
a66accb
moved finalizer label into const file
mcdillson Apr 27, 2026
3b2d925
fixed typo
mcdillson Apr 27, 2026
3ba86cb
restructured loaders package
mcdillson Apr 27, 2026
d0ac86b
restructured target handler
mcdillson Apr 27, 2026
240a2bc
ran go mod tidy
mcdillson Apr 27, 2026
80d3211
manual implementation of required fields
Janooski Apr 27, 2026
b2d3c18
add URL templating
Janooski Apr 27, 2026
7ef1281
renamed target applier to message processor & created client.go for g…
mcdillson Apr 27, 2026
7bcbcc0
added const file for common labels
mcdillson Apr 24, 2026
4fa58b6
Merge branch 'feature/limit-target-loading' into feature/restructuring
mcdillson Apr 27, 2026
d10fc9a
removed all package
mcdillson Apr 27, 2026
108bd2d
changed error lookup to apierrors
mcdillson Apr 27, 2026
b7dd036
remove unused fiels
denyost Apr 29, 2026
d3a9b5c
rename files and restructure packages
denyost Apr 29, 2026
0c80394
rename target handler to target reconciler
denyost Apr 29, 2026
04208bf
rename handler to reconciler
denyost Apr 29, 2026
c3818ce
clarify interface files
denyost Apr 29, 2026
ab09c7c
small code refactor
Janooski Apr 29, 2026
e4df0d4
define EventAction to be go idomatic
denyost Apr 29, 2026
86c0af0
add webhook activation info to metadata of DiscoveryRegistry
denyost Apr 29, 2026
284b1f2
moved reconciler files to discovery
mcdillson Apr 29, 2026
b59897c
renamed messageProcessor to targetReconciler
mcdillson Apr 29, 2026
c268808
moved registry.go to discovery
mcdillson Apr 29, 2026
0295896
moved supervisor to discovery
mcdillson Apr 29, 2026
4d32c40
moved factory.go to discovery/loaders.go
mcdillson Apr 29, 2026
7671c1a
moved send.go to loaders package
mcdillson Apr 29, 2026
5f1e9cb
eliminated message.go
mcdillson Apr 29, 2026
6d67537
moved const.go to discovery.go
mcdillson Apr 29, 2026
3914630
renamed core package within targetsource controller
mcdillson Apr 29, 2026
46a201f
changed events to delete / apply
mcdillson Apr 29, 2026
7b17f7e
moved send.go into separate utils for loaders
mcdillson Apr 29, 2026
4540163
replaced legacy registry package
mcdillson Apr 29, 2026
2c3260e
Merge pull request #57 from gnmic/feature/restructuring
mcdillson Apr 29, 2026
f269a85
Merge branch 'main' of https://github.com/gnmic/operator into feature…
denyost Apr 30, 2026
c728fa2
add supervisor restart policy to targetsource spec configuration
denyost Apr 30, 2026
0ff9bdf
tags wrapped in labels
Janooski Apr 30, 2026
589bc9f
add targetsource example for lab
denyost Apr 30, 2026
a5dde06
remove targetsource example to not add unnecassary logging to main
denyost Apr 30, 2026
4be9c27
update gitignore to not push targetsources in order to prevent loggin…
denyost Apr 30, 2026
7962d77
refactor
Janooski Apr 30, 2026
7337541
add component info to logging
denyost Apr 30, 2026
3ec3203
if context is canceled return with ctx.Err() not a clean exit
denyost Apr 30, 2026
0eaffdc
applied kubebuilder best-practise logging
denyost Apr 30, 2026
fd4abe7
improved logging
denyost Apr 30, 2026
a6bc114
simplified pipeline context handling
denyost Apr 30, 2026
535ee49
rename target reconciler to message processor
denyost May 1, 2026
c09c68f
rename pipeline to runtime
denyost May 1, 2026
e4c01ba
removed supervisor
denyost May 1, 2026
77dbd7e
tidy loader configuration abstraction
denyost May 1, 2026
fe900e3
regenearte manifests without restartPolicy
denyost May 1, 2026
c1d7a91
tidy up comments
denyost May 1, 2026
e5b7532
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost May 1, 2026
5c37a2a
add dynamic endpoints
denyost May 1, 2026
05c7538
move webhook spec into provider and rename it to acceptPush
denyost May 1, 2026
061d4b8
regenerate manifests
denyost May 1, 2026
e250a8a
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost May 1, 2026
f8b92b2
verify acceptPush is enabled for webhook config
denyost May 1, 2026
41655a0
remove spec from laoder config
denyost May 1, 2026
4fda4f8
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost May 1, 2026
97849ae
update LoaderConfig in registry
denyost May 1, 2026
c76fd18
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost May 1, 2026
953aaa7
fix after merge
denyost May 1, 2026
f683a44
comments from weekly
Janooski May 4, 2026
fe31b0d
update manifests
Janooski May 4, 2026
2b4a0af
fix merge conflicts
Janooski May 4, 2026
2855ea3
Merge pull request #64 from gnmic/feature/push-new-architecture
Janooski May 4, 2026
08273d0
udpate contract
Janooski May 4, 2026
426e27a
fix: use defined variable
denyost May 4, 2026
e04c9c5
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost May 4, 2026
84012af
change logger
Janooski May 6, 2026
7fa3e5b
unit test for helpers
Janooski May 6, 2026
491e6a9
Merge branch 'feature/push-interface' of github.com:gnmic/operator in…
Janooski May 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ notes/
docs/public
docs/resources/_gen/
docs/.hugo_build.lock
test/integration/clab-*
test/integration/clab-*

# Only for development and testing purposes
# To be removed after development of targetsource
# ignored in order to not add unnecassary logging messages
lab/dev/resources/targetsources
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ delete-outputs-dev-lab: ## Delete the outputs for the development lab cluster
kubectl delete -f lab/dev/resources/outputs

.PHONY: apply-pipelines-dev-lab
apply-pipelines-dev-lab: ## Apply the pipelines for the development lab cluster
§apply-pipelines-dev-lab: ## Apply the pipelines for the development lab cluster
kubectl apply -f lab/dev/resources/pipelines

.PHONY: delete-pipelines-dev-lab
Expand Down
5 changes: 4 additions & 1 deletion api/v1alpha1/targetsource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (
// +kubebuilder:validation:Required
type TargetSourceSpec struct {
Provider *ProviderSpec `json:"provider"`
//

// +kubebuilder:validation:Optional
TargetLabels map[string]string `json:"targetLabels,omitempty"`

// +kubebuilder:validation:MinLength=1
Expand All @@ -40,6 +41,8 @@ type ProviderSpec struct {
type HTTPConfig struct {
// +kubebuilder:validation:MinLength=1
URL string `json:"url"`
// +kubebuilder:validation:Optional
AcceptPush bool `json:"acceptPush,omitempty"`
}

type ConsulConfig struct {
Expand Down
45 changes: 38 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package main

import (
"context"
"errors"
"flag"
"net/http"
"os"
"time"

Expand All @@ -28,6 +30,7 @@ import (

certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
Expand All @@ -40,6 +43,8 @@ import (
operatorv1alpha1 "github.com/gnmic/operator/api/v1alpha1"
"github.com/gnmic/operator/internal/apiserver"
"github.com/gnmic/operator/internal/controller"
"github.com/gnmic/operator/internal/controller/discovery"
"github.com/gnmic/operator/internal/controller/discovery/core"
webhookv1alpha1 "github.com/gnmic/operator/internal/webhook/v1alpha1"
//+kubebuilder:scaffold:imports
)
Expand All @@ -64,13 +69,17 @@ func main() {
var probeAddr string
var devMode bool
var apiAddr string
var discoveryChunkSize int
var discoveryBufferSize int
flag.StringVar(&apiAddr, "api-bind-address", "", "The address the operator API endpoint binds to. Disabled if empty.")
flag.BoolVar(&devMode, "dev-mode", false, "Enable development mode.")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.IntVar(&discoveryChunkSize, "discovery-chunk-size", 100, "Maximum number of targets/events sent in a single discovery message.")
flag.IntVar(&discoveryBufferSize, "discovery-buffer-size", 10, "Amount of discovery messages that can be queued in the channel buffer.")
opts := zap.Options{
Development: devMode,
}
Expand All @@ -79,6 +88,8 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

discoveryRegistry := discovery.NewRegistry[types.NamespacedName, core.DiscoveryRegistryValue]()

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Metrics: metricsserver.Options{BindAddress: metricsAddr},
Expand Down Expand Up @@ -116,9 +127,22 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Pipeline")
os.Exit(1)
}

var api *apiserver.APIServer
if apiAddr != "" {
api, err = apiserver.New(apiAddr, clusterReconciler, discoveryRegistry, discoveryChunkSize)
if err != nil {
setupLog.Error(err, "unable to initialize API server")
os.Exit(1)
}
}
if err := (&controller.TargetSourceReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
BufferSize: discoveryBufferSize,
ChunkSize: discoveryChunkSize,
DiscoveryRegistry: discoveryRegistry,
APIRouter: api.Router(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "TargetSource")
os.Exit(1)
Expand Down Expand Up @@ -218,20 +242,27 @@ func main() {
os.Exit(1)
}

if apiAddr != "" {
apiServer := apiserver.New(apiAddr, clusterReconciler)
if api != nil {
err = mgr.Add(manager.RunnableFunc(func(ctx context.Context) error {
errCh := make(chan error)
go func() {
errCh <- apiServer.Server.ListenAndServe()
err := api.Server.ListenAndServe()
if err != nil && !errors.Is(err, http.ErrServerClosed) {
errCh <- err
}
close(errCh)
}()

select {
case err := <-errCh:
case err, ok := <-errCh:
if !ok {
return nil
}
return err
case <-ctx.Done():
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
return apiServer.Server.Shutdown(ctx)
return api.Server.Shutdown(ctx)
}
}))
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/operator.gnmic.dev_targetsources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ spec:
type: object
http:
properties:
acceptPush:
type: boolean
url:
minLength: 1
type: string
Expand Down
9 changes: 9 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ spec:
- --leader-elect
image: controller:latest
name: manager
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CLUSTER_NAME
valueFrom:
fieldRef:
fieldPath: metadata.labels['app.kubernetes.io/name']
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down
65 changes: 54 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ module github.com/gnmic/operator
go 1.25.5

require (
github.com/bytedance/gopkg v0.1.3
github.com/cert-manager/cert-manager v1.19.3
github.com/getkin/kin-openapi v0.133.0
github.com/go-logr/logr v1.4.3
github.com/onsi/ginkgo/v2 v2.27.3
github.com/onsi/gomega v1.38.3
github.com/onsi/ginkgo/v2 v2.28.1
github.com/onsi/gomega v1.39.0
github.com/google/uuid v1.6.0
github.com/openconfig/gnmic/pkg/api v0.1.10
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.35.1
Expand All @@ -17,6 +20,43 @@ require (
sigs.k8s.io/controller-runtime v0.22.4
)

require (
github.com/bytedance/sonic v1.15.0 // indirect
github.com/bytedance/sonic/loader v0.5.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.30.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.19.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/oapi-codegen/oapi-codegen/v2 v2.6.0 // indirect
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.59.0 // indirect
github.com/speakeasy-api/jsonpath v0.6.0 // indirect
github.com/speakeasy-api/openapi-overlay v0.10.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.1 // indirect
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
github.com/woodsbury/decimal128 v1.3.0 // indirect
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
golang.org/x/arch v0.22.0 // indirect
golang.org/x/crypto v0.48.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
cloud.google.com/go/compute/metadata v0.9.0 // indirect
github.com/Masterminds/semver/v3 v3.4.0 // indirect
Expand All @@ -27,6 +67,7 @@ require (
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/gin-gonic/gin v1.12.0
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.22.4 // indirect
github.com/go-openapi/jsonreference v0.21.4 // indirect
Expand All @@ -46,8 +87,8 @@ require (
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.7.1 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/pprof v0.0.0-20251213031049-b05bdaca462f // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
github.com/google/uuid v1.6.0
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
Expand All @@ -63,15 +104,15 @@ require (
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/mod v0.31.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/mod v0.32.0 // indirect
golang.org/x/net v0.51.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/term v0.40.0 // indirect
golang.org/x/text v0.34.0 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.40.0 // indirect
golang.org/x/tools v0.41.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
google.golang.org/grpc v1.79.3 // indirect
Expand All @@ -83,6 +124,8 @@ require (
sigs.k8s.io/gateway-api v1.4.1 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)

tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
Loading
Loading