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

Initialize Internal APIs for components #1304

Open
wants to merge 35 commits into
base: feature-operator-refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a717823
Initialize Component APIs
VaishnaviHire Oct 7, 2024
157e0f3
Add spec for Dashboard API
VaishnaviHire Oct 9, 2024
590777d
Add Dashboard Controller
VaishnaviHire Oct 14, 2024
c88a428
Add status sub resource to component's APIs
lburgazzoli Oct 14, 2024
cfb2297
Add component CRDs as internal objects
VaishnaviHire Oct 14, 2024
487dbe8
shared reconciler
lburgazzoli Oct 14, 2024
a812a26
Update DataScienceCLuster controller to only deploy Dashboard
VaishnaviHire Oct 15, 2024
b438f3a
Update implementation of base reconciler
VaishnaviHire Oct 15, 2024
a54e58b
feat: create odh client
lburgazzoli Oct 15, 2024
dc67181
feat: rename BaseReconciler to ComponentReconciler
lburgazzoli Oct 15, 2024
ba56369
feat: add common status update action
lburgazzoli Oct 15, 2024
aa0ea69
feat: improve common conditions
lburgazzoli Oct 15, 2024
a364358
feat: add basic test for delete resource action
lburgazzoli Oct 15, 2024
0f2ad33
feat: add basic status management
lburgazzoli Oct 15, 2024
645ccf6
feat: add basic test for update status action
lburgazzoli Oct 15, 2024
102881e
feat: move common code to pkg/controller to avoid circular dependecies
lburgazzoli Oct 15, 2024
23da2f9
feat: copy DSCDashboard from DataScienceCluster
lburgazzoli Oct 15, 2024
0eedf2c
feat: add components.opendatahub.io/name label
lburgazzoli Oct 15, 2024
2c5901c
Add TODO and refactor component reconciler
VaishnaviHire Oct 15, 2024
c00dcce
Fix linters
VaishnaviHire Oct 16, 2024
2b4880c
Remove e2e tests that are not needed
VaishnaviHire Oct 16, 2024
d0fe61f
Makefile, webhook: add run-nowebhook (#1286)
ykaliuta Oct 10, 2024
bef2ef9
fix status apply
lburgazzoli Oct 17, 2024
03fbbd4
feat: add print columns and validation to components.opendatahub.io/v…
lburgazzoli Oct 17, 2024
d3c1ccc
Fix linter issues
VaishnaviHire Oct 17, 2024
5fea836
Update imports for status_update
VaishnaviHire Oct 17, 2024
52d8e4a
Add e2e tests
VaishnaviHire Oct 17, 2024
e9f8d67
Add dedicated packages for component controllers
VaishnaviHire Oct 17, 2024
59edbbf
Fix linting errors
VaishnaviHire Oct 17, 2024
04e1ccd
Delete component CRs on Removed
VaishnaviHire Oct 18, 2024
8baa3e5
Add managementState annotation
VaishnaviHire Oct 18, 2024
5016936
component(dashboard): initialize images at startup, remove devflags l…
lburgazzoli Oct 18, 2024
d852aac
feat(dashboard): configure watched resources event filter
lburgazzoli Oct 17, 2024
af2c1b3
Update predicate for create event
VaishnaviHire Oct 18, 2024
19d4c28
Fix: Update manifests map in initialization
VaishnaviHire Oct 18, 2024
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
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,16 @@ api-docs: crd-ref-docs ## Creates API docs using https://github.com/elastic/crd-
build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go

RUN_ARGS = --log-mode=devel
GO_RUN_MAIN = OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) DEFAULT_MANIFESTS_PATH=$(DEFAULT_MANIFESTS_PATH) go run $(GO_RUN_ARGS) ./main.go $(RUN_ARGS)
.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) DEFAULT_MANIFESTS_PATH=${DEFAULT_MANIFESTS_PATH} go run ./main.go --log-mode=devel
$(GO_RUN_MAIN)

.PHONY: run-nowebhook
run-nowebhook: GO_RUN_ARGS += -tags nowebhook
run-nowebhook: manifests generate fmt vet ## Run a controller from your host without webhook enabled
$(GO_RUN_MAIN)
grdryn marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: image-build
image-build: # unit-test ## Build image with the manager.
Expand Down
110 changes: 110 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,114 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: Dashboard
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
zdtsw marked this conversation as resolved.
Show resolved Hide resolved
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: Workbenches
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: ModelMeshServing
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: DataSciencePipelines
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: Kserve
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kind: Kserve
kind: KServe

I guess this might be slightly preferred? I don't know what the implications of one over the other are though.

path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: Kueue
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: CodeFlare
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: Ray
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: TrustyAI
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: ModelRegistry
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
- api:
crdVersion: v1
controller: true
domain: opendatahub.io
group: components
kind: TrainingOperator
path: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1
version: v1
webhooks:
validation: false
version: "3"
68 changes: 68 additions & 0 deletions apis/components/component.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// +groupName=datasciencecluster.opendatahub.io
grdryn marked this conversation as resolved.
Show resolved Hide resolved
package components

import (
operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Component struct defines the basis for each OpenDataHub component configuration.
// +kubebuilder:object:generate=true
type Component struct {
// Set to one of the following values:
//
// - "Managed" : the operator is actively managing the component and trying to keep it active.
// It will only upgrade the component if it is safe to do so
//
// - "Removed" : the operator is actively managing the component and will not install it,
// or if it is installed, the operator will try to remove it
//
// +kubebuilder:validation:Enum=Managed;Removed
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
// Add any other common fields across components below

// Add developer fields
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=2
DevFlags *DevFlags `json:"devFlags,omitempty"`
}

// DevFlags defines list of fields that can be used by developers to test customizations. This is not recommended
// to be used in production environment.
// +kubebuilder:object:generate=true
type DevFlags struct {
// List of custom manifests for the given component
// +optional
Manifests []ManifestsConfig `json:"manifests,omitempty"`
}

type ManifestsConfig struct {
// uri is the URI point to a git repo with tag/branch. e.g. https://github.com/org/repo/tarball/<tag/branch>
// +optional
// +kubebuilder:default:=""
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=1
URI string `json:"uri,omitempty"`

// contextDir is the relative path to the folder containing manifests in a repository, default value "manifests"
// +optional
// +kubebuilder:default:="manifests"
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=2
ContextDir string `json:"contextDir,omitempty"`

// sourcePath is the subpath within contextDir where kustomize builds start. Examples include any sub-folder or path: `base`, `overlays/dev`, `default`, `odh` etc.
// +optional
// +kubebuilder:default:=""
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=3
SourcePath string `json:"sourcePath,omitempty"`
}

// +kubebuilder:object:generate=true
type Status struct {
Phase string `json:"phase"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

type WithStatus interface {
GetStatus() *Status
}
69 changes: 69 additions & 0 deletions apis/components/v1/codeflare_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
"github.com/opendatahub-io/opendatahub-operator/v2/apis/components"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// CodeFlareSpec defines the desired state of CodeFlare
type CodeFlareSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of CodeFlare. Edit codeflare_types.go to remove/update
Foo string `json:"foo,omitempty"`
}

// CodeFlareStatus defines the observed state of CodeFlare
type CodeFlareStatus struct {
components.Status `json:",inline"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster

// CodeFlare is the Schema for the codeflares API
type CodeFlare struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CodeFlareSpec `json:"spec,omitempty"`
Status CodeFlareStatus `json:"status,omitempty"`
}

func (c *CodeFlare) GetStatus() *components.Status {
return &c.Status.Status
}

// +kubebuilder:object:root=true

// CodeFlareList contains a list of CodeFlare
type CodeFlareList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CodeFlare `json:"items"`
}

func init() {
SchemeBuilder.Register(&CodeFlare{}, &CodeFlareList{})
}
78 changes: 78 additions & 0 deletions apis/components/v1/dashboard_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
"github.com/opendatahub-io/opendatahub-operator/v2/apis/components"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
DashboardInstanceName = "default-dashboard"
)

// DashboardSpec defines the desired state of Dashboard
type DashboardSpec struct {
// dashboard spec exposed to DSC api
DSCDashboard `json:""`
// dashboard spec exposed only to internal api
}

// DashboardStatus defines the observed state of Dashboard
type DashboardStatus struct {
components.Status `json:",inline"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default-dashboard'",message="Dashboard name must be default-dashboard"
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`,description="Ready"
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`,description="Reason"

// Dashboard is the Schema for the dashboards API
type Dashboard struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec DashboardSpec `json:"spec,omitempty"`
Status DashboardStatus `json:"status,omitempty"`
}

func (c *Dashboard) GetStatus() *components.Status {
return &c.Status.Status
}

// +kubebuilder:object:root=true

// DashboardList contains a list of Dashboard
type DashboardList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Dashboard `json:"items"`
}

func init() {
SchemeBuilder.Register(&Dashboard{}, &DashboardList{})
}

// DSCDashboard contains all the configuration exposed in DSC instance for Dashboard component
type DSCDashboard struct {
// configuration fields common across components
components.Component `json:""`
// configuration fields specific to the dashboard component
}
Loading