diff --git a/docs/addons/index.md b/docs/addons/index.md index 728246567..0a90087d9 100644 --- a/docs/addons/index.md +++ b/docs/addons/index.md @@ -54,6 +54,7 @@ The framework currently supports the following add-ons. | [`KonveyorAddOn`](https://github.com/claranet-ch/konveyor-eks-blueprint-addon) | Adds [Konveyor](https://www.konveyor.io/) to the EKS Cluster. | ✅ | ✅ | | [`KubecostAddOn`](./kubecost.md) | Adds [Kubecost](https://kubecost.com) cost analyzer to the EKS cluster. | ✅ | | [`KubeflowAddOn`](./kubeflow.md) | Adds [kubeflow](https://awslabs.github.io/kubeflow-manifests/) Kubeflow pipeline addon the EKS cluster. | ✅ | +| [`KubeRayAddOn`](./kuberay-operator.md) | Installs the [KubeRay Operator](https://docs.ray.io/en/latest/cluster/kubernetes/index.html). | ✅ | ✅ | | [`KubeviousAddOn`](./kubevious.md) | Adds [Kubevious](https://github.com/kubevious/kubevious) open source Kubernetes dashboard to an EKS cluster. | ✅ | | [`KarpenterAddOn`](./karpenter.md) | Adds [Karpenter](https://github.com/awslabs/karpenter) support for Amazon EKS. | ✅ | ✅ | | [`KubeProxyAddOn`](./kube-proxy.md) | Adds kube-proxy Amazon EKS add-on. Kube-proxy maintains network rules on each Amazon EC2 node. | ✅ | ✅ | diff --git a/docs/addons/kuberay-operator.md b/docs/addons/kuberay-operator.md new file mode 100644 index 000000000..954d2a1b6 --- /dev/null +++ b/docs/addons/kuberay-operator.md @@ -0,0 +1,51 @@ +# KubeRay Operator Add-on + +[Ray](https://github.com/ray-project/ray) is a framework for scaling AI applications written in Python. Ray consists of a core distributed runtime and a set of AI libraries for simplifying ML compute. Ray allows scaling applications from a laptop to a cluster. + +KubeRay is a Kubernetes Operator that simplifies the deployment and management of Ray applications on Kubernetes. It is made of the following components: + +- KubeRay core, the official, fully-maintained component of KubeRay that provides three custom resource definitions, RayCluster, RayJob, and RayService +- Community-managed components (optional): KubeRay APIServer, KubeRay Python client and KubeRay CLI + +Please refer to [KubeRay Operator documentation](https://docs.ray.io/en/latest/cluster/kubernetes/index.html) for detailed information. + +This add-on installs the KubeRay Operator [Helm chart](https://github.com/ray-project/kuberay/blob/master/helm-chart/kuberay-operator/README.md). + +## Usage + +```typescript +import { Construct } from 'constructs'; +import * as blueprints from '@aws-quickstart/eks-blueprints'; + +export class KubeRayConstruct extends Construct { + constructor(scope: Construct, id: string) { + super(scope, id); + + const stackID = `${id}-blueprint`; + + const addOn = new blueprints.addons.KubeRayAddOn(); + + blueprints.EksBlueprint.builder() + .account(process.env.CDK_DEFAULT_ACCOUNT!) + .region(process.env.CDK_DEFAULT_REGION!) + .version('auto') + .addOns(addOn) + .build(scope, stackID); + } +} +``` + +## Validation + +To validate the KubeRay Operator installation, please run the following command: + +```bash +kubectl get pods +``` + +Expected output: + +```bash +NAME READY STATUS RESTARTS AGE +kuberay-operator-58c98b495b-5k75l 1/1 Running 0 112m +``` diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index 47834a933..529134482 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -55,6 +55,7 @@ export default class BlueprintConstruct { }); const addOns: Array = [ + new blueprints.KubeRayAddOn(), new blueprints.addons.AwsLoadBalancerControllerAddOn(), new blueprints.addons.AppMeshAddOn(), new blueprints.addons.CertManagerAddOn(), diff --git a/lib/addons/index.ts b/lib/addons/index.ts index 3c48503f6..e017ba79b 100644 --- a/lib/addons/index.ts +++ b/lib/addons/index.ts @@ -29,6 +29,7 @@ export * from './helm-addon'; export * from './karpenter'; export * from './kube-proxy'; export * from './kube-state-metrics'; +export * from './kuberay'; export * from './metrics-server'; export * from './nested-stack'; export * from './nginx'; diff --git a/lib/addons/kuberay/index.ts b/lib/addons/kuberay/index.ts new file mode 100644 index 000000000..cd0d2d751 --- /dev/null +++ b/lib/addons/kuberay/index.ts @@ -0,0 +1,55 @@ +import { Construct } from 'constructs'; +import merge from "ts-deepmerge"; +import { ClusterInfo, Values } from "../../spi"; +import { createNamespace } from "../../utils"; +import { HelmAddOn, HelmAddOnProps, HelmAddOnUserProps } from "../helm-addon"; + +/** + * User provided options for the Helm Chart + */ +export interface KubeRayAddOnProps extends HelmAddOnUserProps { + /** + * To Create Namespace using CDK + */ + createNamespace?: boolean; +} + +/** + * Default props to be used when creating the Helm chart + */ +const defaultProps: HelmAddOnProps & KubeRayAddOnProps = { + name: "kuberay-operator", + chart: "kuberay-operator", + namespace: "default", + version: "1.0.0", + release: "kuberay-operator", + repository: "https://ray-project.github.io/kuberay-helm", + values: {}, + createNamespace: true +}; + +/** + * Main class to instantiate the Helm chart + */ +export class KubeRayAddOn extends HelmAddOn { + + readonly options: KubeRayAddOnProps; + constructor(props?: KubeRayAddOnProps) { + super({...defaultProps, ...props}); + this.options = this.props as KubeRayAddOnProps; + } + + deploy(clusterInfo: ClusterInfo): Promise { + const cluster = clusterInfo.cluster; + let values: Values = this.options.values ?? {}; + values = merge(values, this.props.values ?? {}); + + const chart = this.addHelmChart(clusterInfo, values); + + if( this.options.createNamespace == true){ + const namespace = createNamespace(this.options.namespace! , cluster); + chart.node.addDependency(namespace); + } + return Promise.resolve(chart); + } +} diff --git a/mkdocs.yml b/mkdocs.yml index 1bfbdaa4b..3deefddd0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -67,6 +67,7 @@ nav: - Kube Proxy: 'addons/kube-proxy.md' - Kubecost: 'addons/kubecost.md' - Kubeflow: 'addons/kubeflow.md' + - KubeRay Operator: 'addons/kuberay-operator.md' - Kubevious: 'addons/kubevious.md' - Kube State Metrics: 'addons/kube-state-metrics.md' - Metrics Server: 'addons/metrics-server.md'