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

Implement model registry inference service reconciliation #135

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
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ vet: ## Run go vet against code.

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" POD_NAMESPACE=default go test ./... -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" POD_NAMESPACE=default go test ./controllers/... -coverprofile cover.out

.PHONY: e2e-test
e2e-test: manifests generate fmt vet ## Run e2e-tests.
POD_NAMESPACE=default go test ./test/e2e/...
lampajr marked this conversation as resolved.
Show resolved Hide resolved

##@ Build

Expand Down Expand Up @@ -109,6 +113,15 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy-dev
deploy-dev: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/overlays/dev | kubectl apply -f -

.PHONY: undeploy-dev
undeploy-dev: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/overlays/dev | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

##@ Build Dependencies

## Location to install dependencies to
Expand Down
7 changes: 7 additions & 0 deletions config/crd/external/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
resources:
- serving.kserve.io_inferenceservices.yaml
- serving.kserve.io_servingruntimes.yaml
- route.openshift.io_routes.yaml
- monitoring.coreos.com_podmonitors.yaml
- monitoring.coreos.com_servicemonitors.yaml
- maistra.io_servicemeshmemberrolls.yaml
- maistra.io_servicemeshmembers.yaml
- telemetry.istio.io_telemetries.yaml
# - route.openshift.io_routes.yaml #minikube
31 changes: 29 additions & 2 deletions config/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
resources:
- ../../crd/external
- ../../manager/namespace.yaml
- ../../crd/external
- ../../default

patchesStrategicMerge:
- odh_model_controller_manager_patch.yaml

namespace: default
configMapGenerator:
- envs:
- params.env
name: odh-model-controller-parameters
generatorOptions:
disableNameSuffixHash: true

vars:
- fieldref:
fieldPath: metadata.namespace
name: mesh-namespace
objref:
apiVersion: v1
kind: ConfigMap
name: odh-model-controller-parameters
- fieldref:
fieldPath: data.monitoring-namespace
name: monitoring-namespace
objref:
apiVersion: v1
kind: ConfigMap
name: odh-model-controller-parameters
19 changes: 19 additions & 0 deletions config/overlays/dev/odh_model_controller_manager_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: odh-model-controller
spec:
replicas: 3
template:
spec:
containers:
- args:
- --leader-elect
- --model-registry-inference-reconcile
- "--monitoring-namespace"
- "$(MONITORING_NS)"
env:
- name: MONITORING_NS
value: $(monitoring-namespace)
name: manager
imagePullPolicy: IfNotPresent
2 changes: 2 additions & 0 deletions config/overlays/dev/params.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
monitoring-namespace=default
metadata.namespace=default
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ rules:
verbs:
- get
- list
- update
Copy link
Member

Choose a reason for hiding this comment

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

hmm, which rbac needs to be updated?

I am not about operators updating rbac. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reconcile loop has to update InferenceService CRs, adding some ad-hoc labels to keep the links between the CR and the record in model registry - that's why I had to add that update. Is there any other way I can do that?

- watch
- apiGroups:
- serving.kserve.io
Expand Down
34 changes: 34 additions & 0 deletions controllers/comparators/inferenceservice_comparator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*

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 comparators

import (
"reflect"

kservev1beta1 "github.com/kserve/kserve/pkg/apis/serving/v1beta1"
"github.com/opendatahub-io/odh-model-controller/controllers/constants"
"sigs.k8s.io/controller-runtime/pkg/client"
)

func GetInferenceServiceComparator() ResourceComparator {
return func(deployed client.Object, requested client.Object) bool {
deployedInferenceService := deployed.(*kservev1beta1.InferenceService)
requestedInferenceService := requested.(*kservev1beta1.InferenceService)
return reflect.DeepEqual(deployedInferenceService.Labels[constants.ModelRegistryInferenceServiceIdLabel], requestedInferenceService.Labels[constants.ModelRegistryInferenceServiceIdLabel]) &&
reflect.DeepEqual(deployedInferenceService.Labels[constants.ModelRegistryRegisteredModelIdLabel], requestedInferenceService.Labels[constants.ModelRegistryRegisteredModelIdLabel]) &&
reflect.DeepEqual(deployedInferenceService.Labels[constants.ModelRegistryModelVersionIdLabel], requestedInferenceService.Labels[constants.ModelRegistryModelVersionIdLabel])
}
}
9 changes: 9 additions & 0 deletions controllers/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ const (
IstioIngressServiceHTTPPortName = "http2"
IstioIngressServiceHTTPSPortName = "https"
)

// model registry
const (
MLMDAddressEnv = "MLMD_ADDRESS"
ModelRegistryNamespaceLabel = "modelregistry.opendatahub.io/namespace"
ModelRegistryInferenceServiceIdLabel = "modelregistry.opendatahub.io/inference-service-id"
ModelRegistryModelVersionIdLabel = "modelregistry.opendatahub.io/model-version-id"
ModelRegistryRegisteredModelIdLabel = "modelregistry.opendatahub.io/registered-model-id"
)
Loading