Skip to content
Open
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
43 changes: 43 additions & 0 deletions api/v1beta1/openstacklightspeed_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1beta1
import (
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -91,6 +92,40 @@ type DatabaseSpec struct {
Class string `json:"class,omitempty"`
}

// ContainerResourcesSpec defines resource requirements for each container
// managed by the operator. Defaults are applied by the API server via
// kubebuilder markers. Users may override any container's resources in
// the CR; the provided value replaces the default entirely.
type ContainerResourcesSpec struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default:={requests: {cpu: "500m", memory: "2Gi"}, limits: {cpu: "2", memory: "8Gi"}}
// LlamaStack sets compute resources for the llama-stack (OGX) container
// in the lightspeed-stack deployment.
LlamaStack corev1.ResourceRequirements `json:"llamaStack,omitempty"`
Comment thread
omkarjoshi0304 marked this conversation as resolved.

// +kubebuilder:validation:Optional
// +kubebuilder:default:={requests: {cpu: "250m", memory: "512Mi"}, limits: {cpu: "1", memory: "2Gi"}}
// LightspeedService sets compute resources for the lightspeed-service-api
// container in the lightspeed-stack deployment.
LightspeedService corev1.ResourceRequirements `json:"lightspeedService,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default:={requests: {cpu: "30m", memory: "300Mi"}, limits: {cpu: "500m", memory: "2Gi"}}
// Postgres sets compute resources for the PostgreSQL container.
Postgres corev1.ResourceRequirements `json:"postgres,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default:={requests: {cpu: "500m", memory: "2Gi"}, limits: {cpu: "2", memory: "4Gi"}}
// OKP sets compute resources for the Offline Knowledge Portal container.
OKP corev1.ResourceRequirements `json:"okp,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default:={requests: {cpu: "50m", memory: "64Mi"}, limits: {cpu: "200m", memory: "256Mi"}}
// ConsolePlugin sets compute resources for the lightspeed-console-plugin
// container and its init container.
ConsolePlugin corev1.ResourceRequirements `json:"consolePlugin,omitempty"`
}

// OpenStackLightspeedSpec defines the desired state of OpenStackLightspeed
type OpenStackLightspeedSpec struct {
OpenStackLightspeedCore `json:",inline"`
Expand All @@ -105,6 +140,14 @@ type OpenStackLightspeedSpec struct {
// OKP configures the Offline Knowledge Portal (OKP) RAG source.
OKP *OKPSpec `json:"okp,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default:={}
// Resources configures compute resource requirements for individual
// containers managed by the operator. Each field has sensible defaults
// applied by the API server. Override any container's resources to
// replace its defaults entirely.
Resources ContainerResourcesSpec `json:"resources,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:pruning:PreserveUnknownFields
// Dev contains developer/experimental configuration.
Expand Down
21 changes: 21 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

347 changes: 347 additions & 0 deletions bundle/manifests/lightspeed.openstack.org_openstacklightspeeds.yaml

Large diffs are not rendered by default.

347 changes: 347 additions & 0 deletions config/crd/bases/lightspeed.openstack.org_openstacklightspeeds.yaml

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions config/samples/api_v1beta1_openstacklightspeed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ spec:
# database:
# size: "5Gi"
# class: "my-storage-class"
# Uncomment to customize container resource requests/limits:
# resources:
# llamaStack:
# requests:
# cpu: "500m"
# memory: "2Gi"
# limits:
# cpu: "2"
# memory: "8Gi"
# lightspeedService:
# requests:
# cpu: "250m"
# memory: "512Mi"
# limits:
# cpu: "1"
# memory: "2Gi"
# postgres:
# requests:
# cpu: "30m"
# memory: "300Mi"
# limits:
# cpu: "500m"
# memory: "2Gi"
# Uncomment to customize log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL):
# logging:
# ogxLogLevel: "all=info"
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ require (
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
golang.org/x/mod v0.35.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/mod v0.37.0 // indirect
golang.org/x/net v0.56.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/term v0.43.0 // indirect
golang.org/x/text v0.37.0 // indirect
golang.org/x/sync v0.21.0 // indirect
golang.org/x/sys v0.46.0 // indirect
golang.org/x/term v0.44.0 // indirect
golang.org/x/text v0.39.0 // indirect
golang.org/x/time v0.12.0 // indirect
golang.org/x/tools v0.44.0 // indirect
golang.org/x/tools v0.47.0 // indirect
Comment thread
omkarjoshi0304 marked this conversation as resolved.
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -200,41 +200,41 @@ golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/y
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4=
golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk=
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc=
golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus=
golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM=
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q=
golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
28 changes: 6 additions & 22 deletions internal/controller/console_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"fmt"

consolev1 "github.com/openshift/api/console/v1"
apiv1beta1 "github.com/openstack-k8s-operators/lightspeed-operator/api/v1beta1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
Expand All @@ -48,7 +48,9 @@ const consoleLocalesPath = "/usr/share/nginx/html/locales/en/" + consoleLocalesF
// buildConsoleDeploymentSpec builds the Deployment spec for the console plugin.
// Includes an init container that rewrites OpenShift references to OpenStack
// in the locales JSON file using an emptyDir volume.
func buildConsoleDeploymentSpec(consoleImage string) appsv1.DeploymentSpec {
func buildConsoleDeploymentSpec(consoleImage string, instance *apiv1beta1.OpenStackLightspeed) appsv1.DeploymentSpec {
consoleRes := instance.Spec.Resources.ConsolePlugin

replicas := int32(1)
volumeDefaultMode := VolumeDefaultMode
labels := generateConsoleSelectorLabels()
Expand Down Expand Up @@ -86,16 +88,7 @@ func buildConsoleDeploymentSpec(consoleImage string) appsv1.DeploymentSpec {
"awk '" + consoleLocalesRewriteAwk + "' " +
consoleLocalesPath + " > /locales-rewrite/" + consoleLocalesFilename,
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("50m"),
corev1.ResourceMemory: resource.MustParse("64Mi"),
},
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("200m"),
corev1.ResourceMemory: resource.MustParse("256Mi"),
},
},
Resources: consoleRes,
VolumeMounts: []corev1.VolumeMount{
{
Name: "locales-rewrite",
Expand All @@ -119,16 +112,7 @@ func buildConsoleDeploymentSpec(consoleImage string) appsv1.DeploymentSpec {
SecurityContext: &corev1.SecurityContext{
AllowPrivilegeEscalation: toPtr(false),
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("50m"),
corev1.ResourceMemory: resource.MustParse("64Mi"),
},
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("200m"),
corev1.ResourceMemory: resource.MustParse("256Mi"),
},
},
Resources: consoleRes,
VolumeMounts: []corev1.VolumeMount{
{
Name: "lightspeed-console-plugin-cert",
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/console_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func resolveConsoleImage(ctx context.Context, h *common_helper.Helper) string {
}

// reconcileConsoleDeploymentResource ensures the console plugin deployment exists.
func reconcileConsoleDeploymentResource(h *common_helper.Helper, ctx context.Context, _ *apiv1beta1.OpenStackLightspeed) error {
func reconcileConsoleDeploymentResource(h *common_helper.Helper, ctx context.Context, instance *apiv1beta1.OpenStackLightspeed) error {
logger := h.GetLogger()

consoleImage := resolveConsoleImage(ctx, h)
Expand All @@ -194,7 +194,7 @@ func reconcileConsoleDeploymentResource(h *common_helper.Helper, ctx context.Con
}

result, err := controllerutil.CreateOrPatch(ctx, h.GetClient(), deployment, func() error {
spec := buildConsoleDeploymentSpec(consoleImage)
spec := buildConsoleDeploymentSpec(consoleImage, instance)
deployment.Spec.Replicas = spec.Replicas
deployment.Spec.Selector = spec.Selector
deployment.Spec.Template = spec.Template
Expand Down
5 changes: 4 additions & 1 deletion internal/controller/console_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ var _ = Describe("Console Plugin", func() {
var spec appsv1.DeploymentSpec

BeforeEach(func() {
spec = buildConsoleDeploymentSpec(apiv1beta1.OpenStackLightspeedDefaultValues.ConsoleImagePF5URL)
instance := &apiv1beta1.OpenStackLightspeed{
Spec: apiv1beta1.OpenStackLightspeedSpec{},
}
spec = buildConsoleDeploymentSpec(apiv1beta1.OpenStackLightspeedDefaultValues.ConsoleImagePF5URL, instance)
})

It("should have one replica", func() {
Expand Down
Loading
Loading