Skip to content

Commit

Permalink
remove servicemonitor and adjust podmonitor label selector
Browse files Browse the repository at this point in the history
Signed-off-by: Spolti <[email protected]>
  • Loading branch information
spolti committed May 9, 2024
1 parent b19dc35 commit 7231fda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewKServeIstioPeerAuthenticationReconciler(client client.Client) *KserveIst

// TODO remove this reconcile loop in future versions
func (r *KserveIstioPeerAuthenticationReconciler) Reconcile(ctx context.Context, log logr.Logger, isvc *kservev1beta1.InferenceService) error {
log.V(1).Info("Reconciling PeerAuthentication for target namespace, checking if there are resource for deletion")
log.V(1).Info("Reconciling PeerAuthentication for target namespace, checking if there are resources for deletion")
// Create Desired resource
desiredResource, err := r.createDesiredResource(isvc)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions controllers/reconcilers/kserve_istio_podmonitor_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ func (r *KserveIstioPodMonitorReconciler) createDesiredResource(ctx context.Cont
Selector: metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{
{
Key: "istio-prometheus-ignore",
Operator: metav1.LabelSelectorOpDoesNotExist,
Key: "component",
Operator: metav1.LabelSelectorOpIn,
Values: []string{"predictor", "explainer", "transformer"},
},
},
},
Expand Down
39 changes: 4 additions & 35 deletions controllers/reconcilers/kserve_istio_servicemonitor_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ package reconcilers

import (
"context"
"fmt"
"github.com/go-logr/logr"
kservev1beta1 "github.com/kserve/kserve/pkg/apis/serving/v1beta1"
"github.com/opendatahub-io/odh-model-controller/controllers/comparators"
"github.com/opendatahub-io/odh-model-controller/controllers/processors"
"github.com/opendatahub-io/odh-model-controller/controllers/resources"
"github.com/opendatahub-io/odh-model-controller/controllers/utils"
v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -55,7 +52,7 @@ func (r *KserveIstioServiceMonitorReconciler) Reconcile(ctx context.Context, log
log.V(1).Info("Creating Istio ServiceMonitor for target namespace")

// Create Desired resource
desiredResource, err := r.createDesiredResource(ctx, isvc)
desiredResource, err := r.createDesiredResource(isvc)
if err != nil {
return err
}
Expand All @@ -78,37 +75,9 @@ func (r *KserveIstioServiceMonitorReconciler) Cleanup(ctx context.Context, log l
return r.serviceMonitorHandler.DeleteServiceMonitor(ctx, types.NamespacedName{Name: istioServiceMonitorName, Namespace: isvcNs})
}

func (r *KserveIstioServiceMonitorReconciler) createDesiredResource(ctx context.Context, isvc *kservev1beta1.InferenceService) (*v1.ServiceMonitor, error) {
istioControlPlaneName, meshNamespace := utils.GetIstioControlPlaneName(ctx, r.client)

desiredServiceMonitor := &v1.ServiceMonitor{
ObjectMeta: metav1.ObjectMeta{
Name: istioServiceMonitorName,
Namespace: isvc.Namespace,
},
Spec: v1.ServiceMonitorSpec{
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"istio": "pilot",
},
},
TargetLabels: []string{"app"},
Endpoints: []v1.Endpoint{
{
Port: "http-monitoring",
Interval: "30s",
RelabelConfigs: []*v1.RelabelConfig{
{
TargetLabel: "mesh_id",
Replacement: fmt.Sprintf("%s-%s", istioControlPlaneName, meshNamespace),
Action: "replace",
},
},
},
},
},
}
return desiredServiceMonitor, nil
// TODO remove this reconcile loop in future versions
func (r *KserveIstioServiceMonitorReconciler) createDesiredResource(isvc *kservev1beta1.InferenceService) (*v1.ServiceMonitor, error) {
return nil, nil
}

func (r *KserveIstioServiceMonitorReconciler) getExistingResource(ctx context.Context, log logr.Logger, isvc *kservev1beta1.InferenceService) (*v1.ServiceMonitor, error) {
Expand Down

0 comments on commit 7231fda

Please sign in to comment.