@@ -4,8 +4,12 @@ import (
4
4
"os/exec"
5
5
6
6
corev1 "k8s.io/api/core/v1"
7
+ "k8s.io/apimachinery/pkg/api/resource"
8
+ corev1ac "k8s.io/client-go/applyconfigurations/core/v1"
7
9
8
10
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
11
+ "github.com/ray-project/kuberay/ray-operator/controllers/ray/utils"
12
+ rayv1ac "github.com/ray-project/kuberay/ray-operator/pkg/client/applyconfiguration/ray/v1"
9
13
e2e "github.com/ray-project/kuberay/ray-operator/test/e2erayservice"
10
14
. "github.com/ray-project/kuberay/ray-operator/test/support"
11
15
)
@@ -23,3 +27,100 @@ func requestRayService(t Test, rayService *rayv1.RayService, curlPod *corev1.Pod
23
27
24
28
return stdout1 .String () + ", " + stdout2 .String ()
25
29
}
30
+
31
+ func rayServiceSampleYamlApplyConfigurationWithWorker () * rayv1ac.RayServiceSpecApplyConfiguration {
32
+ return rayv1ac .RayServiceSpec ().WithServeConfigV2 (`applications:
33
+ - name: fruit_app
34
+ import_path: fruit.deployment_graph
35
+ route_prefix: /fruit
36
+ runtime_env:
37
+ working_dir: "https://github.com/ray-project/test_dag/archive/78b4a5da38796123d9f9ffff59bab2792a043e95.zip"
38
+ deployments:
39
+ - name: MangoStand
40
+ num_replicas: 1
41
+ user_config:
42
+ price: 3
43
+ ray_actor_options:
44
+ num_cpus: 0.1
45
+ - name: OrangeStand
46
+ num_replicas: 1
47
+ user_config:
48
+ price: 2
49
+ ray_actor_options:
50
+ num_cpus: 0.1
51
+ - name: FruitMarket
52
+ num_replicas: 1
53
+ ray_actor_options:
54
+ num_cpus: 0.1
55
+ - name: math_app
56
+ import_path: conditional_dag.serve_dag
57
+ route_prefix: /calc
58
+ runtime_env:
59
+ working_dir: "https://github.com/ray-project/test_dag/archive/78b4a5da38796123d9f9ffff59bab2792a043e95.zip"
60
+ deployments:
61
+ - name: Adder
62
+ num_replicas: 1
63
+ user_config:
64
+ increment: 3
65
+ ray_actor_options:
66
+ num_cpus: 0.1
67
+ - name: Multiplier
68
+ num_replicas: 1
69
+ user_config:
70
+ factor: 5
71
+ ray_actor_options:
72
+ num_cpus: 0.1
73
+ - name: Router
74
+ ray_actor_options:
75
+ num_cpus: 0.1
76
+ num_replicas: 1` ).
77
+ WithRayClusterSpec (rayv1ac .RayClusterSpec ().
78
+ WithRayVersion (GetRayVersion ()).
79
+ WithHeadGroupSpec (rayv1ac .HeadGroupSpec ().
80
+ WithRayStartParams (map [string ]string {"dashboard-host" : "0.0.0.0" }).
81
+ WithTemplate (corev1ac .PodTemplateSpec ().
82
+ WithSpec (corev1ac .PodSpec ().
83
+ WithContainers (corev1ac .Container ().
84
+ WithName ("ray-head" ).
85
+ WithImage (GetRayImage ()).
86
+ WithPorts (
87
+ corev1ac .ContainerPort ().WithName (utils .GcsServerPortName ).WithContainerPort (utils .DefaultGcsServerPort ),
88
+ corev1ac .ContainerPort ().WithName (utils .ServingPortName ).WithContainerPort (utils .DefaultServingPort ),
89
+ corev1ac .ContainerPort ().WithName (utils .DashboardPortName ).WithContainerPort (utils .DefaultDashboardPort ),
90
+ corev1ac .ContainerPort ().WithName (utils .ClientPortName ).WithContainerPort (utils .DefaultClientPort ),
91
+ ).
92
+ WithResources (corev1ac .ResourceRequirements ().
93
+ WithRequests (corev1.ResourceList {
94
+ corev1 .ResourceCPU : resource .MustParse ("1" ),
95
+ corev1 .ResourceMemory : resource .MustParse ("2Gi" ),
96
+ }).
97
+ WithLimits (corev1.ResourceList {
98
+ corev1 .ResourceCPU : resource .MustParse ("2" ),
99
+ corev1 .ResourceMemory : resource .MustParse ("3Gi" ),
100
+ })))))).
101
+ WithWorkerGroupSpecs (rayv1ac .WorkerGroupSpec ().
102
+ WithReplicas (1 ).
103
+ WithGroupName ("ray-worker-1" ).
104
+ WithMinReplicas (1 ).
105
+ WithMaxReplicas (1 ).
106
+ WithRayStartParams (map [string ]string {"num-cpus" : "1" }).
107
+ WithTemplate (corev1ac .PodTemplateSpec ().
108
+ WithSpec (corev1ac .PodSpec ().
109
+ WithContainers (corev1ac .Container ().
110
+ WithName ("ray-worker" ).
111
+ WithImage (GetRayImage ()).
112
+ WithResources (corev1ac .ResourceRequirements ().
113
+ WithRequests (corev1.ResourceList {
114
+ corev1 .ResourceCPU : resource .MustParse ("500m" ),
115
+ corev1 .ResourceMemory : resource .MustParse ("1Gi" ),
116
+ }).
117
+ WithLimits (corev1.ResourceList {
118
+ corev1 .ResourceCPU : resource .MustParse ("1" ),
119
+ corev1 .ResourceMemory : resource .MustParse ("2Gi" ),
120
+ }),
121
+ ),
122
+ ),
123
+ ),
124
+ ),
125
+ ))
126
+ }
0 commit comments