Skip to content

Commit 67c6b38

Browse files
authored
adding local deplyment script using kind (#3863)
* adding local deplyment script using kind * deleting kind clusters each time and cleaning .md * deleting kind clusters each time and cleaning .md * cleaning up local deploy script * cleaning up local deploy script * cleaning up script and .md * cleaning script * cleaning script * cleaning up script * cleaning script * cleaning * cleaning script * trim trailing whitespace
1 parent 5e5af55 commit 67c6b38

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

ray-operator/DEVELOPMENT.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ kubectl logs deployments/kuberay-operator
9797
* The command `make docker-build` (Step 3) will also run `make build` (Go project compilation).
9898
* Step 6 also installs the custom resource definitions (CRDs) used by the KubeRay operator.
9999

100+
#### Using Local Deployment Script
101+
102+
You can also run the `local_deploy.sh` bash script (located in `ray-operator/hack`) which runs the steps shown above, but deletes and recreates the kind cluster each run for consistency during repeated development.
103+
104+
There are configuable variables in the script, the defaults are shown below:
105+
106+
```bash
107+
IMAGE_TAG="kuberay-dev"
108+
KIND_CLUSTER_NAME="kuberay-dev"
109+
KIND_NODE_IMAGE="kindest/node:v1.24.0"
110+
```
111+
112+
Additionally, you can run the script with a `-l` or `--logs` to stream the logs of the ray operator to the terminal after installation.
113+
100114
### Run the operator outside the cluster
101115

102116
This step requires you to switch your working directory to the kuberay project root. If

ray-operator/hack/local_deploy.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
PROJECT_ROOT="${SCRIPT_DIR}/../.." # hack/ -> ray-operator/ -> kuberay/
6+
HELM_CHART_PATH="${PROJECT_ROOT}/helm-chart/kuberay-operator"
7+
RAY_OPERATOR_PATH="${PROJECT_ROOT}/ray-operator"
8+
9+
# --- Configuration Variables ---
10+
IMAGE_TAG="${IMAGE_TAG:=kuberay-dev}"
11+
KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:=kuberay-dev}"
12+
KIND_NODE_IMAGE="${KIND_NODE_IMAGE:=kindest/node:v1.24.0}"
13+
14+
delete_kind_cluster() {
15+
echo "--- Deleting Kind Cluster ---"
16+
if kind get clusters | grep -q "${KIND_CLUSTER_NAME}"; then
17+
echo "Kind cluster '${KIND_CLUSTER_NAME}' found. Deleting it..."
18+
kind delete cluster --name "${KIND_CLUSTER_NAME}"
19+
else
20+
echo "Kind cluster '${KIND_CLUSTER_NAME}' not found. Skipping deletion."
21+
fi
22+
}
23+
24+
create_kind_cluster() {
25+
echo "--- Creating Kind Cluster ---"
26+
echo "Creating Kind cluster '${KIND_CLUSTER_NAME}' with image '${KIND_NODE_IMAGE}'..."
27+
kind create cluster --name "${KIND_CLUSTER_NAME}" --image="${KIND_NODE_IMAGE}"
28+
echo "Kind cluster nodes are ready."
29+
}
30+
31+
# Parsing for arguements
32+
SHOW_LOGS=false
33+
while [[ "$#" -gt 0 ]]; do
34+
case "$1" in
35+
-l|--logs)
36+
SHOW_LOGS=true
37+
shift
38+
;;
39+
*)
40+
echo "Unknown option: $1"
41+
exit 1
42+
;;
43+
esac
44+
done
45+
46+
echo "--- Ensuring Clean Kind Cluster ---"
47+
delete_kind_cluster
48+
create_kind_cluster
49+
50+
echo "--- Building Docker Image ---"
51+
FULL_IMAGE_NAME="kuberay-operator:${IMAGE_TAG}"
52+
echo "Building image: ${FULL_IMAGE_NAME}"
53+
54+
echo "Running make docker-build from ray-operator path: ${RAY_OPERATOR_PATH}"
55+
make -C "${RAY_OPERATOR_PATH}" docker-build IMG="${FULL_IMAGE_NAME}"
56+
57+
echo "--- Loading Image into Kind Cluster ---"
58+
kind load docker-image "${FULL_IMAGE_NAME}" --name "${KIND_CLUSTER_NAME}"
59+
60+
echo "Running make sync from ray-operator path: ${RAY_OPERATOR_PATH}"
61+
make -C "${RAY_OPERATOR_PATH}" sync
62+
63+
echo "--- Installing KubeRay Operator via Helm Chart ---"
64+
echo "Installing new Helm release: kuberay-operator"
65+
echo "Helm chart path: ${HELM_CHART_PATH}"
66+
helm install "kuberay-operator" "${HELM_CHART_PATH}" \
67+
--namespace "default" \
68+
--set "image.repository=kuberay-operator" \
69+
--set "image.tag=${IMAGE_TAG}"
70+
71+
echo "--- Waiting for Deployment Rollout ---"
72+
kubectl -n default rollout status deployment kuberay-operator --timeout=5m
73+
74+
# Check the logs
75+
if [ "$SHOW_LOGS" = true ]; then
76+
echo "--- Streaming Controller Logs (Ctrl+C to stop) ---"
77+
kubectl -n default logs -f deployment/kuberay-operator
78+
fi

0 commit comments

Comments
 (0)