Skip to content

Commit

Permalink
Add observability feature flag to Kuadrant CRD
Browse files Browse the repository at this point in the history
Signed-off-by: David Martin <[email protected]>
  • Loading branch information
david-martin committed Feb 10, 2025
1 parent 10f482b commit a3556a8
Show file tree
Hide file tree
Showing 17 changed files with 1,046 additions and 10 deletions.
5 changes: 5 additions & 0 deletions api/v1beta1/kuadrant_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func (p *Kuadrant) GetLocator() string {

// KuadrantSpec defines the desired state of Kuadrant
type KuadrantSpec struct {
Observability Observability `json:"observability,omitempty"`
}

type Observability struct {
Enable bool `json:"enable,omitempty"`
}

// KuadrantStatus defines the observed state of Kuadrant
Expand Down
31 changes: 31 additions & 0 deletions api/v1beta1/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"
"github.com/kuadrant/policy-machinery/controller"
"github.com/kuadrant/policy-machinery/machinery"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/samber/lo"
"k8s.io/apimachinery/pkg/runtime/schema"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand Down Expand Up @@ -61,3 +62,33 @@ func LinkKuadrantToAuthorino(objs controller.Store) machinery.LinkFunc {
},
}
}

func LinkKuadrantToServiceMonitor(objs controller.Store) machinery.LinkFunc {
kuadrants := lo.Map(objs.FilterByGroupKind(KuadrantGroupKind), controller.ObjectAs[machinery.Object])

return machinery.LinkFunc{
From: KuadrantGroupKind,
To: schema.GroupKind{Group: monitoringv1.SchemeGroupVersion.Group, Kind: monitoringv1.ServiceMonitorsKind},
Func: func(child machinery.Object) []machinery.Object {
return lo.Filter(kuadrants, func(kuadrant machinery.Object, _ int) bool {
// ServiceMonitors outside the Kuadrant namespace will be outside the topology tree
return kuadrant.GetNamespace() == child.GetNamespace()
})

Check warning on line 76 in api/v1beta1/topology.go

View check run for this annotation

Codecov / codecov/patch

api/v1beta1/topology.go#L66-L76

Added lines #L66 - L76 were not covered by tests
},
}
}

func LinkKuadrantToPodMonitor(objs controller.Store) machinery.LinkFunc {
kuadrants := lo.Map(objs.FilterByGroupKind(KuadrantGroupKind), controller.ObjectAs[machinery.Object])

return machinery.LinkFunc{
From: KuadrantGroupKind,
To: schema.GroupKind{Group: monitoringv1.SchemeGroupVersion.Group, Kind: monitoringv1.PodMonitorsKind},
Func: func(child machinery.Object) []machinery.Object {
return lo.Filter(kuadrants, func(kuadrant machinery.Object, _ int) bool {
// PodMonitors outside the Kuadrant namespace will be outside the topology tree
return kuadrant.GetNamespace() == child.GetNamespace()
})

Check warning on line 91 in api/v1beta1/topology.go

View check run for this annotation

Codecov / codecov/patch

api/v1beta1/topology.go#L81-L91

Added lines #L81 - L91 were not covered by tests
},
}
}
16 changes: 16 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/kuadrant/kuadrant-operator:latest
createdAt: "2024-12-09T09:56:27Z"
createdAt: "2025-02-10T11:02:45Z"
description: A Kubernetes Operator to manage the lifecycle of the Kuadrant system
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down
6 changes: 6 additions & 0 deletions bundle/manifests/kuadrant.io_kuadrants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ spec:
type: object
spec:
description: KuadrantSpec defines the desired state of Kuadrant
properties:
observability:
properties:
enable:
type: boolean
type: object
type: object
status:
description: KuadrantStatus defines the observed state of Kuadrant
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/kuadrant.io_kuadrants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ spec:
type: object
spec:
description: KuadrantSpec defines the desired state of Kuadrant
properties:
observability:
properties:
enable:
type: boolean
type: object
type: object
status:
description: KuadrantStatus defines the observed state of Kuadrant
Expand Down
Loading

0 comments on commit a3556a8

Please sign in to comment.