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

fix: workbench deployment + change path for its manifests in build #343

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
77 changes: 31 additions & 46 deletions components/workbenches/workbenches.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (
var (
ComponentName = "workbenches"
DependentComponentName = "notebooks"
// manifests for nbc in ODH and downstream + downstream use it for imageparams.
// manifests for nbc in ODH and RHOAI + downstream use it for imageparams.
notebookControllerPath = deploy.DefaultManifestPath + "/odh-notebook-controller/odh-notebook-controller/base"
// manifests for ODH nbc + downstream use it for imageparams.
kfnotebookControllerPath = deploy.DefaultManifestPath + "/odh-notebook-controller/kf-notebook-controller/overlays/openshift"
notebookImagesPath = deploy.DefaultManifestPath + "/notebooks/overlays/additional"
notebookImagesPathSupported = deploy.DefaultManifestPath + "/jupyterhub/notebooks/base"
kfnotebookControllerPath = deploy.DefaultManifestPath + "/odh-notebook-controller/kf-notebook-controller/overlays/openshift"
// notebook image manifests.
notebookImagesPath = deploy.DefaultManifestPath + "/notebooks/overlays/additional"
)

// Verifies that Workbench implements ComponentInterface.
Expand All @@ -43,26 +43,8 @@ type Workbenches struct {
func (w *Workbenches) OverrideManifests(ctx context.Context, platform cluster.Platform) error {
// Download manifests if defined by devflags
// Go through each manifest and set the overlays if defined
// first on odh-notebook-controller and kf-notebook-controller last to notebook-images
for _, subcomponent := range w.DevFlags.Manifests {
if strings.Contains(subcomponent.URI, DependentComponentName) {
// Download subcomponent
if err := deploy.DownloadManifests(ctx, DependentComponentName, subcomponent); err != nil {
return err
}
// If overlay is defined, update paths
defaultKustomizePath := "overlays/additional"
defaultKustomizePathSupported := "notebook-images/overlays/additional"
if subcomponent.SourcePath != "" {
defaultKustomizePath = subcomponent.SourcePath
defaultKustomizePathSupported = subcomponent.SourcePath
}
if platform == cluster.ManagedRhods || platform == cluster.SelfManagedRhods {
notebookImagesPathSupported = filepath.Join(deploy.DefaultManifestPath, "jupyterhub", defaultKustomizePathSupported)
} else {
notebookImagesPath = filepath.Join(deploy.DefaultManifestPath, DependentComponentName, defaultKustomizePath)
}
}

if strings.Contains(subcomponent.ContextDir, "components/odh-notebook-controller") {
// Download subcomponent
if err := deploy.DownloadManifests(ctx, "odh-notebook-controller/odh-notebook-controller", subcomponent); err != nil {
Expand All @@ -88,6 +70,18 @@ func (w *Workbenches) OverrideManifests(ctx context.Context, platform cluster.Pl
}
kfnotebookControllerPath = filepath.Join(deploy.DefaultManifestPath, "odh-notebook-controller/kf-notebook-controller", defaultKustomizePathKfNbc)
}
if strings.Contains(subcomponent.URI, DependentComponentName) {
// Download subcomponent
if err := deploy.DownloadManifests(ctx, DependentComponentName, subcomponent); err != nil {
return err
}
// If overlay is defined, update paths
defaultKustomizePath := "overlays/additional"
if subcomponent.SourcePath != "" {
defaultKustomizePath = subcomponent.SourcePath
}
notebookImagesPath = filepath.Join(deploy.DefaultManifestPath, DependentComponentName, defaultKustomizePath)
}
}
return nil
}
Expand All @@ -108,8 +102,6 @@ func (w *Workbenches) ReconcileComponent(ctx context.Context, cli client.Client,
// Create rhods-notebooks namespace in managed platforms
enabled := w.GetManagementState() == operatorv1.Managed
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed
// Set default notebooks namespace
// Create rhods-notebooks namespace in managed platforms
if enabled {
if w.DevFlags != nil {
// Download manifests and update paths
Expand All @@ -120,7 +112,7 @@ func (w *Workbenches) ReconcileComponent(ctx context.Context, cli client.Client,
if platform == cluster.SelfManagedRhods || platform == cluster.ManagedRhods {
// Intentionally leaving the ownership unset for this namespace.
// Specifying this label triggers its deletion when the operator is uninstalled.
_, err := cluster.CreateNamespace(ctx, cli, "rhods-notebooks", cluster.WithLabels(labels.ODH.OwnedNamespace, "true"))
_, err := cluster.CreateNamespace(ctx, cli, cluster.DefaultNotebooksNamespace, cluster.WithLabels(labels.ODH.OwnedNamespace, "true"))
if err != nil {
return err
}
Expand All @@ -131,10 +123,6 @@ func (w *Workbenches) ReconcileComponent(ctx context.Context, cli client.Client,
return err
}
}
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, notebookControllerPath, dscispec.ApplicationsNamespace, ComponentName, enabled); err != nil {
return fmt.Errorf("failed to apply manifetss %s: %w", notebookControllerPath, err)
}
l.WithValues("Path", notebookControllerPath).Info("apply manifests done NBC")

// Update image parameters for nbc
if enabled {
Expand All @@ -150,31 +138,28 @@ func (w *Workbenches) ReconcileComponent(ctx context.Context, cli client.Client,
}
}
if err := deploy.DeployManifestsFromPath(ctx, cli, owner,
kfnotebookControllerPath,
notebookControllerPath,
dscispec.ApplicationsNamespace,
ComponentName, enabled); err != nil {
return err
return fmt.Errorf("failed to apply manifetss %s: %w", notebookControllerPath, err)
}
var manifestsPath string
if platform == cluster.OpenDataHub || platform == "" {
// only for ODH after transit to kubeflow repo
if err := deploy.DeployManifestsFromPath(ctx, cli, owner,
kfnotebookControllerPath,
dscispec.ApplicationsNamespace,
ComponentName, enabled); err != nil {
return err
}
manifestsPath = notebookImagesPath
} else {
manifestsPath = notebookImagesPathSupported
l.WithValues("Path", notebookControllerPath).Info("apply manifests done notebook controller done")

if err := deploy.DeployManifestsFromPath(ctx, cli, owner,
kfnotebookControllerPath,
dscispec.ApplicationsNamespace,
ComponentName, enabled); err != nil {
return fmt.Errorf("failed to apply manifetss %s: %w", kfnotebookControllerPath, err)
}
l.WithValues("Path", kfnotebookControllerPath).Info("apply manifests done kf-notebook controller done")

if err := deploy.DeployManifestsFromPath(ctx, cli, owner,
manifestsPath,
notebookImagesPath,
dscispec.ApplicationsNamespace,
ComponentName, enabled); err != nil {
return err
}
l.WithValues("Path", manifestsPath).Info("apply manifests done notebook image")
l.WithValues("Path", notebookImagesPath).Info("apply manifests done notebook image done")

// Wait for deployment available
if enabled {
Expand Down
26 changes: 13 additions & 13 deletions get_all_manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ MANIFEST_ORG="red-hat-data-services"
# component: notebook, dsp, kserve, dashbaord, cf/ray/kueue/trainingoperator, trustyai, modelmesh.
# in the format of "repo-org:repo-name:ref-name:source-folder:target-folder".
declare -A COMPONENT_MANIFESTS=(
["codeflare"]="red-hat-data-services:codeflare-operator:rhoai-2.12:config:codeflare"
["ray"]="red-hat-data-services:kuberay:rhoai-2.12:ray-operator/config:ray"
["kueue"]="red-hat-data-services:kueue:rhoai-2.12:config:kueue"
["data-science-pipelines-operator"]="red-hat-data-services:data-science-pipelines-operator:rhoai-2.12:config:data-science-pipelines-operator"
["kf-notebook-controller"]="red-hat-data-services:kubeflow:rhoai-2.12:components/notebook-controller/config:odh-notebook-controller/kf-notebook-controller"
["odh-notebook-controller"]="red-hat-data-services:kubeflow:rhoai-2.12:components/odh-notebook-controller/config:odh-notebook-controller/odh-notebook-controller"
["notebooks"]="red-hat-data-services:notebooks:rhoai-2.12:manifests:/jupyterhub/notebooks"
["trustyai"]="red-hat-data-services:trustyai-service-operator:rhoai-2.12:config:trustyai-service-operator"
["model-mesh"]="red-hat-data-services:modelmesh-serving:rhoai-2.12:config:model-mesh"
["odh-model-controller"]="red-hat-data-services:odh-model-controller:rhoai-2.12:config:odh-model-controller"
["kserve"]="red-hat-data-services:kserve:rhoai-2.12:config:kserve"
["odh-dashboard"]="red-hat-data-services:odh-dashboard:rhoai-2.12:manifests:dashboard"
["trainingoperator"]="red-hat-data-services:training-operator:rhoai-2.12:manifests:trainingoperator"
["codeflare"]="red-hat-data-services:codeflare-operator:rhoai-2.13:config:codeflare"
["ray"]="red-hat-data-services:kuberay:rhoai-2.13:ray-operator/config:ray"
["kueue"]="red-hat-data-services:kueue:rhoai-2.13:config:kueue"
["data-science-pipelines-operator"]="red-hat-data-services:data-science-pipelines-operator:rhoai-2.13:config:data-science-pipelines-operator"
["kf-notebook-controller"]="red-hat-data-services:kubeflow:rhoai-2.13:components/notebook-controller/config:odh-notebook-controller/kf-notebook-controller"
["odh-notebook-controller"]="red-hat-data-services:kubeflow:rhoai-2.13:components/odh-notebook-controller/config:odh-notebook-controller/odh-notebook-controller"
["notebooks"]="red-hat-data-services:notebooks:rhoai-2.13:manifests:notebooks"
["trustyai"]="red-hat-data-services:trustyai-service-operator:rhoai-2.13:config:trustyai-service-operator"
["model-mesh"]="red-hat-data-services:modelmesh-serving:rhoai-2.13:config:model-mesh"
["odh-model-controller"]="red-hat-data-services:odh-model-controller:rhoai-2.13:config:odh-model-controller"
["kserve"]="red-hat-data-services:kserve:rhoai-2.13:config:kserve"
["odh-dashboard"]="red-hat-data-services:odh-dashboard:rhoai-2.13:manifests:dashboard"
["trainingoperator"]="red-hat-data-services:training-operator:rhoai-2.13:manifests:trainingoperator"
)

# Allow overwriting repo using flags component=repo
Expand Down
3 changes: 3 additions & 0 deletions pkg/cluster/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ const (
OpenDataHub Platform = "Open Data Hub"
// Unknown indicates that operator is not deployed using OLM.
Unknown Platform = ""

// DefaultNotebooksNamespace defines default namespace for notebooks.
DefaultNotebooksNamespace = "rhods-notebooks"
)
Loading