feat: phase 8 serviceadapter crd rollout (32/33 tasks)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2026.
|
||||
|
||||
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 contains API Schema definitions for the gateway v1 API group
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=gateway.riotpiao.com
|
||||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// GroupVersion is group version used to register these objects
|
||||
GroupVersion = schema.GroupVersion{Group: "gateway.riotpiao.com", Version: "v1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
||||
|
||||
// AddToScheme adds the types in this group-version to the given scheme.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
Copyright 2026.
|
||||
|
||||
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 (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// ServiceAdapterUpstream defines the upstream target for this adapter.
|
||||
type ServiceAdapterUpstream struct {
|
||||
// URL is the upstream service endpoint.
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:MinLength=1
|
||||
URL string `json:"url"`
|
||||
|
||||
// TimeoutSeconds is the request timeout in seconds.
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:Minimum=1
|
||||
// +kubebuilder:validation:Maximum=3600
|
||||
TimeoutSeconds int32 `json:"timeoutSeconds"`
|
||||
}
|
||||
|
||||
// ServiceAdapterAuth defines authentication requirements.
|
||||
type ServiceAdapterAuth struct {
|
||||
// Required indicates if authentication is needed.
|
||||
// +kubebuilder:validation:Required
|
||||
Required bool `json:"required"`
|
||||
|
||||
// Capability is the required capability name (e.g., "reasoning", "embedding").
|
||||
// Empty if auth is not required.
|
||||
// +kubebuilder:validation:Optional
|
||||
Capability string `json:"capability,omitempty"`
|
||||
}
|
||||
|
||||
// ServiceAdapterMethod defines a single method endpoint.
|
||||
type ServiceAdapterMethod struct {
|
||||
// Verb is the HTTP method (GET, POST, etc.).
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:Enum=GET;POST;PUT;DELETE;PATCH;HEAD;OPTIONS
|
||||
Verb string `json:"verb"`
|
||||
|
||||
// UpstreamPath is the path to forward to on the upstream.
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:MinLength=1
|
||||
UpstreamPath string `json:"upstreamPath"`
|
||||
|
||||
// RequestSchema is the flat KV+type validation schema for requests (optional).
|
||||
// +kubebuilder:validation:Optional
|
||||
RequestSchema string `json:"requestSchema,omitempty"`
|
||||
|
||||
// ResponseSchema is the flat KV+type validation schema for responses (optional).
|
||||
// +kubebuilder:validation:Optional
|
||||
ResponseSchema string `json:"responseSchema,omitempty"`
|
||||
|
||||
// Auth overrides the resource-level auth for this method (optional).
|
||||
// +kubebuilder:validation:Optional
|
||||
Auth *ServiceAdapterAuth `json:"auth,omitempty"`
|
||||
}
|
||||
|
||||
// ServiceAdapterResource defines a resource exposed by this adapter.
|
||||
type ServiceAdapterResource struct {
|
||||
// Name is the resource identifier.
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:MinLength=1
|
||||
Name string `json:"name"`
|
||||
|
||||
// Methods are the HTTP methods available for this resource.
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:MinItems=1
|
||||
Methods []ServiceAdapterMethod `json:"methods"`
|
||||
|
||||
// Auth applies to all methods in this resource unless overridden.
|
||||
// +kubebuilder:validation:Optional
|
||||
Auth *ServiceAdapterAuth `json:"auth,omitempty"`
|
||||
}
|
||||
|
||||
// ServiceAdapterSpec defines the desired state of ServiceAdapter.
|
||||
type ServiceAdapterSpec struct {
|
||||
// ServiceName is the unique identifier for this service.
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:MinLength=1
|
||||
// +kubebuilder:validation:MaxLength=63
|
||||
ServiceName string `json:"serviceName"`
|
||||
|
||||
// Upstream defines where to forward requests.
|
||||
// +kubebuilder:validation:Required
|
||||
Upstream ServiceAdapterUpstream `json:"upstream"`
|
||||
|
||||
// Auth defines default authentication for this adapter.
|
||||
// +kubebuilder:validation:Required
|
||||
Auth ServiceAdapterAuth `json:"auth"`
|
||||
|
||||
// Retryable indicates if requests can be retried on 5xx.
|
||||
// +kubebuilder:validation:Optional
|
||||
// +kubebuilder:validation:Default=false
|
||||
Retryable bool `json:"retryable,omitempty"`
|
||||
|
||||
// Resources are the endpoints exposed by this adapter.
|
||||
// +kubebuilder:validation:Required
|
||||
Resources []ServiceAdapterResource `json:"resources"`
|
||||
}
|
||||
|
||||
// ServiceAdapterStatus defines the observed state of ServiceAdapter.
|
||||
type ServiceAdapterStatus struct {
|
||||
// Ready indicates if the adapter is loaded and healthy.
|
||||
// +kubebuilder:validation:Optional
|
||||
Ready bool `json:"ready,omitempty"`
|
||||
|
||||
// Error message if the adapter failed to load.
|
||||
// +kubebuilder:validation:Optional
|
||||
Error string `json:"error,omitempty"`
|
||||
|
||||
// LastSyncTime is when the adapter was last synced.
|
||||
// +kubebuilder:validation:Optional
|
||||
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:resource:scope=Namespaced
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="Service",type=string,JSONPath=`.spec.serviceName`
|
||||
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
|
||||
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
|
||||
|
||||
// ServiceAdapter describes a service exposed through the gateway.
|
||||
type ServiceAdapter struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ServiceAdapterSpec `json:"spec,omitempty"`
|
||||
Status ServiceAdapterStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ServiceAdapterList contains a list of ServiceAdapter.
|
||||
type ServiceAdapterList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []ServiceAdapter `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&ServiceAdapter{}, &ServiceAdapterList{})
|
||||
}
|
||||
Reference in New Issue
Block a user