diff --git a/controllers/service_controller.go b/controllers/service_controller.go index 54e7be562..95e0bdb08 100644 --- a/controllers/service_controller.go +++ b/controllers/service_controller.go @@ -247,16 +247,23 @@ func (r *ServiceReconciler) reconcileService(ctx context.Context, mms *mmesh.MMS // - when the namespace does not have the annotation modelmesh-enabled // - when the namespace is under a Terminating state. n := &corev1.Namespace{} - if err := r.Client.Get(ctx, types.NamespacedName{Name: namespace}, n); err != nil { - return nil, err, false + if r.ClusterScope { + if err := r.Client.Get(ctx, types.NamespacedName{Name: namespace}, n); err != nil { + return nil, err, false + } + } else { + n = &corev1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + Name: namespace, + }, + } } - if !modelMeshEnabled(n, r.ControllerDeployment.Namespace) { r.ModelEventStream.RemoveWatchedService(serviceName, namespace) r.Log.Info("Deleted Watched Service", "name", serviceName, "namespace", namespace) return nil, nil, false } - + var s *corev1.Service for i := range sl.Items { ss := &sl.Items[i]