Skip to content

Commit 23d0195

Browse files
authored
[apiserver] Use ClusterIP instead of NodePort for KubeRay API server service (#3708)
1 parent 05b77e1 commit 23d0195

File tree

8 files changed

+104
-113
lines changed

8 files changed

+104
-113
lines changed

apiserver/Autoscaling.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ run an example.
66

77
## Setup
88

9-
Refer to the [README](README.md) for setting up the KubeRay operator and APIServer.
9+
Refer to the [Install with Helm](README.md#install-with-helm) section in the README for
10+
setting up the KubeRay operator and APIServer, and port-forward the HTTP endpoint to local
11+
port 31888.
1012

1113
## Example
1214

apiserver/CreatingServe.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ creating the cluster:
1717

1818
## Setup
1919

20-
Refer to the [README](README.md) for setting up the KubeRay operator and APIServer.
20+
Refer to the [Install with Helm](README.md#install-with-helm) section in the README for
21+
setting up the KubeRay operator and APIServer, and port-forward the HTTP endpoint to local
22+
port 31888.
2123

2224
## Example
2325

apiserver/HACluster.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ We will provide a detailed example on how to create this highly available APISer
1717

1818
### Setup Ray Operator and APIServer
1919

20-
Refer to the [README](README.md) for setting up the KubeRay operator and APIServer.
20+
Refer to the [Install with Helm](README.md#install-with-helm) section in the README for
21+
setting up the KubeRay operator and APIServer, and port-forward the HTTP endpoint to local
22+
port 31888.
2123

2224
## Example
2325

apiserver/JobSubmission.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ kubectl delete raycluster --all
2323

2424
### Deploy KubeRay operator and APIServer
2525

26-
Refer to [README](README.md) for setting up the KubeRay operator and APIServer.
26+
Refer to the [Install with Helm](README.md#install-with-helm) section in the README for
27+
setting up the KubeRay operator and APIServer, and port-forward the HTTP endpoint to local
28+
port 31888.
2729

2830
### Install ConfigMap
2931

apiserver/Monitoring.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ If this flag is enabled, an `http` port at the `/metrics` endpoint provides APIS
1414

1515
### Deploy KubeRay operator and APIServer
1616

17-
Refer to [README](README.md) for setting up the KubeRay operator and APIServer. This will
18-
set the flag `collectMetricsFlag` to `true`, which enables metrics collection.
17+
Refer to the [Install with Helm](README.md#install-with-helm) section in the README for
18+
setting up the KubeRay operator and APIServer, and port-forward the HTTP endpoint to local
19+
port 31888. This will set the flag `collectMetricsFlag` to `true`, which enables metrics
20+
collection.
1921

2022
> [!IMPORTANT]
2123
> All the following guidance requires you to switch your working directory to the KubeRay project root.

apiserver/README.md

Lines changed: 41 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,21 @@ The KubeRay APIServer is an optional component that provides a layer of simplifi
99

1010
## Installation
1111

12-
### Start a local apiserver
13-
14-
You can build and start the APIServer from scratch in your local environment with a single command. This will deploy all the necessary components to a local kind cluster.
15-
16-
```sh
17-
make start-local-apiserver
18-
```
12+
### Install with Helm
1913

20-
The APIServer supports HTTP requests, so you can easily verify its successful startup by issuing two simple curl commands.
14+
Ensure that the version of Helm is v3+. Currently, [existing CI tests](https://github.com/ray-project/kuberay/blob/master/.github/workflows/helm-lint.yaml) are based on Helm v3.4.1 and v3.9.4.
2115

2216
```sh
23-
# Create complete template.
24-
curl --silent -X 'POST' \
25-
'http://localhost:31888/apis/v1/namespaces/ray-system/compute_templates' \
26-
-H 'accept: application/json' \
27-
-H 'Content-Type: application/json' \
28-
-d '{
29-
"name": "default-template",
30-
"namespace": "ray-system",
31-
"cpu": 2,
32-
"memory": 4
33-
}'
34-
35-
# Check whether compute template is created successfully.
36-
curl --silent -X 'GET' \
37-
'http://localhost:31888/apis/v1/namespaces/ray-system/compute_templates' \
38-
-H 'accept: application/json'
17+
helm version
3918
```
4019

41-
### Install with Helm
20+
#### Create a Kubernetes cluster
4221

43-
Ensure that the version of Helm is v3+. Currently, [existing CI tests](https://github.com/ray-project/kuberay/blob/master/.github/workflows/helm-lint.yaml) are based on Helm v3.4.1 and v3.9.4.
22+
Create a local Kubernetes cluster using [Kind](https://kind.sigs.k8s.io/). If you already
23+
have a Kubernetes cluster, you can skip this step.
4424

4525
```sh
46-
helm version
26+
kind create cluster --image=kindest/node:v1.26.0
4727
```
4828

4929
#### Install KubeRay Operator
@@ -52,66 +32,52 @@ Refer to [this document](https://docs.ray.io/en/master/cluster/kubernetes/gettin
5232

5333
#### Install KubeRay APIServer
5434

55-
- Install a stable version via the Helm repository (supports KubeRay v0.4.0+ only)
35+
Refer to [this document](../helm-chart/kuberay-apiserver/README.md#without-security-proxy) to install the latest
36+
stable KubeRay operator and APIServer (without the security proxy) from the Helm
37+
repository.
5638

57-
```sh
58-
# Install the KubeRay helm repo
59-
helm repo add kuberay https://ray-project.github.io/kuberay-helm/
39+
> [!IMPORTANT]
40+
> If you install APIServer with security proxy, you may receive an "Unauthorized" error
41+
> when making a request. Please add an authorization header to the request: `-H 'Authorization: 12345'`
42+
> or install the APIServer without a security proxy.
6043
61-
# Install KubeRay APIServer.
62-
helm install kuberay-apiserver kuberay/kuberay-apiserver
44+
#### Port-forwarding the APIServer service
6345

64-
# Check the KubeRay APIServer Pod in `default` namespace
65-
kubectl get pods
66-
# NAME READY STATUS RESTARTS AGE
67-
# kuberay-apiserver-857869f665-b94px 1/1 Running 0 86m
68-
# kuberay-operator-7456c6b69b-t6pt7 1/1 Running 0 172m
69-
```
46+
Use the following command for port-forwarding to access the APIServer through port 31888:
7047

71-
- Install the nightly version
72-
73-
```sh
74-
# Step1: Clone KubeRay repository
75-
76-
# Step2: Move to `helm-chart/kuberay-apiserver`
77-
cd helm-chart/kuberay-apiserver
78-
79-
# Step3: Install KubeRay APIServer
80-
helm install kuberay-apiserver .
81-
```
82-
83-
- Install the current working branch version
84-
85-
```sh
86-
# Step1: Clone KubeRay repository
87-
88-
# Step2: Change directory to the api server
89-
cd apiserver
90-
91-
# Step3: Build docker image, create a local kind cluster and deploy api server (using helm)
92-
make docker-image cluster load-image deploy
93-
```
48+
```sh
49+
kubectl port-forward service/kuberay-apiserver-service 31888:8888
50+
```
9451

95-
#### List the chart
52+
### For Development: Start a Local APIServer
9653

97-
To list the deployed charts:
54+
You can build and start the APIServer from scratch in your local environment with a single command. This will deploy all the necessary components to a local kind cluster.
9855

9956
```sh
100-
helm ls
101-
# NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
102-
# kuberay-apiserver default 1 2023-09-25 10:42:34.267328 +0300 EEST deployed kuberay-apiserver-1.0.0
103-
# kuberay-operator default 1 2023-09-25 10:41:48.355831 +0300 EEST deployed kuberay-operator-1.0.0
57+
make start-local-apiserver
10458
```
10559

106-
#### Uninstall the Chart
60+
### Verify the installation
61+
62+
The APIServer supports HTTP requests, so you can easily verify its successful startup by issuing two simple curl commands.
10763

10864
```sh
109-
# Uninstall the `kuberay-apiserver` release
110-
helm uninstall kuberay-apiserver
65+
# Create complete template.
66+
curl --silent -X 'POST' \
67+
'http://localhost:31888/apis/v1/namespaces/ray-system/compute_templates' \
68+
-H 'accept: application/json' \
69+
-H 'Content-Type: application/json' \
70+
-d '{
71+
"name": "default-template",
72+
"namespace": "ray-system",
73+
"cpu": 2,
74+
"memory": 4
75+
}'
11176

112-
# The KubeRay APIServer Pod should be removed.
113-
kubectl get pods
114-
# No resources found in default namespace.
77+
# Check whether compute template is created successfully.
78+
curl --silent -X 'GET' \
79+
'http://localhost:31888/apis/v1/namespaces/ray-system/compute_templates' \
80+
-H 'accept: application/json'
11581
```
11682

11783
## Usage
@@ -122,7 +88,7 @@ After deployment, you can use the `{{baseUrl}}` to access the service. Refer to
12288

12389
- for ingress access, you will need to create your own ingress
12490

125-
Details of the request parameters can be found in [KubeRay Swagger](https://github.com/ray-project/kuberay/tree/master/proto/swagger). This document only provides basic examples.
91+
Details of the request parameters can be found in [KubeRay Swagger](https://github.com/ray-project/kuberay/tree/master/proto/swagger). This README provides only basic examples.
12692

12793
### Setup a smoke test
12894

helm-chart/kuberay-apiserver/README.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,56 @@ helm version
1313

1414
## Install KubeRay API Server
1515

16-
* Install a stable version via Helm repository (only supports KubeRay v0.4.0+)
16+
### Without security proxy
1717

18-
```sh
19-
helm repo add kuberay https://ray-project.github.io/kuberay-helm/
18+
- Install a stable version via Helm repository
2019

21-
# Install the KubeRay API Server at Version v1.1.0.
22-
helm install kuberay-apiserver kuberay/kuberay-apiserver --version 1.1.0
20+
```sh
21+
helm repo add kuberay https://ray-project.github.io/kuberay-helm/
22+
helm repo update
23+
# Install KubeRay APIServer without security proxy
24+
helm install kuberay-apiserver kuberay/kuberay-apiserver --version 1.4.0 --set security=null
25+
```
26+
27+
- Install the nightly version
28+
29+
```sh
30+
# Step1: Clone KubeRay repository
31+
32+
# Step2: Navigate to `helm-chart/kuberay-apiserver`
33+
cd helm-chart/kuberay-apiserver
2334

24-
# Check that the KubeRay API Server is running in the "default" namespaces.
25-
kubectl get pods
26-
# NAME READY STATUS RESTARTS AGE
27-
# kuberay-apiserver-xxxxxx 1/1 Running 0 17s
28-
```
35+
# Step3: Install the KubeRay apiserver
36+
helm install kuberay-apiserver . --set security=null
37+
```
2938

30-
* Install the nightly version
39+
### With security proxy
3140

32-
```sh
33-
# Step1: Clone KubeRay repository
41+
- Install a stable version via Helm repository
3442

35-
# Step2: Move to `helm-chart/kuberay-apiserver`
43+
```sh
44+
helm repo add kuberay https://ray-project.github.io/kuberay-helm/
45+
helm repo update
46+
# Install KubeRay APIServer
47+
helm install kuberay-apiserver kuberay/kuberay-apiserver --version 1.4.0
48+
```
49+
50+
- Install the nightly version
51+
52+
```sh
53+
# Step1: Clone KubeRay repository
54+
55+
# Step2: Navigate to `helm-chart/kuberay-apiserver`
56+
cd helm-chart/kuberay-apiserver
57+
58+
# Step3: Install the KubeRay apiserver
59+
helm install kuberay-apiserver .
60+
```
3661

37-
# Step3: Install the KubeRay apiserver
38-
helm install kuberay-apiserver .
39-
```
62+
> [!IMPORTANT]
63+
> If you receive an "Unauthorized" error when making a request, please add an
64+
> authorization header to the request: `-H 'Authorization: 12345'` or install the
65+
> APIServer without a security proxy.
4066
4167
## List the chart
4268

helm-chart/kuberay-apiserver/values.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,17 @@ tolerations: []
6666

6767
# Only one service type needs to be picked
6868
service:
69-
# Nodeport service
70-
type: NodePort
69+
# ClusterIP service
70+
type: ClusterIP
7171
ports:
7272
- name: http
73+
protocol: TCP
7374
port: 8888
7475
targetPort: 8888
75-
nodePort: 31888
7676
- name: rpc
77+
protocol: TCP
7778
port: 8887
7879
targetPort: 8887
79-
nodePort: 31887
80-
# ClusterIP service
81-
# type: ClusterIP
82-
# ports:
83-
# - name: http
84-
# protocol: TCP
85-
# port: 8888
86-
# targetPort: 8888
87-
# - name: rpc
88-
# protocol: TCP
89-
# port: 8887
90-
# targetPort: 8887
9180

9281
# You can only enable an ingress or route, if you are using OpenShift cluster
9382
# Also note that in order to enable ingress or route you need to use ClusterIP service

0 commit comments

Comments
 (0)