Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helm #109

Merged
merged 3 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions helm-chart/ray-cluster-helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions helm-chart/ray-cluster-helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: ray-cluster-helm
version: 0.1.0
icon: https://github.com/ray-project/ray/raw/master/doc/source/images/ray_header_logo.png
65 changes: 65 additions & 0 deletions helm-chart/ray-cluster-helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Ray Cluster

Make sure ray-operator has been deployed.

[Ray](https://ray.io/) is An open source framework that provides a simple, universal API for building distributed applications. Ray is packaged with RLlib, a scalable reinforcement learning library, and Tune, a scalable hyperparameter tuning library.
zhuangzhuang131419 marked this conversation as resolved.
Show resolved Hide resolved

## Helm

```console
$ helm version
version.BuildInfo{Version:"v3.6.2", GitCommit:"ee407bdf364942bcb8e8c665f82e15aa28009b71", GitTreeState:"dirty", GoVersion:"go1.16.5"}
```

## TL;DR;

```console
helm install --name ray-cluster-helm . --values values.yaml --namespace default
```

## Installing the Chart

To install the chart with the release name `my-release`:


```console
helm install --name sample ray-cluster-helm --values ray-cluster-helm/values.yaml --namespace default
```

> note: The chart will submit a RayCluster.


## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```console
helm delete ray-cluster-helm
```

The command removes nearly all the Kubernetes components associated with the
chart and deletes the release.

## Check Cluster status

### Get Service

```console
$ kubectl get svc -l ray.io/cluster=ray-cluster-helm
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ray-cluster-helm-head-svc ClusterIP 10.103.36.68 <none> 10001/TCP,6379/TCP,8265/TCP 9m24s
```

## Forward to dashboard

```console
$ kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
ray-cluster-helm-head-sd77l 1/1 Running 0 8h 10.1.61.208 docker-desktop <none> <none>
ray-cluster-helm-worker-workergroup-czxd6 1/1 Running 0 8h 10.1.61.207 docker-desktop <none> <none>
ray-operator-helm-687785b964-jgfhv 1/1 Running 6 3d4h 10.1.61.196 docker-desktop <none> <none>

$ kubectl port-forward ray-cluster-helm-head-sd77l 8265
Forwarding from 127.0.0.1:8265 -> 8265
Forwarding from [::1]:8265 -> 8265
```
56 changes: 56 additions & 0 deletions helm-chart/ray-cluster-helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "ray-cluster-helm.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "ray-cluster-helm.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "ray-cluster-helm.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "ray-cluster-helm.labels" -}}
app.kubernetes.io/name: {{ include "ray-cluster-helm.name" . }}
helm.sh/chart: {{ include "ray-cluster-helm.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "ray-cluster-helm.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "ray-cluster-helm.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
71 changes: 71 additions & 0 deletions helm-chart/ray-cluster-helm/templates/raycluster-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
apiVersion: ray.io/v1alpha1
kind: RayCluster
metadata:
labels:
{{ include "ray-cluster-helm.labels" . | indent 4 }}
name: {{ include "ray-cluster-helm.fullname" . }}
spec:
headGroupSpec:
serviceType: ClusterIP
rayStartParams:
{{- range $key, $val := .Values.head.initArgs }}
{{ $key }}: {{ $val | quote }}
{{- end }}
replicas: {{ .Values.head.replicas }}
template:
spec:
containers:
- volumeMounts: {{- toYaml .Values.head.volumeMounts | nindent 12 }}
name: ray-head
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources: {{- toYaml .Values.head.resources | nindent 14 }}
env:
- name: TYPE
value: head
{{- toYaml .Values.head.containerEnv | nindent 14}}
volumes: {{- toYaml .Values.head.volumes | nindent 10 }}
affinity: {{- toYaml .Values.head.affinity | nindent 10 }}
metadata:
annotation: {{- toYaml .Values.head.annotations | nindent 10 }}
labels:
groupName: {{ .Values.head.groupName }}
rayNodeType: {{ .Values.head.type }}
rayCluster: {{ include "ray-cluster-helm.fullname" . }}
{{ include "ray-cluster-helm.labels" . | indent 10 }}

workerGroupSpecs:
- rayStartParams:
{{- range $key, $val := .Values.worker.initArgs }}
{{ $key }}: {{ $val | quote }}
{{- end }}
replicas: {{ .Values.worker.replicas }}
minReplicas: {{ .Values.worker.miniReplicas | default 1 }}
maxReplicas: {{ .Values.worker.maxiReplicas | default 2147483647 }}
groupName: {{ .Values.worker.groupName }}
template:
spec:
initContainers:
- name: init-myservice
image: busybox:1.28
command: ['sh', '-c', "until nslookup $RAY_IP.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for myservice; sleep 2; done"]
containers:
- volumeMounts: {{- toYaml .Values.worker.volumeMounts | nindent 12 }}
name: ray-worker
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources: {{- toYaml .Values.worker.resources | nindent 14 }}
env:
- name: TYPE
value: worker
{{- toYaml .Values.worker.containerEnv | nindent 14}}
ports: {{- toYaml .Values.worker.ports | nindent 14}}
volumes: {{- toYaml .Values.worker.volumes | nindent 10 }}
affinity: {{- toYaml .Values.worker.affinity | nindent 10 }}
metadata:
annotation: {{- toYaml .Values.worker.annotations | nindent 10 }}
labels:
rayNodeType: {{ .Values.worker.type }}
groupName: {{ .Values.worker.groupName }}
rayCluster: {{ include "ray-cluster-helm.fullname" . }}
{{ include "ray-cluster-helm.labels" . | indent 10 }}
100 changes: 100 additions & 0 deletions helm-chart/ray-cluster-helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Default values for ray-cluster-helm.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

image:
repository: rayproject/ray
tag: latest
pullPolicy: IfNotPresent

nameOverride: "ray"
fullnameOverride: ""

head:
groupName: headgroup
replicas: 1
type: head
labels:
key: value
initArgs:
port: '6379'
object-manager-port: '12345'
node-manager-port: '12346'
object-store-memory: '100000000'
redis-password: 'LetMeInRay'
dashboard-host: '0.0.0.0'
num-cpus: '1' # can be auto-completed from the limits
node-ip-address: $MY_POD_IP # auto-completed as the head pod IP
containerEnv:
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
resources:
limits:
cpu: 1
requests:
cpu: 200m
annotations: {}
volumes:
- name: config
configMap:
name: ray-code
items:
- key: code.py
path: code.py
volumeMounts:
- mountPath: /opt
name: config


worker:
groupName: workergroup
replicas: 1
type: worker
labels:
key: value
initArgs:
node-ip-address: $MY_POD_IP
redis-password: LetMeInRay
containerEnv:
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: RAY_DISABLE_DOCKER_CPU_WARNING
value: "1"
- name: CPU_REQUEST
valueFrom:
resourceFieldRef:
containerName: ray-worker
resource: requests.cpu
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
ports:
- containerPort: 80
protocol: TCP
resources:
limits:
cpu: 1
requests:
cpu: 200m
annotations:
key: value
nodeSelector: {}
tolerations: []
affinity: {}
volumes:
- name: log-volume
emptyDir: {}
volumeMounts:
- mountPath: /var/log
name: log-volume

headServiceSuffix: "ray-operator.svc"

service:
type: ClusterIP
port: 8080
22 changes: 22 additions & 0 deletions helm-chart/ray-operator-helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
7 changes: 7 additions & 0 deletions helm-chart/ray-operator-helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: ray-operator-helm
version: 0.1.0
icon: https://github.com/ray-project/ray/raw/master/doc/source/images/ray_header_logo.png
type: application
40 changes: 40 additions & 0 deletions helm-chart/ray-operator-helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Ray Operator

Ray-Operator-Helm: A simple Helm chart

Run a deployment of Ray Operator.

Deploy ray operator first, then deploy ray cluster.

## Helm

Make sure helm version is v3+
```console
$ helm version
version.BuildInfo{Version:"v3.6.2", GitCommit:"ee407bdf364942bcb8e8c665f82e15aa28009b71", GitTreeState:"dirty", GoVersion:"go1.16.5"}
```

## Installing the Chart

Please use command below:
```console
$ helm install ray-operator-helm . --values values.yaml --namespace default --create-namespace
```
## List the Chart

To list the `my-release` deployment:

```console
$ helm list -n default
```

## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```console
$ helm delete ray-operator-helm
```

The command removes nearly all the Kubernetes components associated with the
chart and deletes the release.
Loading