-
Notifications
You must be signed in to change notification settings - Fork 139
/
ray.go
89 lines (74 loc) · 2.56 KB
/
ray.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Package ray provides utility functions to config Ray as part of the stack which makes managing distributed compute infrastructure in the cloud easy and intuitive for Data Scientists
package ray
import (
dsci "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"path/filepath"
"sigs.k8s.io/controller-runtime/pkg/client"
)
var (
ComponentName = "ray"
RayPath = deploy.DefaultManifestPath + "/" + "ray/operator/base"
)
var imageParamMap = map[string]string{
"odh-kuberay-operator-controller-image": "RELATED_IMAGE_ODH_KUBERAY_OPERATOR_CONTROLLER_IMAGE",
}
type Ray struct {
components.Component `json:""`
}
func (r *Ray) OverrideManifests(_ string) error {
// If devflags are set, update default manifests path
if len(r.DevFlags.Manifests) != 0 {
manifestConfig := r.DevFlags.Manifests[0]
if err := deploy.DownloadManifests(ComponentName, manifestConfig); err != nil {
return err
}
// If overlay is defined, update paths
defaultKustomizePath := "operator/base"
if manifestConfig.SourcePath != "" {
defaultKustomizePath = manifestConfig.SourcePath
}
RayPath = filepath.Join(deploy.DefaultManifestPath, ComponentName, defaultKustomizePath)
}
return nil
}
func (r *Ray) GetComponentDevFlags() components.DevFlags {
return r.DevFlags
}
func (r *Ray) SetImageParamsMap(imageMap map[string]string) map[string]string {
imageParamMap = imageMap
return imageParamMap
}
func (r *Ray) GetComponentName() string {
return ComponentName
}
// Verifies that Ray implements ComponentInterface
var _ components.ComponentInterface = (*Ray)(nil)
func (r *Ray) ReconcileComponent(cli client.Client, owner metav1.Object, dscispec *dsci.DSCInitializationSpec) error {
enabled := r.GetManagementState() == operatorv1.Managed
platform, err := deploy.GetPlatform(cli)
if err != nil {
return err
}
if enabled {
// Download manifests and update paths
if err = r.OverrideManifests(string(platform)); err != nil {
return err
}
if dscispec.DevFlags.ManifestsUri == "" {
if err := deploy.ApplyImageParams(RayPath, imageParamMap); err != nil {
return err
}
}
}
// Deploy Ray Operator
err = deploy.DeployManifestsFromPath(cli, owner, RayPath, dscispec.ApplicationsNamespace, r.GetComponentName(), enabled)
return err
}
func (r *Ray) DeepCopyInto(target *Ray) {
*target = *r
target.Component = r.Component
}