88 rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
99
1010 networkingv1 "k8s.io/api/networking/v1"
11- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1211 "k8s.io/apimachinery/pkg/types"
1312 "k8s.io/apimachinery/pkg/util/intstr"
1413 v1 "k8s.io/client-go/applyconfigurations/meta/v1"
@@ -39,7 +38,7 @@ func desiredRayClientRoute(cluster *rayv1.RayCluster) *routeapply.RouteApplyConf
3938}
4039
4140// Create an Ingress object for the RayCluster
42- func desiredRayClientIngress (cluster * rayv1.RayCluster , ingressDomain string ) * networkingv1ac.IngressApplyConfiguration {
41+ func desiredRayClientIngress (cluster * rayv1.RayCluster , ingressHost string ) * networkingv1ac.IngressApplyConfiguration {
4342 return networkingv1ac .Ingress (rayClientNameFromCluster (cluster ), cluster .Namespace ).
4443 WithLabels (map [string ]string {"ray.io/cluster-name" : cluster .Name }).
4544 WithAnnotations (map [string ]string {
@@ -55,7 +54,7 @@ func desiredRayClientIngress(cluster *rayv1.RayCluster, ingressDomain string) *n
5554 WithSpec (networkingv1ac .IngressSpec ().
5655 WithIngressClassName ("nginx" ).
5756 WithRules (networkingv1ac .IngressRule ().
58- WithHost (rayClientNameFromCluster ( cluster ) + "-" + cluster . Namespace + "." + ingressDomain ).
57+ WithHost (ingressHost ).
5958 WithHTTP (networkingv1ac .HTTPIngressRuleValue ().
6059 WithPaths (networkingv1ac .HTTPIngressPath ().
6160 WithPath ("/" ).
@@ -85,7 +84,7 @@ func desiredClusterIngress(cluster *rayv1.RayCluster, ingressHost string) *netwo
8584 WithUID (types .UID (cluster .UID ))).
8685 WithSpec (networkingv1ac .IngressSpec ().
8786 WithRules (networkingv1ac .IngressRule ().
88- WithHost (ingressHost ). // KinD hostname or ingressDomain
87+ WithHost (ingressHost ). // Full Hostname
8988 WithHTTP (networkingv1ac .HTTPIngressRuleValue ().
9089 WithPaths (networkingv1ac .HTTPIngressPath ().
9190 WithPath ("/" ).
@@ -104,19 +103,6 @@ func desiredClusterIngress(cluster *rayv1.RayCluster, ingressHost string) *netwo
104103 )
105104}
106105
107- // isOnKindCluster checks if the current cluster is a KinD cluster.
108- // It searches for a node with a label commonly used by KinD clusters.
109- func isOnKindCluster (clientset * kubernetes.Clientset ) (bool , error ) {
110- nodes , err := clientset .CoreV1 ().Nodes ().List (context .TODO (), metav1.ListOptions {
111- LabelSelector : "kubernetes.io/hostname=kind-control-plane" ,
112- })
113- if err != nil {
114- return false , err
115- }
116- // If we find one or more nodes with the label, assume it's a KinD cluster.
117- return len (nodes .Items ) > 0 , nil
118- }
119-
120106// getDiscoveryClient returns a discovery client for the current reconciler
121107func getDiscoveryClient (config * rest.Config ) (* discovery.DiscoveryClient , error ) {
122108 return discovery .NewDiscoveryClientForConfig (config )
@@ -153,15 +139,15 @@ func isOpenShift(ctx context.Context, clientset *kubernetes.Clientset, cluster *
153139}
154140
155141// getIngressHost generates the cluster URL string based on the cluster type, RayCluster, and ingress domain.
156- func getIngressHost (ctx context.Context , clientset * kubernetes.Clientset , cluster * rayv1.RayCluster , ingressDomain string ) string {
157- logger := ctrl .LoggerFrom (ctx )
158- onKind , _ := isOnKindCluster (clientset )
159- if onKind && ingressDomain == "" {
160- logger .Info ("We detected being on a KinD cluster!" )
161- return "kind"
142+ func (r * RayClusterReconciler ) getIngressHost (ctx context.Context , clientset * kubernetes.Clientset , cluster * rayv1.RayCluster , ingressNameFromCluster string ) string {
143+ ingressDomain := "fake.domain"
144+ if r .Config != nil && r .Config .IngressDomain != "" {
145+ ingressDomain = r .Config .IngressDomain
162146 }
163- logger .Info ("We detected being on Vanilla Kubernetes!" )
164- return fmt .Sprintf ("ray-dashboard-%s-%s.%s" , cluster .Name , cluster .Namespace , ingressDomain )
147+ if ingressDomain == "kind" {
148+ return ingressDomain
149+ }
150+ return fmt .Sprintf ("%s-%s.%s" , ingressNameFromCluster , cluster .Namespace , ingressDomain )
165151}
166152
167153func (r * RayClusterReconciler ) isRayDashboardOAuthEnabled () bool {
0 commit comments