Skip to content

Commit 8983330

Browse files
committed
Initial NEMO PoC
1 parent b611e37 commit 8983330

36 files changed

+1464
-5
lines changed

PROJECT

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ resources:
2323
- api:
2424
crdVersion: v1
2525
namespaced: true
26-
controller: false
2726
domain: opendatahub.io
2827
group: trustyai
2928
kind: TrustyAIService
@@ -51,4 +50,13 @@ resources:
5150
kind: GuardrailsOrchestrator
5251
path: github.com/trustyai-explainability/trustyai-service-operator/api/gorch/v1alpha1
5352
version: v1alpha1
53+
- api:
54+
crdVersion: v1
55+
namespaced: true
56+
controller: true
57+
domain: opendatahub.io
58+
group: trustyai
59+
kind: NemoGuardrails
60+
path: github.com/trustyai-explainability/trustyai-service-operator/api/v1alpha1
61+
version: v1alpha1
5462
version: "3"

api/common/condition.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package common
2+
3+
import (
4+
corev1 "k8s.io/api/core/v1"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
)
7+
8+
type Condition struct {
9+
Type string `json:"type" description:"type of condition ie. Available|Progressing|Degraded."`
10+
11+
Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"`
12+
13+
// +optional
14+
Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"`
15+
16+
// +optional
17+
Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"`
18+
19+
// +optional
20+
LastTransitionTime metav1.Time `json:"lastTransitionTime" description:"last time the condition transit from one status to another"`
21+
}
22+
23+
// DeepCopyInto copies all properties of this object into another object of the same type.
24+
func (in *Condition) DeepCopyInto(out *Condition) {
25+
*out = *in
26+
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
27+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2023.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1alpha1 contains API Schema definitions for the trustyai v1alpha1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=trustyai.opendatahub.io
20+
package v1alpha1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects
29+
GroupVersion = schema.GroupVersion{Group: "trustyai.opendatahub.io", Version: "v1alpha1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
Copyright 2023.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
"github.com/trustyai-explainability/trustyai-service-operator/api/common"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
25+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
26+
27+
// NemoGuardrailsSpec defines the desired state of NemoGuardrails
28+
type NemoGuardrailsSpec struct {
29+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
30+
// Important: Run "make" to regenerate code after modifying this file
31+
32+
// NemoConfig should be the name of the configmap containing the NeMO server configuration
33+
NemoConfig string `json:"nemoConfig,omitempty"`
34+
}
35+
36+
// NemoGuardrailStatus defines the observed state of NemoGuardrails
37+
type NemoGuardrailStatus struct {
38+
Phase string `json:"phase,omitempty"`
39+
40+
// Conditions describes the state of the NemoGuardrails resource.
41+
// +optional
42+
Conditions []common.Condition `json:"conditions,omitempty"`
43+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
44+
// Important: Run "make" to regenerate code after modifying this file
45+
}
46+
47+
//+kubebuilder:object:root=true
48+
//+kubebuilder:subresource:status
49+
50+
// NemoGuardrails is the Schema for the nemoguardrails API
51+
type NemoGuardrails struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ObjectMeta `json:"metadata,omitempty"`
54+
55+
Spec NemoGuardrailsSpec `json:"spec,omitempty"`
56+
Status NemoGuardrailStatus `json:"status,omitempty"`
57+
}
58+
59+
//+kubebuilder:object:root=true
60+
61+
// NemoGuardrailsList contains a list of NemoGuardrails
62+
type NemoGuardrailsList struct {
63+
metav1.TypeMeta `json:",inline"`
64+
metav1.ListMeta `json:"metadata,omitempty"`
65+
Items []NemoGuardrails `json:"items"`
66+
}
67+
68+
func init() {
69+
SchemeBuilder.Register(&NemoGuardrails{}, &NemoGuardrailsList{})
70+
}

api/nemo/v1alpha1/zz_generated.deepcopy.go

Lines changed: 122 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package main
1919
import (
2020
"flag"
2121
"fmt"
22+
trustyaiv1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/nemo/v1alpha1"
2223
"os"
2324

2425
kservev1alpha1 "github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
@@ -39,14 +40,15 @@ import (
3940
"sigs.k8s.io/controller-runtime/pkg/log/zap"
4041
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
4142

43+
kueuev1beta1 "sigs.k8s.io/kueue/apis/kueue/v1beta1"
44+
4245
gorchv1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/gorch/v1alpha1"
4346
lmesv1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/lmes/v1alpha1"
4447
tasv1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1"
4548
tasv1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1"
4649
"github.com/trustyai-explainability/trustyai-service-operator/controllers"
4750
"github.com/trustyai-explainability/trustyai-service-operator/controllers/constants"
4851
"github.com/trustyai-explainability/trustyai-service-operator/controllers/utils"
49-
kueuev1beta1 "sigs.k8s.io/kueue/apis/kueue/v1beta1"
5052
//+kubebuilder:scaffold:imports
5153
)
5254

@@ -67,6 +69,7 @@ func init() {
6769
utilruntime.Must(apiextensionsv1.AddToScheme(scheme))
6870
utilruntime.Must(kueuev1beta1.AddToScheme(scheme))
6971
utilruntime.Must(gorchv1alpha1.AddToScheme(scheme))
72+
utilruntime.Must(trustyaiv1alpha1.AddToScheme(scheme))
7073
//+kubebuilder:scaffold:scheme
7174
}
7275

@@ -130,6 +133,7 @@ func main() {
130133
setupLog.Error(err, "unable to initialize controller(s)")
131134
os.Exit(1)
132135
}
136+
133137
//+kubebuilder:scaffold:builder
134138

135139
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {

config/base/params.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ lmes-allow-code-execution=true
1414
guardrails-orchestrator-image=quay.io/trustyai/ta-guardrails-orchestrator:latest
1515
guardrails-built-in-detector-image=quay.io/trustyai/regex-detector:latest
1616
guardrails-sidecar-gateway-image=quay.io/trustyai/guardrails-sidecar-gateway:latest
17+
nemo-guardrails-image=quay.io/trustyai/nemo-guardrails-server:latest

0 commit comments

Comments
 (0)