Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
181ea95
extend TargetSource CRD by http token
denyost Apr 16, 2026
2fddddf
add pull logic as poc
denyost Apr 16, 2026
64a83cd
fix request header typo
denyost Apr 16, 2026
98823e8
refactor pull implementation
denyost Apr 16, 2026
cfe0273
Merge branch 'feature/target-loading-architecture' of https://github.…
denyost Apr 16, 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
10a9978
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost Apr 17, 2026
8b36d7d
add http_push skeleton
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
201ccb3
Merge branch 'feature/targetsource-crd-fields' into feature/limit-tar…
mcdillson Apr 21, 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
e7ff5f8
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost Apr 22, 2026
3cb9160
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
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
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
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
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
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
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
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
65eb7f6
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost Apr 30, 2026
7337541
add component info to logging
denyost Apr 30, 2026
4ec0bb6
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost Apr 30, 2026
41d5498
make snapshot id a bit smaller
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
5140605
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost Apr 30, 2026
e447b3b
improved logging
denyost Apr 30, 2026
fca37e0
improved logging
denyost Apr 30, 2026
fd4abe7
improved logging
denyost Apr 30, 2026
a6bc114
simplified pipeline context handling
denyost Apr 30, 2026
34cd51e
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost Apr 30, 2026
54c41fd
add timeout as a const
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
05c7538
move webhook spec into provider and rename it to acceptPush
denyost May 1, 2026
061d4b8
regenerate manifests
denyost May 1, 2026
41655a0
remove spec from laoder config
denyost May 1, 2026
97849ae
update LoaderConfig in registry
denyost May 1, 2026
426e27a
fix: use defined variable
denyost May 4, 2026
c472f48
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost May 6, 2026
a6e449d
load spec into loader
denyost May 6, 2026
e908953
update httpconfig
denyost May 6, 2026
85278df
use httpconfig within loader
denyost May 6, 2026
6c82320
refactor
denyost May 6, 2026
deb9e90
git ignore sonar scanner
denyost May 8, 2026
b088db2
add defaulting for targetsource crd
denyost May 8, 2026
9208766
remove closeChannel and fix cleanup logic
denyost May 13, 2026
209948e
fix: resolved pointer and returns smells
denyost May 13, 2026
1a0f447
improved logging message
denyost May 13, 2026
d94c23f
improved error handling
denyost May 13, 2026
e3f18d8
refactor: ctx should flow not be stored
denyost May 13, 2026
bc1b350
refactor: resetSnapshot
denyost May 13, 2026
020be5a
refactor: context cancellation
denyost May 13, 2026
3280229
refactor: default error handling now logs errors instead of terminati…
denyost May 13, 2026
cf49f83
Merge branch 'feature/limit-target-loading' of https://github.com/gnm…
denyost May 13, 2026
39f1650
refactor: pointer missuse
denyost May 13, 2026
f1d8c31
move defaulting logic to kubebuilder:default
denyost May 13, 2026
b0c63ff
remove pointer from bool
denyost May 13, 2026
c422dff
update deepcopy
denyost May 13, 2026
abb7180
fix: pointer issue
denyost May 13, 2026
36cf9fd
add helper to read secrets
denyost May 14, 2026
4f70c43
implement basic and token authentication
denyost May 14, 2026
966cd59
support .Key for TokenSecretRef
denyost May 14, 2026
862e28d
update targetsource
denyost May 14, 2026
e6e9439
support TLS verification
denyost May 14, 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
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ 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
.scannerwork/
173 changes: 165 additions & 8 deletions api/v1alpha1/targetsource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,191 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// TargetSourceSpec defines the desired state of TargetSource
// +kubebuilder:validation:Required
type TargetSourceSpec struct {
// Provider defines the source of targets for this TargetSource
// Only one provider can be specified per TargetSource
// +kubebuilder:validation:Required
Provider *ProviderSpec `json:"provider"`
//

// TODO: implement in message processor
// Optional port to use for discovered targets if not specified by the provider
// +kubebuilder:validation:Optional
TargetPort int32 `json:"targetPort,omitempty"`

// Optional labels to apply to all targets discovered by this TargetSource
// +kubebuilder:validation:Optional
TargetLabels map[string]string `json:"targetLabels,omitempty"`

// The TargetProfile to use for targets discovered by this TargetSource
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
TargetProfile string `json:"targetProfile"`
}

// +kubebuilder:validation:ExactlyOneOf=http;consul
// ProviderSpec defines the source of targets for a TargetSource
// Only one provider can be specified per TargetSource
// +kubebuilder:validation:ExactlyOneOf=http
type ProviderSpec struct {
HTTP *HTTPConfig `json:"http,omitempty"`
Consul *ConsulConfig `json:"consul,omitempty"`
// HTTP defines the configuration for a HTTP provider
HTTP *HTTPConfig `json:"http,omitempty"`
}

// HTTPConfig defines the configuration for the HTTP provider
// +kubebuilder:validation:AtLeastOneOf=url;acceptPush
type HTTPConfig struct {
// +kubebuilder:validation:MinLength=1
URL string `json:"url"`
// URL of the HTTP endpoint to pull targets from
// If defined, the loader will periodically poll this endpoint for targets
// +kubebuilder:validation:Optional
URL string `json:"url,omitempty"`

// If true, the loader will accept pushed target updates to the controller endpoint
// The endpoint will be /{namespace}/{targetsource}/<todo>
// +kubebuilder:default=false
// +kubebuilder:validation:Optional
AcceptPush bool `json:"acceptPush,omitempty"`

// Optional authorization configuration for accessing the HTTP endpoint
// +kubebuilder:validation:Optional
Authorization *AuthorizationSpec `json:"authorization,omitempty"`

// Optional interval for polling the HTTP endpoint for targets
// TODO: increase default value
// +kubebuilder:default="30s"
// +kubebuilder:validation:Optional
PollInterval *metav1.Duration `json:"interval,omitempty"`

// Optional timeout for HTTP requests to the endpoint
// +kubebuilder:default="10s"
// +kubebuilder:validation:Optional
Timeout *metav1.Duration `json:"timeout,omitempty"`

// Optional TLS configuration for connecting to the HTTP endpoint
// +kubebuilder:validation:Optional
TLS *ClientTLSConfig `json:"tls,omitempty"`

// Optional pagination configuration for parsing responses from the HTTP endpoint
// +kubebuilder:validation:Optional
Pagination *PaginationSpec `json:"pagination,omitempty"`

// Optional mapping configuration for parsing responses from the HTTP endpoint
// +kubebuilder:validation:Optional
ResponseMapping *ResponseMappingSpec `json:"mapping,omitempty"`
}

// +kubebuilder:validation:XValidation:rule="!(has(self.caBundle) && has(self.caBundleSecretRef))",message="caBundle and caBundleSecretRef are mutually exclusive"
type ClientTLSConfig struct {
// Skip TLS verification of the Provider's certificate.
// +kubebuilder:default:=false
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`

// Base64-encoded bundle of PEM CAs which will be used to validate the certificate
// chain presented by the Provider. Only used if using HTTPS to connect to Provider and
// ignored for HTTP connections.
// Mutually exclusive with CABundleSecretRef.
// +optional
CABundle []byte `json:"caBundle,omitempty"`

// Reference to a Secret containing a bundle of PEM-encoded CAs to use when
// verifying the certificate chain presented by the Provider when using HTTPS.
// Mutually exclusive with CABundle.
CABundleSecretRef *corev1.SecretKeySelector `json:"caBundleSecretRef,omitempty"`
}

// AuthorizationSpec defines the configuration for authentication
// +kubebuilder:validation:ExactlyOneOf=basic;token
type AuthorizationSpec struct {
// Basic authentication configuration
Basic *BasicAuthSpec `json:"basic,omitempty"`
// Token-based authentication configuration
Token *TokenAuthSpec `json:"token,omitempty"`
// JWT *JWTAuthSpec `json:"jwt,omitempty"`
// MTLS
}

// BasicAuthSpec defines the configuration for basic authentication
// Enforce EITHER inline creds OR secret ref
// +kubebuilder:validation:XValidation:rule="(has(self.credentialsSecretRef) && !has(self.username) && !has(self.password)) || (!has(self.credentialsSecretRef) && has(self.username) && has(self.password))",message="either credentialsSecretRef OR both username and password must be set, but not a mix"
type BasicAuthSpec struct {
// Username for basic auth
// Mutually exclusive with CredentialsSecretRef.
Username string `json:"username,omitempty"`
// Password for basic auth
// Mutually exclusive with CredentialsSecretRef.
Password string `json:"password,omitempty"`

// Reference to a Secret containing "username" and "password" keys to use for
// basic authentication when connecting to the Provider.
// Mutually exclusive with Username and Password.
CredentialsSecretRef *corev1.SecretKeySelector `json:"credentialsSecretRef,omitempty"`
}

type ConsulConfig struct {
// TokenAuthSpec defines the configuration for token-based authentication
// +kubebuilder:validation:XValidation:rule="has(self.token) != has(self.tokenSecretRef)",message="either token or tokenSecretRef must be set, but not both"
type TokenAuthSpec struct {
// Scheme for the token, e.g. "Bearer"
// +kubebuilder:validation:MinLength=1
URL string `json:"url,omitempty"`
Scheme string `json:"scheme"`
// Token value for authentication
// Mutually exclusive with TokenSecretRef.
Token string `json:"token,omitempty"`
// Reference to a Secret containing a key with the token value to use for
// authentication when connecting to the Provider.
// Mutually exclusive with Token.
TokenSecretRef *corev1.SecretKeySelector `json:"tokenSecretRef,omitempty"`
}

// +kubebuilder:validation:XValidation:rule="!((has(self.token) || has(self.tokenSecretRef)) && ((has(self.key) || has(self.signingKeySecretRef) || has(self.claims)))",message="static JWT token and generated JWT configuration cannot be combined"
// +kubebuilder:validation:XValidation:rule="!has(self.signingKeySecretRef) || self.algorithm != \"\"",message="algorithm must be specified when generating a JWT"
// type JWTAuthSpec struct {
// // Static pre-generated JWT
// Token string `json:"token,omitempty"`
// TokenSecretRef *corev1.SecretKeySelector `json:"tokenSecretRef,omitempty"`
// // Optional: generate JWT dynamically
// Claims map[string]string `json:"claims,omitempty"`
// Key string `json:"key,omitempty"`
// SigningKeySecretRef *corev1.SecretKeySelector `json:"signingKeySecretRef,omitempty"`
// // HS256, RS256, ES256, etc.
// Algorithm string `json:"algorithm,omitempty"`
// TTL *metav1.Duration `json:"ttl,omitempty"`
// }

// PaginationSpec defines the configuration for paginating through responses from providers
type PaginationSpec struct {
// JSONPath-style expression to extract the list of targets from the response
// Example: "results"
ItemsField string `json:"itemsField,omitempty"`

// JSONPath-style expression to extract the next page token or URL from the response for pagination
// Example: "next"
NextField string `json:"nextField,omitempty"`
}

// JSONPath-style expressions to extract target fields from the response
// and map them to the corresponding Target fields.
type ResponseMappingSpec struct {
// JSONPath expression to extract the target name from the response
// +kubebuilder:validation:Required
Name string `json:"name"`

// JSONPath expression to extract the target address from the response
// +kubebuilder:validation:Required
Address string `json:"address"`

// JSONPath expression to extract the target port from the response
// +kubebuilder:validation:Optional
Port string `json:"port,omitempty"`

// JSONPath expression to extract the target labels from the response
// The extracted labels will be merged with the static TargetLabels defined in the TargetSourceSpec,
// with values from the response taking precedence in case of conflicts.
// +kubebuilder:validation:Optional
Labels map[string]string `json:"labels,omitempty"`
}

// TargetSourceStatus defines the observed state of TargetSource
Expand Down
Loading
Loading