Skip to content

only use the default-dsci applicationsNamespace in openshift #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 1, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions pkg/controllers/raycluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,21 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
// Locate the KubeRay operator deployment:
// - First try to get the ODH / RHOAI application namespace from the DSCInitialization
// - Or fallback to the well-known defaults
// add check if running on openshift or vanilla kubernetes
var kubeRayNamespaces []string
dsci := &dsciv1.DSCInitialization{}
err := r.Client.Get(ctx, client.ObjectKey{Name: "default-dsci"}, dsci)
if errors.IsNotFound(err) {
kubeRayNamespaces = []string{"opendatahub", "redhat-ods-applications"}
} else if err != nil {
return ctrl.Result{}, err
} else {
kubeRayNamespaces = []string{dsci.Spec.ApplicationsNamespace}
kubeRayNamespaces = []string{"opendatahub", "redhat-ods-applications"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szaher We're still passing these namespaces (which I assume are openshift specific) to the network policy creation below. I may be wrong but on a native k8s installation, kuberay won't be installed in either of those namespaces. The OpenShift specific kustomization.yaml points to opendatahub by default but the deployments namespace by default I think is just ray-system. So wouldn't this still set up those network policies to point to ODH/RHOAI namespaces?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if r.IsOpenShift {
dsci := &dsciv1.DSCInitialization{}
err := r.Client.Get(ctx, client.ObjectKey{Name: "default-dsci"}, dsci)
if err != nil {
return ctrl.Result{}, err
} else {
kubeRayNamespaces = []string{dsci.Spec.ApplicationsNamespace}
}
Copy link

@eoinfennessy eoinfennessy Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kubeRayNamespaces = []string{"opendatahub", "redhat-ods-applications"}
if r.IsOpenShift {
dsci := &dsciv1.DSCInitialization{}
err := r.Client.Get(ctx, client.ObjectKey{Name: "default-dsci"}, dsci)
if err != nil {
return ctrl.Result{}, err
} else {
kubeRayNamespaces = []string{dsci.Spec.ApplicationsNamespace}
}
var kubeRayNamespaces []string
if r.IsOpenShift {
dsci := &dsciv1.DSCInitialization{}
if err := r.Client.Get(ctx, client.ObjectKey{Name: "default-dsci"}, dsci); err != nil {
return ctrl.Result{}, err
}
kubeRayNamespaces = []string{dsci.Spec.ApplicationsNamespace}
} else {
kubeRayNamespaces = []string{"opendatahub", "redhat-ods-applications"}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eoinfennessy actually there is a missing condition that needs to be handled. if the dsci is not found error we use the fall back namespaces if it's available we use it.
otherwise if it's not openshift, I will use the cluster namespace

}

_, err = r.kubeClient.NetworkingV1().NetworkPolicies(cluster.Namespace).Apply(ctx, desiredHeadNetworkPolicy(cluster, r.Config, kubeRayNamespaces), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
_, err := r.kubeClient.NetworkingV1().NetworkPolicies(cluster.Namespace).Apply(ctx, desiredHeadNetworkPolicy(cluster, r.Config, kubeRayNamespaces), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
if err != nil {
logger.Error(err, "Failed to update NetworkPolicy")
}
Expand Down
Loading