Skip to content

Commit

Permalink
feat: refactor, and add possibility for multiple collectors on the sa…
Browse files Browse the repository at this point in the history
…me tenant

Signed-off-by: Kristof Gyuracz <kristof.gyuracz@axoflow.com>
  • Loading branch information
kristofgyuracz committed Mar 6, 2024
1 parent cda40ce commit bc8ea1a
Show file tree
Hide file tree
Showing 12 changed files with 660 additions and 518 deletions.
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
Loading

0 comments on commit bc8ea1a

Please sign in to comment.