Skip to content
Closed
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ help: ## Display this help.
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
mkdir -p config/operator/rbac && \
$(CONTROLLER_GEN) crd$(CRDDESC_OVERRIDE) output:crd:artifacts:config=config/crd/bases webhook paths="./..." && \
$(CONTROLLER_GEN) rbac:roleName=manager-role paths="{./apis/client/...,./apis/core/...,./apis/dataplane/...,./controllers/client/...,./controllers/core/...,./controllers/dataplane/...,./pkg/...}" output:dir=config/rbac && \
$(CONTROLLER_GEN) rbac:roleName=manager-role paths="{./apis/lightspeed/...,./apis/client/...,./apis/core/...,./apis/dataplane/...,./controllers/lightspeed/...,./controllers/client/...,./controllers/core/...,./controllers/dataplane/...,./pkg/...}" output:dir=config/rbac && \
$(CONTROLLER_GEN) rbac:roleName=operator-role paths="./controllers/operator/..." paths="./apis/operator/..." output:dir=config/operator/rbac && \
rm -f apis/bases/* && cp -a config/crd/bases apis/

Expand Down
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,13 @@ resources:
kind: OpenStack
path: github.com/openstack-k8s-operators/openstack-operator/apis/operator/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openstack.org
group: lightspeed
kind: OpenStackLightspeed
path: github.com/openstack-k8s-operators/openstack-operator/apis/lightspeed/v1beta1
version: v1beta1
version: "3"
96 changes: 96 additions & 0 deletions apis/bases/lightspeed.openstack.org_openstacklightspeeds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.18.0
name: openstacklightspeeds.lightspeed.openstack.org
spec:
group: lightspeed.openstack.org
names:
kind: OpenStackLightspeed
listKind: OpenStackLightspeedList
plural: openstacklightspeeds
singular: openstacklightspeed
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Status
jsonPath: .status.conditions[0].status
name: Status
type: string
- description: Message
jsonPath: .status.conditions[0].message
name: Message
type: string
name: v1beta1
schema:
openAPIV3Schema:
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
spec:
properties:
llmCredentials:
type: string
llmEndpoint:
type: string
llmEndpointType:
enum:
- azure_openai
- bam
- openai
- watsonx
- rhoai_vllm
- rhelai_vllm
- fake_provider
type: string
modelName:
type: string
ragImage:
type: string
tlsCACertBundle:
type: string
required:
- llmCredentials
- llmEndpoint
- llmEndpointType
- modelName
type: object
status:
properties:
conditions:
items:
properties:
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
severity:
type: string
status:
type: string
type:
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
observedGeneration:
format: int64
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}
40 changes: 40 additions & 0 deletions apis/lightspeed/v1beta1/conditions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright 2025.

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 v1beta1

import (
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
)

// OpenStackLightspeed Condition Types used by API objects.
const (
// OpenStackLightspeedReadyCondition Status=True condition which indicates if OpenStackLightspeedReadyCondition
// is configured and operational
OpenStackLightspeedReadyCondition condition.Type = "OpenStackLightspeedReady"
)

// Common Messages used by API objects.
const (
// OpenStackLightspeedReadyInitMessage
OpenStackLightspeedReadyInitMessage = "OpenStack Lightspeed not started"

// OpenStackLightspeedReadyMessage
OpenStackLightspeedReadyMessage = "OpenStack Lightspeed created"

// OpenStackLightspeedWaitingVectorDBMessage
OpenStackLightspeedWaitingVectorDBMessage = "Waiting for OpenStackLightspeed vector DB pod to become ready"
)
36 changes: 36 additions & 0 deletions apis/lightspeed/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2025.

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 v1beta1 contains API Schema definitions for the lightspeed v1beta1 API group
// +kubebuilder:object:generate=true
// +groupName=lightspeed.openstack.org
package v1beta1

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: "lightspeed.openstack.org", Version: "v1beta1"}

// 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
)
124 changes: 124 additions & 0 deletions apis/lightspeed/v1beta1/openstacklightspeed_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
Copyright 2025.

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 v1beta1

import (
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
// Container image fall-back defaults

// OpenStackLightspeedContainerImage is the fall-back container image for OpenStackLightspeed
OpenStackLightspeedContainerImage = "quay.io/openstack-lightspeed/rag-content:os-docs-2024.2"
)

// OpenStackLightspeedSpec defines the desired state of OpenStackLightspeed
type OpenStackLightspeedSpec struct {
OpenStackLightspeedCore `json:",inline"`

// +kubebuilder:validation:Optional
// ContainerImage for the Openstack Lightspeed RAG container (will be set to environmental default if empty)
RAGImage string `json:"ragImage"`
}

// OpenStackLightspeedCore defines the desired state of OpenStackLightspeed
type OpenStackLightspeedCore struct {
// +kubebuilder:validation:Required
// URL pointing to the LLM
LLMEndpoint string `json:"llmEndpoint"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=azure_openai;bam;openai;watsonx;rhoai_vllm;rhelai_vllm;fake_provider
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Provider Type"
// Type of the provider serving the LLM
LLMEndpointType string `json:"llmEndpointType"`

// +kubebuilder:validation:Required
// Name of the model to use at the API endpoint provided in LLMEndpoint
ModelName string `json:"modelName"`

// +kubebuilder:validation:Required
// Secret name containing API token for the LLMEndpoint. The key for the field
// in the secret that holds the token should be "apitoken".
LLMCredentials string `json:"llmCredentials"`

// +kubebuilder:validation:Optional
// Configmap name containing a CA Certificates bundle
TLSCACertBundle string `json:"tlsCACertBundle"`
}

// OpenStackLightspeedStatus defines the observed state of OpenStackLightspeed
type OpenStackLightspeedStatus struct {
// Conditions
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`

// ObservedGeneration - the most recent generation observed for this object.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +operator-sdk:csv:customresourcedefinitions:displayName="OpenStack Lightspeed"
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[0].status",description="Status"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[0].message",description="Message"

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

Spec OpenStackLightspeedSpec `json:"spec,omitempty"`
Status OpenStackLightspeedStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&OpenStackLightspeed{}, &OpenStackLightspeedList{})
}

// IsReady - returns true if OpenStackLightspeed is reconciled successfully
func (instance OpenStackLightspeed) IsReady() bool {
return instance.Status.Conditions.IsTrue(OpenStackLightspeedReadyCondition)
}

type OpenStackLightspeedDefaults struct {
RAGImageURL string
}

var OpenStackLightspeedDefaultValues OpenStackLightspeedDefaults

// SetupDefaults - initializes OpenStackLightspeedDefaultValues with default values from env vars
func SetupDefaults() {
// Acquire environmental defaults and initialize OpenStackLightspeed defaults with them
openStackLightspeedDefaults := OpenStackLightspeedDefaults{
RAGImageURL: util.GetEnvVar(
"RELATED_IMAGE_OPENSTACK_LIGHTSPEED_IMAGE_URL_DEFAULT", OpenStackLightspeedContainerImage),
}

OpenStackLightspeedDefaultValues = openStackLightspeedDefaults
}
28 changes: 28 additions & 0 deletions apis/lightspeed/v1beta1/webhook_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2025.

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 v1beta1

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"testing"
)

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "LightSpeed v1beta1 Suite")
}
Loading