8
8
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
9
9
10
10
networkingv1 "k8s.io/api/networking/v1"
11
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
11
"k8s.io/apimachinery/pkg/types"
13
12
"k8s.io/apimachinery/pkg/util/intstr"
14
13
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
@@ -39,7 +38,7 @@ func desiredRayClientRoute(cluster *rayv1.RayCluster) *routeapply.RouteApplyConf
39
38
}
40
39
41
40
// 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 {
43
42
return networkingv1ac .Ingress (rayClientNameFromCluster (cluster ), cluster .Namespace ).
44
43
WithLabels (map [string ]string {"ray.io/cluster-name" : cluster .Name }).
45
44
WithAnnotations (map [string ]string {
@@ -55,7 +54,7 @@ func desiredRayClientIngress(cluster *rayv1.RayCluster, ingressDomain string) *n
55
54
WithSpec (networkingv1ac .IngressSpec ().
56
55
WithIngressClassName ("nginx" ).
57
56
WithRules (networkingv1ac .IngressRule ().
58
- WithHost (rayClientNameFromCluster ( cluster ) + "-" + cluster . Namespace + "." + ingressDomain ).
57
+ WithHost (ingressHost ).
59
58
WithHTTP (networkingv1ac .HTTPIngressRuleValue ().
60
59
WithPaths (networkingv1ac .HTTPIngressPath ().
61
60
WithPath ("/" ).
@@ -85,7 +84,7 @@ func desiredClusterIngress(cluster *rayv1.RayCluster, ingressHost string) *netwo
85
84
WithUID (types .UID (cluster .UID ))).
86
85
WithSpec (networkingv1ac .IngressSpec ().
87
86
WithRules (networkingv1ac .IngressRule ().
88
- WithHost (ingressHost ). // KinD hostname or ingressDomain
87
+ WithHost (ingressHost ). // Full Hostname
89
88
WithHTTP (networkingv1ac .HTTPIngressRuleValue ().
90
89
WithPaths (networkingv1ac .HTTPIngressPath ().
91
90
WithPath ("/" ).
@@ -104,19 +103,6 @@ func desiredClusterIngress(cluster *rayv1.RayCluster, ingressHost string) *netwo
104
103
)
105
104
}
106
105
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
-
120
106
// getDiscoveryClient returns a discovery client for the current reconciler
121
107
func getDiscoveryClient (config * rest.Config ) (* discovery.DiscoveryClient , error ) {
122
108
return discovery .NewDiscoveryClientForConfig (config )
@@ -153,15 +139,15 @@ func isOpenShift(ctx context.Context, clientset *kubernetes.Clientset, cluster *
153
139
}
154
140
155
141
// 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
162
146
}
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 )
165
151
}
166
152
167
153
func (r * RayClusterReconciler ) isRayDashboardOAuthEnabled () bool {
0 commit comments