Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor, and add possibility for multiple collectors on the same tenant #40

Merged
merged 5 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
4 changes: 3 additions & 1 deletion api/telemetry/v1alpha1/subscription_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ type SubscriptionSpec struct {

// SubscriptionStatus defines the observed state of Subscription
type SubscriptionStatus struct {
Tenant string `json:"tenant,omitempty"`
Tenant string `json:"tenant,omitempty"`
Outputs []NamespacedName `json:"outputs,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Tenant",type=string,JSONPath=`.status.tenant`
//+kubebuilder:printcolumn:name="Outputs",type=string,JSONPath=`.status.outputs`
//+kubebuilder:resource:categories=telemetry-all

// Subscription is the Schema for the subscriptions API
Expand Down
17 changes: 9 additions & 8 deletions api/telemetry/v1alpha1/tenant_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@ type TenantSpec struct {
LogSourceNamespaceSelectors []metav1.LabelSelector `json:"logSourceNamespaceSelectors,omitempty"`
}

const (
StateReady = "ready"
StateFailed = "failed"
)

// TenantStatus defines the observed state of Tenant
type TenantStatus struct {
Subscriptions []string `json:"subscriptions,omitempty"`
LogSourceNamespaces []string `json:"logSourceNamespaces,omitempty"`
Collector string `json:"collector"`
Subscriptions []NamespacedName `json:"subscriptions,omitempty"`
LogSourceNamespaces []string `json:"logSourceNamespaces,omitempty"`
State string `json:"state,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:resource:scope=Cluster,categories=telemetry-all
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Subscriptions",type=string,JSONPath=`.status.subscriptions`
//+kubebuilder:printcolumn:name="Logsource namespaces",type=string,JSONPath=`.status.logSourceNamespaces`
//+kubebuilder:printcolumn:name="Collector",type=string,JSONPath=`.status.collector`
//+kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`

// Tenant is the Schema for the tenants API
type Tenant struct {
Expand All @@ -59,7 +64,3 @@ type TenantList struct {
func init() {
SchemeBuilder.Register(&Tenant{}, &TenantList{})
}

func (t *Tenant) NamespacedName() NamespacedName {
return NamespacedName{Namespace: t.Namespace, Name: t.Name}
}
9 changes: 7 additions & 2 deletions api/telemetry/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ func main() {
os.Exit(1)
}

if err = (&controller.RouteReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Route")
os.Exit(1)
}
if err = (&controller.CollectorReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/telemetry.kube-logging.dev_subscriptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ spec:
- jsonPath: .status.tenant
name: Tenant
type: string
- jsonPath: .status.outputs
name: Outputs
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -63,6 +66,18 @@ spec:
status:
description: SubscriptionStatus defines the observed state of Subscription
properties:
outputs:
items:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: array
tenant:
type: string
type: object
Expand Down
20 changes: 13 additions & 7 deletions config/crd/bases/telemetry.kube-logging.dev_tenants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ spec:
- jsonPath: .status.logSourceNamespaces
name: Logsource namespaces
type: string
- jsonPath: .status.collector
name: Collector
- jsonPath: .status.state
name: State
type: string
name: v1alpha1
schema:
Expand Down Expand Up @@ -153,18 +153,24 @@ spec:
status:
description: TenantStatus defines the observed state of Tenant
properties:
collector:
type: string
logSourceNamespaces:
items:
type: string
type: array
state:
type: string
subscriptions:
items:
type: string
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: array
required:
- collector
type: object
type: object
served: true
Expand Down
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/wayneashleyberry/terminal-dimensions v1.1.0 // indirect
go.opentelemetry.io/collector/featuregate v0.77.0 // indirect
logur.dev/logur v0.17.0 // indirect
)

require (
Expand Down Expand Up @@ -72,7 +71,7 @@ require (
go.opentelemetry.io/collector/config/configcompression v0.91.0
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sys v0.15.0 // indirect
Expand All @@ -84,16 +83,15 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.28.4
k8s.io/apiextensions-apiserver v0.28.4 // indirect
k8s.io/component-base v0.28.4 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20231127182322-b307cd553661 // indirect
logur.dev/integration/logr v0.5.0
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
sigs.k8s.io/yaml v1.4.0
)
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7z
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
Expand Down Expand Up @@ -273,10 +272,6 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI=
k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
logur.dev/integration/logr v0.5.0 h1:Xy4/PIBbGKKsKGt+86sBJhMa8MSX5+XsyOaoBBU+tnw=
logur.dev/integration/logr v0.5.0/go.mod h1:Kp0WOJ6LRV7ewobPZddHHoLmLOpDmi+phZFhpUWD1Qg=
logur.dev/logur v0.17.0 h1:lwFZk349ZBY7KhonJFLshP/VhfFa6BxOjHxNnPHnEyc=
logur.dev/logur v0.17.0/go.mod h1:DyA5B+b6WjjCcnpE1+HGtTLh2lXooxRq+JmAwXMRK08=
sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4=
sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
Expand Down
Loading
Loading