@@ -26,6 +26,7 @@ import (
2626 "sigs.k8s.io/controller-runtime/pkg/manager"
2727
2828 rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
29+ "github.com/ray-project/kuberay/ray-operator/controllers/ray/utils/dashboardclient"
2930)
3031
3132const (
@@ -640,7 +641,7 @@ func EnvVarByName(envName string, envVars []corev1.EnvVar) (corev1.EnvVar, bool)
640641}
641642
642643type ClientProvider interface {
643- GetDashboardClient (mgr manager.Manager ) func (rayCluster * rayv1.RayCluster , url string ) (RayDashboardClientInterface , error )
644+ GetDashboardClient (mgr manager.Manager ) func (rayCluster * rayv1.RayCluster , url string ) (dashboardclient. RayDashboardClientInterface , error )
644645 GetHttpProxyClient (mgr manager.Manager ) func (hostIp , podNamespace , podName string , port int ) RayHttpProxyClientInterface
645646}
646647
@@ -757,8 +758,9 @@ func FetchHeadServiceURL(ctx context.Context, cli client.Client, rayCluster *ray
757758 return headServiceURL , nil
758759}
759760
760- func GetRayDashboardClientFunc (mgr manager.Manager , useKubernetesProxy bool ) func (rayCluster * rayv1.RayCluster , url string ) (RayDashboardClientInterface , error ) {
761- return func (rayCluster * rayv1.RayCluster , url string ) (RayDashboardClientInterface , error ) {
761+ func GetRayDashboardClientFunc (mgr manager.Manager , useKubernetesProxy bool ) func (rayCluster * rayv1.RayCluster , url string ) (dashboardclient.RayDashboardClientInterface , error ) {
762+ return func (rayCluster * rayv1.RayCluster , url string ) (dashboardclient.RayDashboardClientInterface , error ) {
763+ dashboardClient := & dashboardclient.RayDashboardClient {}
762764 if useKubernetesProxy {
763765 var err error
764766 headSvcName := rayCluster .Status .Head .ServiceName
@@ -769,20 +771,20 @@ func GetRayDashboardClientFunc(mgr manager.Manager, useKubernetesProxy bool) fun
769771 return nil , err
770772 }
771773 }
772- return & RayDashboardClient {
774+
775+ dashboardClient .InitClient (
773776 // Use `mgr.GetHTTPClient()` instead of `http.Client{}` so that the client has proper authentication
774777 // configured to communicate with the Kubernetes API server.
775- client : mgr .GetHTTPClient (),
776- dashboardURL : fmt .Sprintf ("%s/api/v1/namespaces/%s/services/%s:dashboard/proxy" , mgr .GetConfig ().Host , rayCluster .Namespace , headSvcName ),
777- }, nil
778+ mgr .GetHTTPClient (),
779+ fmt .Sprintf ("%s/api/v1/namespaces/%s/services/%s:dashboard/proxy" , mgr .GetConfig ().Host , rayCluster .Namespace , headSvcName ),
780+ )
781+ return dashboardClient , nil
778782 }
779783
780- return & RayDashboardClient {
781- client : & http.Client {
782- Timeout : 2 * time .Second ,
783- },
784- dashboardURL : "http://" + url ,
785- }, nil
784+ dashboardClient .InitClient (& http.Client {
785+ Timeout : 2 * time .Second ,
786+ }, "http://" + url )
787+ return dashboardClient , nil
786788 }
787789}
788790
0 commit comments