-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# RayService: MobileNet example | ||
|
||
> **Note:** The Python files for the Ray Serve application and its client are in the repository [ray-project/serve_config_examples](https://github.com/ray-project/serve_config_examples). | ||
## Step 1: Create a Kubernetes cluster with Kind. | ||
|
||
```sh | ||
kind create cluster --image=kindest/node:v1.23.0 | ||
``` | ||
|
||
## Step 2: Install KubeRay operator | ||
|
||
Follow [this document](../../helm-chart/kuberay-operator/README.md) to install the latest stable KubeRay operator via Helm repository. | ||
|
||
## Step 3: Install a RayService | ||
|
||
```sh | ||
# path: ray-operator/config/samples/ | ||
kubectl apply -f ray-service.mobilenet.yaml | ||
``` | ||
|
||
* The [mobilenet.py](https://github.com/ray-project/serve_config_examples/blob/master/mobilenet/mobilenet.py) file requires `tensorflow` as a dependency. Hence, the YAML file uses `rayproject/ray-ml:2.5.0` instead of `rayproject/ray:2.5.0`. | ||
* `python-multipart` is required for the request parsing function `starlette.requests.form()`, so the YAML file includes `python-multipart` in the runtime environment. | ||
|
||
## Step 4: Forward the port of Serve | ||
|
||
```sh | ||
kubectl port-forward svc/rayservice-mobilenet-serve-svc 8000 | ||
``` | ||
|
||
Note that the Serve service will be created after the Serve applications are ready and running. This process may take approximately 1 minute after all Pods in the RayCluster are running. | ||
|
||
## Step 5: Send a request to the ImageClassifier | ||
|
||
* Step 5.1: Prepare an image file. | ||
* Step 5.2: Update `image_path` in [mobilenet_req.py](https://github.com/ray-project/serve_config_examples/blob/master/mobilenet/mobilenet_req.py) | ||
* Step 5.3: Send a request to the `ImageClassifier`. | ||
```sh | ||
python mobilenet_req.py | ||
# sample output: {"prediction":["n02099601","golden_retriever",0.17944198846817017]} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
apiVersion: ray.io/v1alpha1 | ||
kind: RayService | ||
metadata: | ||
name: rayservice-mobilenet | ||
spec: | ||
serviceUnhealthySecondThreshold: 300 # Config for the health check threshold for service. Default value is 60. | ||
deploymentUnhealthySecondThreshold: 300 # Config for the health check threshold for deployments. Default value is 60. | ||
serveConfig: | ||
importPath: mobilenet.mobilenet:app | ||
runtimeEnv: | | ||
working_dir: "https://github.com/ray-project/serve_config_examples/archive/b393e77bbd6aba0881e3d94c05f968f05a387b96.zip" | ||
pip: ["python-multipart==0.0.6"] | ||
rayClusterConfig: | ||
rayVersion: '2.5.0' # should match the Ray version in the image of the containers | ||
######################headGroupSpecs################################# | ||
# Ray head pod template. | ||
headGroupSpec: | ||
# The `rayStartParams` are used to configure the `ray start` command. | ||
# See https://github.com/ray-project/kuberay/blob/master/docs/guidance/rayStartParams.md for the default settings of `rayStartParams` in KubeRay. | ||
# See https://docs.ray.io/en/latest/cluster/cli.html#ray-start for all available options in `rayStartParams`. | ||
rayStartParams: | ||
dashboard-host: '0.0.0.0' | ||
#pod template | ||
template: | ||
spec: | ||
containers: | ||
- name: ray-head | ||
image: rayproject/ray-ml:2.5.0 | ||
resources: | ||
limits: | ||
cpu: 2 | ||
memory: 8Gi | ||
requests: | ||
cpu: 2 | ||
memory: 8Gi | ||
ports: | ||
- containerPort: 6379 | ||
name: gcs-server | ||
- containerPort: 8265 # Ray dashboard | ||
name: dashboard | ||
- containerPort: 10001 | ||
name: client | ||
- containerPort: 8000 | ||
name: serve | ||
workerGroupSpecs: | ||
# the pod replicas in this group typed worker | ||
- replicas: 1 | ||
minReplicas: 1 | ||
maxReplicas: 5 | ||
# logical group name, for this called small-group, also can be functional | ||
groupName: worker | ||
# The `rayStartParams` are used to configure the `ray start` command. | ||
# See https://github.com/ray-project/kuberay/blob/master/docs/guidance/rayStartParams.md for the default settings of `rayStartParams` in KubeRay. | ||
# See https://docs.ray.io/en/latest/cluster/cli.html#ray-start for all available options in `rayStartParams`. | ||
rayStartParams: {} | ||
#pod template | ||
template: | ||
spec: | ||
containers: | ||
- name: ray-worker # must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc' | ||
image: rayproject/ray-ml:2.5.0 | ||
lifecycle: | ||
preStop: | ||
exec: | ||
command: ["/bin/sh","-c","ray stop"] | ||
resources: | ||
limits: | ||
cpu: "2" | ||
memory: "8Gi" | ||
requests: | ||
cpu: "2" | ||
memory: "8Gi" |