@@ -269,18 +269,25 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
269269 // Locate the KubeRay operator deployment:
270270 // - First try to get the ODH / RHOAI application namespace from the DSCInitialization
271271 // - Or fallback to the well-known defaults
272+ // add check if running on openshift or vanilla kubernetes
272273 var kubeRayNamespaces []string
273- dsci := & dsciv1.DSCInitialization {}
274- err := r .Client .Get (ctx , client.ObjectKey {Name : "default-dsci" }, dsci )
275- if errors .IsNotFound (err ) {
276- kubeRayNamespaces = []string {"opendatahub" , "redhat-ods-applications" }
277- } else if err != nil {
278- return ctrl.Result {}, err
279- } else {
280- kubeRayNamespaces = []string {dsci .Spec .ApplicationsNamespace }
274+ kubeRayNamespaces = []string {kubeRayDefaultNamespace }
275+
276+ if r .IsOpenShift {
277+ dsci := & dsciv1.DSCInitialization {}
278+
279+ err := r .Client .Get (ctx , client.ObjectKey {Name : defaultDSCINamespace }, dsci )
280+ if errors .IsNotFound (err ) {
281+ kubeRayNamespaces = []string {odhNamespace , rhdsAppsNamespace }
282+ } else if err != nil {
283+ return ctrl.Result {}, err
284+ } else {
285+ kubeRayNamespaces = []string {dsci .Spec .ApplicationsNamespace }
286+ }
287+
281288 }
282289
283- _ , err = r .kubeClient .NetworkingV1 ().NetworkPolicies (cluster .Namespace ).Apply (ctx , desiredHeadNetworkPolicy (cluster , r .Config , kubeRayNamespaces ), metav1.ApplyOptions {FieldManager : controllerName , Force : true })
290+ _ , err : = r .kubeClient .NetworkingV1 ().NetworkPolicies (cluster .Namespace ).Apply (ctx , desiredHeadNetworkPolicy (cluster , r .Config , kubeRayNamespaces ), metav1.ApplyOptions {FieldManager : controllerName , Force : true })
284291 if err != nil {
285292 logger .Error (err , "Failed to update NetworkPolicy" )
286293 }
@@ -550,7 +557,7 @@ func desiredHeadNetworkPolicy(cluster *rayv1.RayCluster, cfg *config.KubeRayConf
550557 networkingv1ac .NetworkPolicyIngressRule ().
551558 WithFrom (
552559 networkingv1ac .NetworkPolicyPeer ().WithPodSelector (metav1ac .LabelSelector ().
553- WithMatchLabels (map [string ]string {"app.kubernetes.io/component" : "kuberay-operator" })).
560+ WithMatchLabels (map [string ]string {"app.kubernetes.io/component" : kubeRayOperatorNamespace })).
554561 WithNamespaceSelector (metav1ac .LabelSelector ().
555562 WithMatchExpressions (metav1ac .LabelSelectorRequirement ().
556563 WithKey (corev1 .LabelMetadataName ).
0 commit comments