Skip to content

Commit

Permalink
Update Helm charts (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Younday authored Dec 20, 2024
1 parent e62a7e5 commit 614665d
Show file tree
Hide file tree
Showing 48 changed files with 36,610 additions and 17,283 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cli-integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
working-directory: ./cli/tests/integration/
env:
CLUSTER_NAME: integration-tests
VERSION: 1.28.0
VERSION: 1.43.0
LICENSE_KEY: ${{ secrets.LICENSE_KEY }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_PWD: ${{ secrets.REGISTRY_PWD }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint-helm-charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
matrix:
include:
- dir: 'helm/syntho-ui'
dyff_args: '--exclude "frontend_url" --exclude "frontend_path" --exclude "frontend_protocol" --exclude "SynthoLicense" --exclude-regexp "core.image.*" --exclude-regexp "backend.image.*" --exclude-regexp "backend.user.*" --exclude-regexp "frontend.image.*" --exclude-regexp "redis.image.*" --exclude-regexp "db.image.*" --exclude "db.storageClassName" --exclude "db.pvLabelKey" --exclude "redis.storageClassName" --exclude "redis.pvLabelKey" --exclude "frontend.ingress.className" --exclude "frontend.ingress.hosts.0.host" --exclude "frontend.ingress.hosts.0.host" --exclude "frontend.ingress.tls.enabled" --exclude "frontend.ingress.tls.conf.0.hosts.0" --exclude "imagePullSecrets" --exclude "frontend.busyboxImage"'
- dir: 'helm/ray'
dyff_args: '--exclude-regexp "head.resources.*" --exclude-regexp "storage.*" --exclude-regexp "operatorImage.*" --exclude-regexp "image.*" --exclude "SynthoLicense" --exclude "head.initContainer.image" --exclude "worker.initContainerImage"'
dyff_args: '--exclude "frontend_url" --exclude "frontend_path" --exclude "frontend_protocol" --exclude "SynthoLicense" --exclude-regexp "core.image.*" --exclude-regexp "backend.image.*" --exclude-regexp "backend.user.*" --exclude-regexp "frontend.image.*" --exclude-regexp "redis.image.*" --exclude-regexp "db.image.*" --exclude "db.storageClassName" --exclude "db.pvLabelKey" --exclude "redis.storageClassName" --exclude "redis.pvLabelKey" --exclude "frontend.ingress.className" --exclude "frontend.ingress.hosts.0.host" --exclude "frontend.ingress.hosts.0.host" --exclude "frontend.ingress.tls.enabled" --exclude "frontend.ingress.tls.conf.0.hosts.0" --exclude "imagePullSecrets" --exclude "frontend.busyboxImage" --exclude-regexp "backend.env.*"'
- dir: 'helm/ray/chart'
dyff_args: '--exclude-regexp "ray-cluster.head.resources.*" --exclude-regexp "storage.*" --exclude-regexp "kuberay-operator.image.*" --exclude-regexp "kuberay-operator.imagePullSecrets.*" --exclude-regexp "ray-cluster.image.*" --exclude-regexp "ray-cluster.common.containerEnv.*" --exclude "ray-cluster.head.initContainer.image" --exclude "ray-cluster.worker.initContainerImage"'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
8 changes: 4 additions & 4 deletions cli/cli/scripts/deploy-ray-and-syntho-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ PV_LABEL_KEY="$PV_LABEL_KEY"


generate_ray_values() {
local TEMPLATE_FILE="$CHARTS_DIR/ray/values.yaml.tpl"
local OUTPUT_FILE="$CHARTS_DIR/ray/values-generated.yaml"
local TEMPLATE_FILE="$CHARTS_DIR/ray/chart/values.yaml.tpl"
local OUTPUT_FILE="$CHARTS_DIR/ray/chart/values-generated.yaml"

# Create a copy of the template file to work with
cp "$TEMPLATE_FILE" "$OUTPUT_FILE"
Expand All @@ -135,8 +135,8 @@ generate_ray_values() {
}

deploy_ray() {
local VALUES_YAML="$CHARTS_DIR/ray/values-generated.yaml"
local RAY_CHARTS="$CHARTS_DIR/ray"
local VALUES_YAML="$CHARTS_DIR/ray/chart/values-generated.yaml"
local RAY_CHARTS="$CHARTS_DIR/ray/chart"


if [[ "$DRY_RUN" == "true" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions cli/cli/scripts/update-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ do_rollout_kubernetes() {
}

replace_versions_in_values_yaml() {
local RAY_DIR="${NEW_RELEASE_DIR}/helm/ray"
local RAY_DIR="${NEW_RELEASE_DIR}/helm/ray/chart"
local RAY_VALUES_PATH="${RAY_DIR}/values-generated.yaml"
if [ ! -e "$RAY_DIR/values-generated.yaml.bak" ]; then
echo "it is the first time ray-cluster is being updated for version $NEW_VERSION"
Expand All @@ -91,7 +91,7 @@ replace_versions_in_values_yaml() {
}

helm_upgrade() {
local RAY_CHARTS_DIR="${NEW_RELEASE_DIR}/helm/ray"
local RAY_CHARTS_DIR="${NEW_RELEASE_DIR}/helm/ray/chart"
local RAY_VALUES_YAML="${RAY_CHARTS_DIR}/values-generated.yaml"
helm --kubeconfig $KUBECONFIG upgrade ray-cluster $RAY_CHARTS_DIR --values $RAY_VALUES_YAML --namespace syntho --wait --timeout 10m

Expand Down
15 changes: 13 additions & 2 deletions cli/cli/syntho_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
from importlib import metadata
from pathlib import Path
from typing import Optional

import click
Expand All @@ -13,6 +14,7 @@
from cli.utilities import offline_ops as offline_ops_manager
from cli.utilities import prepull_images as prepull_images_manager

home = Path.home()
syntho_cli_dir = os.path.dirname(os.path.abspath(__file__))
scripts_dir = os.path.join(syntho_cli_dir, "scripts")

Expand Down Expand Up @@ -241,20 +243,28 @@ def list_releases():


@k8s.command(name="deployment", help="Deploys the Syntho Stack into the given cluster")
@click.option("--license-key", type=str, help="Specify the License Key that is provided by Syntho team", required=True)
@click.option(
"--license-key",
type=str,
help="Specify the License Key that is provided by Syntho team",
required=True,
envvar="LICENSE_KEY",
)
@click.option(
"--registry-user",
type=str,
help="Specify the docker image registry user that is provided by Syntho team",
required=False,
default="u",
envvar="REGISTRY_USER",
)
@click.option(
"--registry-pwd",
type=str,
help="Specify the docker image registry password that is provided by Syntho team",
required=False,
default="p",
envvar="REGISTRY_PWD",
)
@click.option(
"--kubeconfig",
Expand All @@ -264,7 +274,8 @@ def list_releases():
" stack will be deployed into. It can be both kubeconfig content, or a file path that"
" points to a valid kubconfig content file"
),
required=True,
required=False,
default=f"{home}/.kube/config",
callback=validate_kubeconfig,
)
@click.option("--version", type=str, help=("Specify a version for Syntho stack."), required=True)
Expand Down
25 changes: 20 additions & 5 deletions cli/tests/test_syntho_cli_k8s.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
from unittest import TestCase, mock

import yaml
Expand Down Expand Up @@ -195,6 +196,13 @@ class TestK8sStartDeploymentValidationErrors(TestCase):
def setUp(self):
self.runner = CliRunner()

self.expected_output_incorrect_kubeconfig = """
Usage: deployment [OPTIONS]
Try 'deployment --help' for help.
Error: Invalid value for '--kubeconfig': KUBECONFIG is neither a valid YAML string nor a path to a valid YAML file: {home}/.kube/config
""" # noqa: E501

self.expected_output_template_for_missing_param = """
Usage: deployment [OPTIONS]
Try 'deployment --help' for help.
Expand Down Expand Up @@ -249,6 +257,11 @@ def assert_missing_param(self, result, missing):
result.output.strip(), self.expected_output_template_for_missing_param.format(missing=missing).strip()
)

def assert_missing_kubeconfig(self, result, home):
self.assertEqual(result.exit_code, 2)
self.assertEqual(result.output.strip(), self.expected_output_incorrect_kubeconfig.format(home=home).strip())

# TODO: Remove test as default for kubeconfig has been setup (home/<user>/.kube/config)
def test_deployment_without_kubeconfig(self):
result = self.runner.invoke(
syntho_cli.k8s_deployment,
Expand All @@ -259,12 +272,14 @@ def test_deployment_without_kubeconfig(self):
"syntho-user",
"--registry-pwd",
"syntho-pwd",
"--version",
"1.0.0",
],
)

self.assert_missing_param(result, "kubeconfig")
home_folder = Path.home()
kubeconfig = Path(f"{home_folder}/.kube/config")
if kubeconfig.is_file():
self.assert_missing_param(result, "version")
else:
self.assert_missing_kubeconfig(result, home_folder)

def test_deployment_without_license_key(self):
result = self.runner.invoke(
Expand Down Expand Up @@ -297,7 +312,7 @@ def test_deployment_without_version(self):
self.sample_kubeconfig_content,
],
)

print(result.output)
self.assert_missing_param(result, "version")

def test_deployment_without_registry_user(self):
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ BACKEND_DATA_ACCESS=True
CORE_APP_ENV=prod

POSTGRES_IMAGE=postgres:14.5
REDIS_IMAGE=redis:6.2-alpine
REDIS_IMAGE=redis:7.2-rc2
2 changes: 1 addition & 1 deletion helm/config/images.env.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IMAGE_REGISTRY_SERVER=syntho.azurecr.io
RAY_OPERATOR_IMG_REPO=syntho.azurecr.io/syntho-ray-operator
RAY_OPERATOR_IMG_REPO=syntho.azurecr.io/kuberay-operator
RAY_OPERATOR_IMG_TAG=latest
RAY_IMAGE_IMG_REPO=syntho.azurecr.io/syntho-ray
RAY_IMAGE_IMG_TAG={{ SYNTHO_STACK_VERSION }}-cpu
Expand Down
22 changes: 0 additions & 22 deletions helm/ray/.helmignore

This file was deleted.

118 changes: 3 additions & 115 deletions helm/ray/README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,117 +1,5 @@
# KubeRay Operator
# Ray Helm chart and CRDs

This document provides instructions to install both CRDs (RayCluster, RayJob, RayService) and KubeRay operator with a Helm chart.
This folder contains the Ray Helm chart necessary for the deployment of the Syntho application, under `chart/` and a separate folder for the necessary CRDs, under `crds/`.

## Helm

Make sure 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.

```sh
helm version
```

## Install CRDs and KubeRay operator

* Install a stable version via Helm repository (only supports KubeRay v0.4.0+)
```sh
helm repo add kuberay https://ray-project.github.io/kuberay-helm/

# Install both CRDs and KubeRay operator v0.4.0.
helm install kuberay-operator kuberay/kuberay-operator --version 0.4.0

# Check the KubeRay operator Pod in `default` namespace
kubectl get pods
# NAME READY STATUS RESTARTS AGE
# kuberay-operator-6fcbb94f64-mbfnr 1/1 Running 0 17s
```

* Install the nightly version
```sh
# Step1: Clone KubeRay repository

# Step2: Move to `helm-chart/kuberay-operator`

# Step3: Install KubeRay operator
helm install kuberay-operator .
```

* Install KubeRay operator without installing CRDs
* In some cases, the installation of the CRDs and the installation of the operator may require different levels of admin permissions, so these two installations could be handled as different steps by different roles.
* Use Helm's built-in `--skip-crds` flag to install the operator only. See [this document](https://helm.sh/docs/chart_best_practices/custom_resource_definitions/) for more details.
```sh
# Step 1: Install CRDs only (for cluster admin)
kubectl create -k "github.com/ray-project/kuberay/manifests/cluster-scope-resources?ref=v0.4.0&timeout=90s"

# Step 2: Install KubeRay operator only. (for developer)
helm install kuberay-operator kuberay/kuberay-operator --version 0.4.0 --skip-crds
```

## List the chart

To list the `my-release` deployment:

```sh
helm ls
# NAME NAMESPACE REVISION UPDATED STATUS CHART # APP VERSION
# kuberay-operator default 1 2022-12-02 02:13:37.514445313 +0000 UTC deployed kuberay-operator-0.4.0 1.0
```

## Uninstall the Chart

```sh
# Uninstall the `kuberay-operator` release
helm uninstall kuberay-operator

# The operator Pod should be removed.
kubectl get pods
# No resources found in default namespace.
```

## Working with Argo CD

If you are using [Argo CD](https://argoproj.github.io) to manage the operator, you will encounter the issue which complains the CRDs too long. Same with [this issue](https://github.com/prometheus-operator/prometheus-operator/issues/4439).
The recommended solution is to split the operator into two Argo apps, such as:

* The first app just for installing the CRDs with `Replace=true` directly, snippet:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ray-operator-crds
spec:
project: default
source:
repoURL: https://github.com/ray-project/kuberay
targetRevision: v0.4.0
path: helm-chart/kuberay-operator/crds
destination:
server: https://kubernetes.default.svc
syncPolicy:
syncOptions:
- Replace=true
...
```

* The second app that installs the Helm chart with `skipCrds=true` (new feature in Argo CD 2.3.0), snippet:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ray-operator
spec:
source:
repoURL: https://github.com/ray-project/kuberay
targetRevision: v0.4.0
path: helm-chart/kuberay-operator
helm:
skipCrds: true
destination:
server: https://kubernetes.default.svc
namespace: ray-operator
syncPolicy:
syncOptions:
- CreateNamespace=true
...
```
Check the README in the `charts/` folder for more information.
9 changes: 9 additions & 0 deletions helm/ray/chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: kuberay-operator
repository: https://ray-project.github.io/kuberay-helm/
version: 1.2.2
- name: ray-cluster
repository: https://ray-project.github.io/kuberay-helm/
version: 1.2.2
digest: sha256:c5873ef78fcfdcbba500c18b01e270caff261783e6ee61e7f4be9181db0a42ce
generated: "2024-12-05T15:56:36.670714398+01:00"
16 changes: 9 additions & 7 deletions helm/ray/Chart.yaml → helm/ray/chart/Chart.yaml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
apiVersion: v2
description: A Helm chart for Kubernetes ray operator and cluster
name: ray-cluster
version: 1.13.0
name: ray
version: 1.14.0
icon: https://github.com/ray-project/ray/raw/master/doc/source/images/ray_header_logo.png
type: application
maintainers:
- name: Syntho B.V.
email: [email protected]
- name: Younes Moustaghfir
email: [email protected]
dependencies:
- name: kuberay-operator
version: "1.2.2"
repository: "@kuberay"
- name: ray-cluster
version: "1.2.2"
repository: "@kuberay"
11 changes: 11 additions & 0 deletions helm/ray/chart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ray Helm chart

A Helm chart containing dependency charts of [Kuberay Operator](https://github.com/ray-project/kuberay/blob/master/helm-chart/kuberay-operator/README.md) and [RayCluster](https://github.com/ray-project/kuberay/blob/master/helm-chart/ray-cluster/README.md).

## Requirements

- Helm v3+

## Getting started

Please see the [Syntho Deployment Documentation](https://docs.syntho.ai/deploy-syntho/deploy-syntho-using-kubernetes/deploy-ray-using-helm) on how to deploy the application using this Helm chart.
Binary file added helm/ray/chart/charts/kuberay-operator-1.2.2.tgz
Binary file not shown.
Binary file added helm/ray/chart/charts/ray-cluster-1.2.2.tgz
Binary file not shown.
File renamed without changes.
Loading

0 comments on commit 614665d

Please sign in to comment.