Skip to content

Commit b6cb3c0

Browse files
committed
Initial NEMO implementation
1 parent 6b46630 commit b6cb3c0

39 files changed

+2097
-4
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,13 @@ resources:
5151
kind: GuardrailsOrchestrator
5252
path: github.com/trustyai-explainability/trustyai-service-operator/api/gorch/v1alpha1
5353
version: v1alpha1
54+
- api:
55+
crdVersion: v1
56+
namespaced: true
57+
controller: true
58+
domain: opendatahub.io
59+
group: trustyai
60+
kind: NemoGuardrails
61+
path: github.com/trustyai-explainability/trustyai-service-operator/api/nemo/v1alpha1
62+
version: v1alpha1
5463
version: "3"

api/common/ca_bundle.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package common
2+
3+
// CABundleConfig defines the CA bundle configuration for custom certificates
4+
type CABundleConfig struct {
5+
// ConfigMapName is the name of the ConfigMap containing CA bundle certificates
6+
ConfigMapName string `json:"configMapName"`
7+
// ConfigMapNamespace is the namespace of the ConfigMap (defaults to the same namespace as the CR)
8+
// +optional
9+
ConfigMapNamespace string `json:"configMapNamespace,omitempty"`
10+
// ConfigMapKeys specifies multiple keys within the ConfigMap containing CA bundle data
11+
// All certificates from these keys will be concatenated into a single CA bundle file
12+
// If not specified, defaults to [DefaultCABundleKey]
13+
// +optional
14+
// +kubebuilder:validation:MaxItems=50
15+
// +kubebuilder:validation:Items:Pattern="^[a-zA-Z0-9]([a-zA-Z0-9\\-_.]*[a-zA-Z0-9])?$"
16+
// +kubebuilder:validation:Items:MaxLength=253
17+
ConfigMapKeys []string `json:"configMapKeys,omitempty"`
18+
}
19+
20+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
21+
func (in *CABundleConfig) DeepCopyInto(out *CABundleConfig) {
22+
*out = *in
23+
if in.ConfigMapKeys != nil {
24+
in, out := &in.ConfigMapKeys, &out.ConfigMapKeys
25+
*out = make([]string, len(*in))
26+
copy(*out, *in)
27+
}
28+
}
29+
30+
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CABundleConfig.
31+
func (in *CABundleConfig) DeepCopy() *CABundleConfig {
32+
if in == nil {
33+
return nil
34+
}
35+
out := new(CABundleConfig)
36+
in.DeepCopyInto(out)
37+
return out
38+
}

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: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
corev1 "k8s.io/api/core/v1"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
)
24+
25+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
26+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
27+
28+
// NemoGuardrailsSpec defines the desired state of NemoGuardrails
29+
type NemoGuardrailsSpec struct {
30+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
31+
// Important: Run "make" to regenerate code after modifying this file
32+
33+
// NemoConfig should be the name of the configmap containing the NeMO server configuration
34+
NemoConfig string `json:"nemoConfig,omitempty"`
35+
CABundleConfig *common.CABundleConfig `json:"caBundleConfig,omitempty"`
36+
// Define Env information for the main container
37+
// +optional
38+
Env []corev1.EnvVar `json:"env,omitempty"`
39+
}
40+
41+
type CAStatus struct {
42+
ODHTrustedCAFound bool `json:"odhTrustedCAFound"`
43+
ODHTrustedCAError string `json:"odhTrustedCAError,omitempty"`
44+
OpenshiftServingCAFound bool `json:"openshiftServingCAFound"`
45+
OpenshiftServingCAError string `json:"openshiftServingCAError,omitempty"`
46+
UserCAFound bool `json:"userCAFound,omitempty"`
47+
UserCAError string `json:"userCAError,omitempty"`
48+
}
49+
50+
// NemoGuardrailStatus defines the observed state of NemoGuardrails
51+
type NemoGuardrailStatus struct {
52+
Phase string `json:"phase,omitempty"`
53+
54+
// Conditions describes the state of the NemoGuardrails resource.
55+
// +optional
56+
Conditions []common.Condition `json:"conditions,omitempty"`
57+
// CA describes the status of the CA configmaps
58+
// +optional
59+
CA *CAStatus `json:"ca,omitempty"`
60+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
61+
// Important: Run "make" to regenerate code after modifying this file
62+
}
63+
64+
//+kubebuilder:object:root=true
65+
//+kubebuilder:subresource:status
66+
67+
// NemoGuardrails is the Schema for the nemoguardrails API
68+
type NemoGuardrails struct {
69+
metav1.TypeMeta `json:",inline"`
70+
metav1.ObjectMeta `json:"metadata,omitempty"`
71+
72+
Spec NemoGuardrailsSpec `json:"spec,omitempty"`
73+
Status NemoGuardrailStatus `json:"status,omitempty"`
74+
}
75+
76+
//+kubebuilder:object:root=true
77+
78+
// NemoGuardrailsList contains a list of NemoGuardrails
79+
type NemoGuardrailsList struct {
80+
metav1.TypeMeta `json:",inline"`
81+
metav1.ListMeta `json:"metadata,omitempty"`
82+
Items []NemoGuardrails `json:"items"`
83+
}
84+
85+
func init() {
86+
SchemeBuilder.Register(&NemoGuardrails{}, &NemoGuardrailsList{})
87+
}

api/nemo/v1alpha1/zz_generated.deepcopy.go

Lines changed: 154 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package main
1919
import (
2020
"flag"
2121
"fmt"
22+
nemov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/nemo/v1alpha1"
2223
"os"
2324

2425
kservev1alpha1 "github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
@@ -67,6 +68,7 @@ func init() {
6768
utilruntime.Must(apiextensionsv1.AddToScheme(scheme))
6869
utilruntime.Must(kueuev1beta1.AddToScheme(scheme))
6970
utilruntime.Must(gorchv1alpha1.AddToScheme(scheme))
71+
utilruntime.Must(nemov1alpha1.AddToScheme(scheme))
7072
//+kubebuilder:scaffold:scheme
7173
}
7274

config/base/params.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ lmes-allow-online=true
1313
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/guardrails-detector-built-in:latest
16-
guardrails-sidecar-gateway-image=quay.io/trustyai/guardrails-sidecar-gateway:latest
16+
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)