OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
feat: operator pvc mount (#1513)
mingcd9b23460d5b
diff --git a/kubernetes/operator/README.md b/kubernetes/operator/README.mdindex f8d04b4a6..aa5c299d5 100644--- a/kubernetes/operator/README.md+++ b/kubernetes/operator/README.md@@ -38,6 +38,12 @@ kubectl cluster-info --context kind-openragkubectl get nodes```+### 3a. Start the podman machine if it's not running after restart your laptop+```bash+podman start openrag-control-plane+kubectl config use-context kind-openrag+```+### 4. Load a locally built operator image (optional)If you built the image locally instead of pulling from GHCR:@@ -47,6 +53,18 @@ make docker-build IMG=openrag-operator:devpodman save openrag-operator:dev | kind load image-archive /dev/stdin --name openrag```+Install CRD++```bash+make install+```++Run the operator locally:++```bash+go run cmd/main.go+```+### 5. Tear down```bashdiff --git a/kubernetes/operator/api/v1alpha1/openrag_types.go b/kubernetes/operator/api/v1alpha1/openrag_types.goindex 444dc7686..dd59f1a8a 100644--- a/kubernetes/operator/api/v1alpha1/openrag_types.go+++ b/kubernetes/operator/api/v1alpha1/openrag_types.go@@ -45,38 +45,137 @@ type FrontendSpec struct {ComponentSpec `json:",inline"`}+// FlowIDsSpec holds the Langflow flow UUIDs consumed by the backend.+type FlowIDsSpec struct {+ // +optional+ Chat string `json:"chat,omitempty"`+ // +optional+ Ingest string `json:"ingest,omitempty"`+ // +optional+ URLIngest string `json:"urlIngest,omitempty"`+ // +optional+ Nudges string `json:"nudges,omitempty"`+}++// GoogleOAuthSpec holds Google OAuth2 client credentials.+type GoogleOAuthSpec struct {+ // +optional+ ClientID string `json:"clientId,omitempty"`+ // ClientSecret references the Secret key holding the OAuth client secret.+ // +optional+ ClientSecret *corev1.SecretKeySelector `json:"clientSecret,omitempty"`+}++// MicrosoftOAuthSpec holds Microsoft Graph OAuth2 client credentials.+type MicrosoftOAuthSpec struct {+ // +optional+ ClientID string `json:"clientId,omitempty"`+ // ClientSecret references the Secret key holding the OAuth client secret.+ // +optional+ ClientSecret *corev1.SecretKeySelector `json:"clientSecret,omitempty"`+}++// OAuthSpec aggregates supported OAuth provider configurations.+type OAuthSpec struct {+ // +optional+ Google *GoogleOAuthSpec `json:"google,omitempty"`+ // +optional+ Microsoft *MicrosoftOAuthSpec `json:"microsoft,omitempty"`+}+// BackendSpec configures the OpenRAG backend (FastAPI).type BackendSpec struct {ComponentSpec `json:",inline"`- // EnvSecret is the name of a Secret whose keys are mounted as /app/.env.- // The secret must contain a single key ".env" with the full dotenv content.- // +optional- EnvSecret string `json:"envSecret,omitempty"`-// JWTSigningKeySecret references the Secret key that holds the JWT signing key.- // If omitted the operator generates a random key and stores it in a managed Secret.// +optionalJWTSigningKeySecret *corev1.SecretKeySelector `json:"jwtSigningKeySecret,omitempty"`- // BackendDataStorage configures a PVC mounted at /app/backend-data.+ // EncryptionKeySecret references the Secret key for OPENRAG_ENCRYPTION_KEY.+ // If omitted the operator auto-generates a stable key.+ // +optional+ EncryptionKeySecret *corev1.SecretKeySelector `json:"encryptionKeySecret,omitempty"`++ // Storage configures a PVC mounted at /app/backend-data.// +optionalStorage *PersistenceSpec `json:"storage,omitempty"`++ // FlowIDs are the Langflow flow UUIDs the backend calls for chat, ingest, etc.+ // +optional+ FlowIDs *FlowIDsSpec `json:"flowIds,omitempty"`++ // OAuthBrokerURL is the OAuth callback URL (OAUTH_BROKER_URL).+ // +optional+ OAuthBrokerURL string `json:"oauthBrokerUrl,omitempty"`++ // IBMAuthEnabled enables IBM IAM authentication (IBM_AUTH_ENABLED).+ // +optional+ IBMAuthEnabled bool `json:"ibmAuthEnabled,omitempty"`++ // OAuth configures Google and Microsoft OAuth providers.+ // +optional+ OAuth *OAuthSpec `json:"oauth,omitempty"`}// LangflowSpec configures the Langflow instance.type LangflowSpec struct {ComponentSpec `json:",inline"`- // EnvSecret is the name of a Secret whose single ".env" key is mounted at /app/.env.+ // SecretKeySecret references the Secret key for LANGFLOW_SECRET_KEY,+ // shared between backend and Langflow. If omitted the operator auto-generates+ // a stable key stored in <cr-name>-openrag-gen-creds.+ // +optional+ SecretKeySecret *corev1.SecretKeySelector `json:"secretKeySecret,omitempty"`++ // DatabaseURL overrides LANGFLOW_DATABASE_URL.+ // Defaults to sqlite:////app/data/langflow.db when storage is enabled.+ // +optional+ DatabaseURL string `json:"databaseUrl,omitempty"`++ // FlowsRef is the git branch name or commit SHA from which flow JSON files+ // are downloaded at pod startup via an init container. When set, all *.json+ // files under flows/ in langflow-ai/openrag at that ref are fetched into+ // /app/flows (LANGFLOW_LOAD_FLOWS_PATH). Use a commit SHA for reproducibility.+ // +optional+ FlowsRef string `json:"flowsRef,omitempty"`++ // FlowsInitImage is the container image used by the flows-download init container.+ // Defaults to python:3-alpine.// +optional- EnvSecret string `json:"envSecret,omitempty"`+ FlowsInitImage string `json:"flowsInitImage,omitempty"`// Storage configures a PVC mounted at /app/data (Langflow SQLite + flows).// +optionalStorage *PersistenceSpec `json:"storage,omitempty"`}+// LLMSpec configures the LLM provider used by backend and Langflow.+type LLMSpec struct {+ // +optional+ Provider string `json:"provider,omitempty"`+ // +optional+ Model string `json:"model,omitempty"`+}++// EmbeddingSpec configures the embedding provider.+type EmbeddingSpec struct {+ // +optional+ Provider string `json:"provider,omitempty"`+ // +optional+ Model string `json:"model,omitempty"`+}++// WatsonXSpec holds IBM WatsonX connection details.+type WatsonXSpec struct {+ // +optional+ Endpoint string `json:"endpoint,omitempty"`+ // +optional+ ProjectID string `json:"projectId,omitempty"`+ // APIKeySecret references the Secret key for WATSONX_API_KEY.+ // +optional+ APIKeySecret *corev1.SecretKeySelector `json:"apiKeySecret,omitempty"`+}+// PersistenceSpec describes a PVC to be created or reused for a component.type PersistenceSpec struct {// +optional@@ -139,8 +238,6 @@ type DoclingSpec struct {}// NetworkPolicySpec controls whether the operator creates a NetworkPolicy for Langflow.-// The generated policy restricts ingress to RFC-1918 ranges and permits-// egress to Docling, DNS, OpenSearch (9200/443), and Langflow itself.type NetworkPolicySpec struct {// +optional// +kubebuilder:default=false@@ -149,14 +246,16 @@ type NetworkPolicySpec struct {// OpenRAGSpec defines the desired state of an OpenRAG instance.type OpenRAGSpec struct {- // TargetNamespace is the namespace where all OpenRAG resources (deployments,- // services, service accounts) are created. The operator creates this namespace- // if it does not exist and deletes it when the CR is deleted.+ // TargetNamespace is the namespace where all OpenRAG resources are created.// Defaults to the namespace of the CR itself. Cannot be "default".// +optional// +kubebuilder:validation:XValidation:rule="self != 'default'",message="targetNamespace must not be 'default'"TargetNamespace string `json:"targetNamespace,omitempty"`+ // TenantID sets TENANT_ID in both backend and Langflow.+ // +optional+ TenantID string `json:"tenantId,omitempty"`+// ImagePullSecrets for private registries, applied to all component pods.// +optionalImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`@@ -173,8 +272,19 @@ type OpenRAGSpec struct {// +kubebuilder:validation:RequiredLangflow LangflowSpec `json:"langflow"`+ // LLM configures the LLM provider (LLM_PROVIDER, LLM_MODEL).+ // +optional+ LLM *LLMSpec `json:"llm,omitempty"`++ // Embedding configures the embedding provider (EMBEDDING_PROVIDER, EMBEDDING_MODEL).+ // +optional+ Embedding *EmbeddingSpec `json:"embedding,omitempty"`++ // WatsonX configures IBM WatsonX credentials.+ // +optional+ WatsonX *WatsonXSpec `json:"watsonx,omitempty"`+// OpenSearch configures the external OpenSearch connection.- // Required unless you supply the credentials via Backend.EnvSecret.// +optionalOpenSearch *OpenSearchSpec `json:"opensearch,omitempty"`diff --git a/kubernetes/operator/api/v1alpha1/zz_generated.deepcopy.go b/kubernetes/operator/api/v1alpha1/zz_generated.deepcopy.goindex 01041de9e..ca691fe38 100644--- a/kubernetes/operator/api/v1alpha1/zz_generated.deepcopy.go+++ b/kubernetes/operator/api/v1alpha1/zz_generated.deepcopy.go@@ -35,11 +35,26 @@ func (in *BackendSpec) DeepCopyInto(out *BackendSpec) {*out = new(v1.SecretKeySelector)(*in).DeepCopyInto(*out)}+ if in.EncryptionKeySecret != nil {+ in, out := &in.EncryptionKeySecret, &out.EncryptionKeySecret+ *out = new(v1.SecretKeySelector)+ (*in).DeepCopyInto(*out)+ }if in.Storage != nil {in, out := &in.Storage, &out.Storage*out = new(PersistenceSpec)(*in).DeepCopyInto(*out)}+ if in.FlowIDs != nil {+ in, out := &in.FlowIDs, &out.FlowIDs+ *out = new(FlowIDsSpec)+ **out = **in+ }+ if in.OAuth != nil {+ in, out := &in.OAuth, &out.OAuth+ *out = new(OAuthSpec)+ (*in).DeepCopyInto(*out)+ }}// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendSpec.@@ -114,6 +129,36 @@ func (in *DoclingSpec) DeepCopy() *DoclingSpec {return out}+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.+func (in *EmbeddingSpec) DeepCopyInto(out *EmbeddingSpec) {+ *out = *in+}++// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EmbeddingSpec.+func (in *EmbeddingSpec) DeepCopy() *EmbeddingSpec {+ if in == nil {+ return nil+ }+ out := new(EmbeddingSpec)+ in.DeepCopyInto(out)+ return out+}++// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.+func (in *FlowIDsSpec) DeepCopyInto(out *FlowIDsSpec) {+ *out = *in+}++// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlowIDsSpec.+func (in *FlowIDsSpec) DeepCopy() *FlowIDsSpec {+ if in == nil {+ return nil+ }+ out := new(FlowIDsSpec)+ in.DeepCopyInto(out)+ return out+}+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.func (in *FrontendSpec) DeepCopyInto(out *FrontendSpec) {*out = *in@@ -130,10 +175,50 @@ func (in *FrontendSpec) DeepCopy() *FrontendSpec {return out}+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.+func (in *GoogleOAuthSpec) DeepCopyInto(out *GoogleOAuthSpec) {+ *out = *in+ if in.ClientSecret != nil {+ in, out := &in.ClientSecret, &out.ClientSecret+ *out = new(v1.SecretKeySelector)+ (*in).DeepCopyInto(*out)+ }+}++// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GoogleOAuthSpec.+func (in *GoogleOAuthSpec) DeepCopy() *GoogleOAuthSpec {+ if in == nil {+ return nil+ }+ out := new(GoogleOAuthSpec)+ in.DeepCopyInto(out)+ return out+}++// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.+func (in *LLMSpec) DeepCopyInto(out *LLMSpec) {+ *out = *in+}++// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LLMSpec.+func (in *LLMSpec) DeepCopy() *LLMSpec {+ if in == nil {+ return nil+ }+ out := new(LLMSpec)+ in.DeepCopyInto(out)+ return out+}+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.func (in *LangflowSpec) DeepCopyInto(out *LangflowSpec) {*out = *inin.ComponentSpec.DeepCopyInto(&out.ComponentSpec)+ if in.SecretKeySecret != nil {+ in, out := &in.SecretKeySecret, &out.SecretKeySecret+ *out = new(v1.SecretKeySelector)+ (*in).DeepCopyInto(*out)+ }if in.Storage != nil {in, out := &in.Storage, &out.Storage*out = new(PersistenceSpec)@@ -151,6 +236,26 @@ func (in *LangflowSpec) DeepCopy() *LangflowSpec {return out}+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.+func (in *MicrosoftOAuthSpec) DeepCopyInto(out *MicrosoftOAuthSpec) {+ *out = *in+ if in.ClientSecret != nil {+ in, out := &in.ClientSecret, &out.ClientSecret+ *out = new(v1.SecretKeySelector)+ (*in).DeepCopyInto(*out)+ }+}++// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MicrosoftOAuthSpec.+func (in *MicrosoftOAuthSpec) DeepCopy() *MicrosoftOAuthSpec {+ if in == nil {+ return nil+ }+ out := new(MicrosoftOAuthSpec)+ in.DeepCopyInto(out)+ return out+}+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.func (in *NetworkPolicySpec) DeepCopyInto(out *NetworkPolicySpec) {*out = *in@@ -166,6 +271,31 @@ func (in *NetworkPolicySpec) DeepCopy() *NetworkPolicySpec {return out}+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.+func (in *OAuthSpec) DeepCopyInto(out *OAuthSpec) {+ *out = *in+ if in.Google != nil {+ in, out := &in.Google, &out.Google+ *out = new(GoogleOAuthSpec)+ (*in).DeepCopyInto(*out)+ }+ if in.Microsoft != nil {+ in, out := &in.Microsoft, &out.Microsoft+ *out = new(MicrosoftOAuthSpec)+ (*in).DeepCopyInto(*out)+ }+}++// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OAuthSpec.+func (in *OAuthSpec) DeepCopy() *OAuthSpec {+ if in == nil {+ return nil+ }+ out := new(OAuthSpec)+ in.DeepCopyInto(out)+ return out+}+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.func (in *OpenRAG) DeepCopyInto(out *OpenRAG) {*out = *in@@ -236,6 +366,21 @@ func (in *OpenRAGSpec) DeepCopyInto(out *OpenRAGSpec) {in.Frontend.DeepCopyInto(&out.Frontend)in.Backend.DeepCopyInto(&out.Backend)in.Langflow.DeepCopyInto(&out.Langflow)+ if in.LLM != nil {+ in, out := &in.LLM, &out.LLM+ *out = new(LLMSpec)+ **out = **in+ }+ if in.Embedding != nil {+ in, out := &in.Embedding, &out.Embedding+ *out = new(EmbeddingSpec)+ **out = **in+ }+ if in.WatsonX != nil {+ in, out := &in.WatsonX, &out.WatsonX+ *out = new(WatsonXSpec)+ (*in).DeepCopyInto(*out)+ }if in.OpenSearch != nil {in, out := &in.OpenSearch, &out.OpenSearch*out = new(OpenSearchSpec)@@ -316,3 +461,23 @@ func (in *PersistenceSpec) DeepCopy() *PersistenceSpec {in.DeepCopyInto(out)return out}++// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.+func (in *WatsonXSpec) DeepCopyInto(out *WatsonXSpec) {+ *out = *in+ if in.APIKeySecret != nil {+ in, out := &in.APIKeySecret, &out.APIKeySecret+ *out = new(v1.SecretKeySelector)+ (*in).DeepCopyInto(*out)+ }+}++// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WatsonXSpec.+func (in *WatsonXSpec) DeepCopy() *WatsonXSpec {+ if in == nil {+ return nil+ }+ out := new(WatsonXSpec)+ in.DeepCopyInto(out)+ return out+}diff --git a/kubernetes/operator/config/crd/bases/openr.ag_openrags.yaml b/kubernetes/operator/config/crd/bases/openr.ag_openrags.yamlindex 41f5d13ff..8984bc5a4 100644--- a/kubernetes/operator/config/crd/bases/openr.ag_openrags.yaml+++ b/kubernetes/operator/config/crd/bases/openr.ag_openrags.yaml@@ -979,6 +979,32 @@ spec:x-kubernetes-list-type: atomictype: objecttype: object+ encryptionKeySecret:+ description: |-+ EncryptionKeySecret references the Secret key for OPENRAG_ENCRYPTION_KEY.+ If omitted the operator auto-generates a stable key.+ properties:+ key:+ description: The key of the secret to select from. Must be+ a valid secret key.+ type: string+ name:+ default: ""+ description: |-+ Name of the referent.+ This field is effectively required, but due to backwards compatibility is+ allowed to be empty. Instances of this type with an empty value here are+ almost certainly wrong.+ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names+ type: string+ optional:+ description: Specify whether the Secret or its key must be+ defined+ type: boolean+ required:+ - key+ type: object+ x-kubernetes-map-type: atomicenv:description: Additional environment variables injected into thecontainer.@@ -1100,11 +1126,22 @@ spec:- nametype: objecttype: array- envSecret:- description: |-- EnvSecret is the name of a Secret whose keys are mounted as /app/.env.- The secret must contain a single key ".env" with the full dotenv content.- type: string+ flowIds:+ description: FlowIDs are the Langflow flow UUIDs the backend calls+ for chat, ingest, etc.+ properties:+ chat:+ type: string+ ingest:+ type: string+ nudges:+ type: string+ urlIngest:+ type: string+ type: object+ ibmAuthEnabled:+ description: IBMAuthEnabled enables IBM IAM authentication (IBM_AUTH_ENABLED).+ type: booleanimage:description: Image is the container image (repository:tag).type: string@@ -1114,9 +1151,8 @@ spec:a container imagetype: stringjwtSigningKeySecret:- description: |-- JWTSigningKeySecret references the Secret key that holds the JWT signing key.- If omitted the operator generates a random key and stores it in a managed Secret.+ description: JWTSigningKeySecret references the Secret key that+ holds the JWT signing key.properties:key:description: The key of the secret to select from. Must be@@ -1143,6 +1179,76 @@ spec:additionalProperties:type: stringtype: object+ oauth:+ description: OAuth configures Google and Microsoft OAuth providers.+ properties:+ google:+ description: GoogleOAuthSpec holds Google OAuth2 client credentials.+ properties:+ clientId:+ type: string+ clientSecret:+ description: ClientSecret references the Secret key holding+ the OAuth client secret.+ properties:+ key:+ description: The key of the secret to select from. Must+ be a valid secret key.+ type: string+ name:+ default: ""+ description: |-+ Name of the referent.+ This field is effectively required, but due to backwards compatibility is+ allowed to be empty. Instances of this type with an empty value here are+ almost certainly wrong.+ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names+ type: string+ optional:+ description: Specify whether the Secret or its key+ must be defined+ type: boolean+ required:+ - key+ type: object+ x-kubernetes-map-type: atomic+ type: object+ microsoft:+ description: MicrosoftOAuthSpec holds Microsoft Graph OAuth2+ client credentials.+ properties:+ clientId:+ type: string+ clientSecret:+ description: ClientSecret references the Secret key holding+ the OAuth client secret.+ properties:+ key:+ description: The key of the secret to select from. Must+ be a valid secret key.+ type: string+ name:+ default: ""+ description: |-+ Name of the referent.+ This field is effectively required, but due to backwards compatibility is+ allowed to be empty. Instances of this type with an empty value here are+ almost certainly wrong.+ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names+ type: string+ optional:+ description: Specify whether the Secret or its key+ must be defined+ type: boolean+ required:+ - key+ type: object+ x-kubernetes-map-type: atomic+ type: object+ type: object+ oauthBrokerUrl:+ description: OAuthBrokerURL is the OAuth callback URL (OAUTH_BROKER_URL).+ type: stringreplicas:default: 1format: int32@@ -1209,7 +1315,7 @@ spec:type: objecttype: objectstorage:- description: BackendDataStorage configures a PVC mounted at /app/backend-data.+ description: Storage configures a PVC mounted at /app/backend-data.properties:enabled:default: true@@ -1289,6 +1395,15 @@ spec:required:- hosttype: object+ embedding:+ description: Embedding configures the embedding provider (EMBEDDING_PROVIDER,+ EMBEDDING_MODEL).+ properties:+ model:+ type: string+ provider:+ type: string+ type: objectfrontend:description: Frontend configures the OpenRAG Next.js frontend.properties:@@ -3392,6 +3507,11 @@ spec:x-kubernetes-list-type: atomictype: objecttype: object+ databaseUrl:+ description: |-+ DatabaseURL overrides LANGFLOW_DATABASE_URL.+ Defaults to sqlite:////app/data/langflow.db when storage is enabled.+ type: stringenv:description: Additional environment variables injected into thecontainer.@@ -3513,9 +3633,17 @@ spec:- nametype: objecttype: array- envSecret:- description: EnvSecret is the name of a Secret whose single ".env"- key is mounted at /app/.env.+ flowsInitImage:+ description: |-+ FlowsInitImage is the container image used by the flows-download init container.+ Defaults to python:3-alpine.+ type: string+ flowsRef:+ description: |-+ FlowsRef is the git branch name or commit SHA from which flow JSON files+ are downloaded at pod startup via an init container. When set, all *.json+ files under flows/ in langflow-ai/openrag at that ref are fetched into+ /app/flows (LANGFLOW_LOAD_FLOWS_PATH). Use a commit SHA for reproducibility.type: stringimage:description: Image is the container image (repository:tag).@@ -3594,6 +3722,33 @@ spec:More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/type: objecttype: object+ secretKeySecret:+ description: |-+ SecretKeySecret references the Secret key for LANGFLOW_SECRET_KEY,+ shared between backend and Langflow. If omitted the operator auto-generates+ a stable key stored in <cr-name>-openrag-gen-creds.+ properties:+ key:+ description: The key of the secret to select from. Must be+ a valid secret key.+ type: string+ name:+ default: ""+ description: |-+ Name of the referent.+ This field is effectively required, but due to backwards compatibility is+ allowed to be empty. Instances of this type with an empty value here are+ almost certainly wrong.+ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names+ type: string+ optional:+ description: Specify whether the Secret or its key must be+ defined+ type: boolean+ required:+ - key+ type: object+ x-kubernetes-map-type: atomicstorage:description: Storage configures a PVC mounted at /app/data (LangflowSQLite + flows).@@ -3659,6 +3814,14 @@ spec:required:- imagetype: object+ llm:+ description: LLM configures the LLM provider (LLM_PROVIDER, LLM_MODEL).+ properties:+ model:+ type: string+ provider:+ type: string+ type: objectnetworkPolicy:description: NetworkPolicy controls creation of a NetworkPolicy forthe Langflow pod.@@ -3668,9 +3831,7 @@ spec:type: booleantype: objectopensearch:- description: |-- OpenSearch configures the external OpenSearch connection.- Required unless you supply the credentials via Backend.EnvSecret.+ description: OpenSearch configures the external OpenSearch connection.properties:credentialsSecret:description: CredentialsSecret is the name of a Secret with keys@@ -3695,14 +3856,47 @@ spec:type: objecttargetNamespace:description: |-- TargetNamespace is the namespace where all OpenRAG resources (deployments,- services, service accounts) are created. The operator creates this namespace- if it does not exist and deletes it when the CR is deleted.+ TargetNamespace is the namespace where all OpenRAG resources are created.Defaults to the namespace of the CR itself. Cannot be "default".type: stringx-kubernetes-validations:- message: targetNamespace must not be 'default'rule: self != 'default'+ tenantId:+ description: TenantID sets TENANT_ID in both backend and Langflow.+ type: string+ watsonx:+ description: WatsonX configures IBM WatsonX credentials.+ properties:+ apiKeySecret:+ description: APIKeySecret references the Secret key for WATSONX_API_KEY.+ properties:+ key:+ description: The key of the secret to select from. Must be+ a valid secret key.+ type: string+ name:+ default: ""+ description: |-+ Name of the referent.+ This field is effectively required, but due to backwards compatibility is+ allowed to be empty. Instances of this type with an empty value here are+ almost certainly wrong.+ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names+ type: string+ optional:+ description: Specify whether the Secret or its key must be+ defined+ type: boolean+ required:+ - key+ type: object+ x-kubernetes-map-type: atomic+ endpoint:+ type: string+ projectId:+ type: string+ type: objectrequired:- backend- frontenddiff --git a/kubernetes/operator/config/samples/kind-cluster-openrag-cr.yaml b/kubernetes/operator/config/samples/kind-cluster-openrag-cr.yamlnew file mode 100644index 000000000..3ca0467e3--- /dev/null+++ b/kubernetes/operator/config/samples/kind-cluster-openrag-cr.yaml@@ -0,0 +1,66 @@+apiVersion: openr.ag/v1alpha1+kind: OpenRAG+metadata:+ name: my-openrag+ namespace: my-tenant+spec:+ targetNamespace: my-tenant++ frontend:+ image: edwinjosechittilappilly/orag-staging-frontend:release-saas-19a95c48+ resources:+ requests:+ cpu: "500m"+ memory: "512Mi"+ limits:+ cpu: "1"+ memory: "2Gi"++ backend:+ image: edwinjosechittilappilly/orag-staging-backend:release-saas-19a95c48+ resources:+ requests:+ cpu: "500m"+ memory: "1Gi"+ limits:+ cpu: "2"+ memory: "8Gi"+ # envSecret: my-openrag-backend-env # Secret with ".env" key+ # jwtSigningKeySecret:+ # name: my-jwt-secret+ # key: JWT_SIGNING_KEY+ storage:+ enabled: true+ size: "1Gi"++ langflow:+ image: edwinjosechittilappilly/orag-staging-langflow:release-saas-19a95c48+ resources:+ requests:+ cpu: "500m"+ memory: "1Gi"+ limits:+ cpu: "1"+ memory: "2Gi"+ # envSecret: my-openrag-langflow-env # Secret with ".env" key+ flowsRef: release-saas-0.1 # Download flows from this branch+ storage:+ enabled: true+ size: "1Gi"++ # External OpenSearch — required unless credentials are in backend envSecret+ # opensearch:+ # host: opensearch-coordinating.opensearch.svc.cluster.local+ # port: 9200+ # scheme: https+ # indexName: documents+ # credentialsSecret: opensearch-credentials # keys: username, password++ # External Docling — optional document conversion+ # docling:+ # host: docling-serve.docling.svc.cluster.local+ # port: 5001+ # scheme: http++ networkPolicy:+ enabled: falsediff --git a/kubernetes/operator/config/samples/openrag_v1alpha1_openrag.yaml b/kubernetes/operator/config/samples/openrag_v1alpha1_openrag.yamlindex 78fdccb41..3b497dbb6 100644--- a/kubernetes/operator/config/samples/openrag_v1alpha1_openrag.yaml+++ b/kubernetes/operator/config/samples/openrag_v1alpha1_openrag.yaml@@ -2,10 +2,9 @@ apiVersion: openr.ag/v1alpha1kind: OpenRAGmetadata:name: my-openrag- namespace: default+ namespace: my-tenantspec:- # imagePullSecrets:- # - name: my-registry-secret+ targetNamespace: my-tenantfrontend:image: langflowai/openrag-frontend:latest@@ -26,14 +25,17 @@ spec:limits:cpu: "2"memory: "8Gi"- # envSecret: my-openrag-backend-env # Secret with ".env" key# jwtSigningKeySecret:# name: my-jwt-secret# key: JWT_SIGNING_KEYstorage:enabled: true- size: "10Gi"- # storageClassName: standard+ size: "1Gi"+ # flowIds:+ # chat: ""+ # ingest: ""+ # urlIngest: ""+ # nudges: ""langflow:image: langflowai/openrag-langflow:latest@@ -42,21 +44,36 @@ spec:cpu: "500m"memory: "1Gi"limits:- cpu: "4"- memory: "8Gi"- # envSecret: my-openrag-langflow-env # Secret with ".env" key+ cpu: "1"+ memory: "2Gi"storage:enabled: true- size: "10Gi"- # storageClassName: standard+ size: "1Gi"+ flowsRef: release-saas-0.1 # branch name or commit SHA+ # flowsInitImage: python:3-alpine++ # llm:+ # provider: watsonx+ # model: ibm/granite-3-2-8b-instruct++ # embedding:+ # provider: watsonx+ # model: ibm/granite-embedding-278m-multilingual++ # watsonx:+ # endpoint: https://us-south.ml.cloud.ibm.com+ # projectId: ""+ # apiKeySecret:+ # name: my-watsonx-secret+ # key: WATSONX_API_KEY# External OpenSearch — required unless credentials are in backend envSecret- opensearch:- host: opensearch-coordinating.opensearch.svc.cluster.local- port: 9200- scheme: https- indexName: documents- credentialsSecret: opensearch-credentials # keys: username, password+ # opensearch:+ # host: opensearch-coordinating.opensearch.svc.cluster.local+ # port: 9200+ # scheme: https+ # indexName: documents+ # credentialsSecret: opensearch-credentials # keys: username, password# External Docling — optional document conversion# docling:@@ -64,6 +81,5 @@ spec:# port: 5001# scheme: http- # Create a NetworkPolicy restricting Langflow egressnetworkPolicy:enabled: falsediff --git a/kubernetes/operator/internal/controller/openrag_controller.go b/kubernetes/operator/internal/controller/openrag_controller.goindex cabdbb8d6..6f8fcb744 100644--- a/kubernetes/operator/internal/controller/openrag_controller.go+++ b/kubernetes/operator/internal/controller/openrag_controller.go@@ -2,7 +2,13 @@ package controllerimport ("context"+ "crypto/rand"+ "crypto/sha256"+ "encoding/base64"+ "encoding/hex"+ "encoding/json""fmt"+ "strings"appsv1 "k8s.io/api/apps/v1"corev1 "k8s.io/api/core/v1"@@ -19,7 +25,10 @@ import (openragv1alpha1 "github.com/langflow-ai/openrag-operator/api/v1alpha1")-const finalizer = "openr.ag/namespace-cleanup"+const (+ finalizer = "openr.ag/namespace-cleanup"+ specHashAnnotation = "openr.ag/spec-hash"+)// OpenRAGReconciler reconciles an OpenRAG object.type OpenRAGReconciler struct {@@ -53,12 +62,10 @@ func (r *OpenRAGReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctreturn ctrl.Result{}, err}- // Handle deletion when a TargetNamespace was managed by the operator.if !instance.DeletionTimestamp.IsZero() {return ctrl.Result{}, r.handleDeletion(ctx, instance)}- // Add finalizer when we own a target namespace distinct from the CR namespace.if instance.Spec.TargetNamespace != "" && instance.Spec.TargetNamespace != instance.Namespace {if !controllerutil.ContainsFinalizer(instance, finalizer) {controllerutil.AddFinalizer(instance, finalizer)@@ -76,6 +83,15 @@ func (r *OpenRAGReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctif err := r.reconcileServiceAccounts(ctx, instance, targetNS); err != nil {return ctrl.Result{}, fmt.Errorf("service accounts: %w", err)}+ if err := r.reconcileGeneratedCreds(ctx, instance, targetNS); err != nil {+ return ctrl.Result{}, fmt.Errorf("generated creds: %w", err)+ }+ if err := r.reconcileEnvSecrets(ctx, instance, targetNS); err != nil {+ return ctrl.Result{}, fmt.Errorf("env secrets: %w", err)+ }+ if err := r.reconcilePVCs(ctx, instance, targetNS); err != nil {+ return ctrl.Result{}, fmt.Errorf("pvcs: %w", err)+ }if err := r.reconcileServices(ctx, instance, targetNS); err != nil {return ctrl.Result{}, fmt.Errorf("services: %w", err)}@@ -92,8 +108,6 @@ func (r *OpenRAGReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctreturn ctrl.Result{}, nil}-// handleDeletion removes the target namespace (and all resources within it) when-// the CR is deleted, then strips the finalizer so the CR itself can be removed.func (r *OpenRAGReconciler) handleDeletion(ctx context.Context, o *openragv1alpha1.OpenRAG) error {if !controllerutil.ContainsFinalizer(o, finalizer) {return nil@@ -105,7 +119,6 @@ func (r *OpenRAGReconciler) handleDeletion(ctx context.Context, o *openragv1alphreturn err}if err == nil {- // Only delete if the namespace was created by this operator for this CR.if ns.Labels[managedByLabel] == o.Name {if err := r.Delete(ctx, ns); err != nil && !errors.IsNotFound(err) {return err@@ -117,8 +130,6 @@ func (r *OpenRAGReconciler) handleDeletion(ctx context.Context, o *openragv1alphreturn r.Update(ctx, o)}-// reconcileNamespace ensures the target namespace exists, labelled as managed by-// this CR. It is a no-op when targetNS equals the CR's own namespace.func (r *OpenRAGReconciler) reconcileNamespace(ctx context.Context, o *openragv1alpha1.OpenRAG, targetNS string) error {if targetNS == o.Namespace {return nil@@ -160,6 +171,373 @@ func (r *OpenRAGReconciler) reconcileServiceAccounts(ctx context.Context, o *opereturn nil}+// reconcileGeneratedCreds creates a stable Secret holding auto-generated+// LANGFLOW_SECRET_KEY and OPENRAG_ENCRYPTION_KEY. It is only created once —+// subsequent reconcile loops skip it to preserve the generated values.+func (r *OpenRAGReconciler) reconcileGeneratedCreds(ctx context.Context, o *openragv1alpha1.OpenRAG, targetNS string) error {+ secretName := resourceName(o.Name, "gen-creds")+ existing := &corev1.Secret{}+ err := r.Get(ctx, client.ObjectKey{Name: secretName, Namespace: targetNS}, existing)+ if err == nil {+ return nil // already exists, don't overwrite stable keys+ }+ if !errors.IsNotFound(err) {+ return err+ }++ langflowKey, err := generateKey(32)+ if err != nil {+ return err+ }+ encryptionKey, err := generateKey(32)+ if err != nil {+ return err+ }++ secret := &corev1.Secret{+ ObjectMeta: metav1.ObjectMeta{+ Name: secretName,+ Namespace: targetNS,+ Labels: map[string]string{"app.kubernetes.io/managed-by": "openrag-operator"},+ },+ StringData: map[string]string{+ "LANGFLOW_SECRET_KEY": langflowKey,+ "OPENRAG_ENCRYPTION_KEY": encryptionKey,+ },+ }+ if err := r.setOwnerOrLabel(o, secret, targetNS); err != nil {+ return err+ }+ return r.Create(ctx, secret)+}++// reconcileEnvSecrets creates / updates the backend and Langflow .env Secrets+// from CR fields and fixed runtime defaults.+func (r *OpenRAGReconciler) reconcileEnvSecrets(ctx context.Context, o *openragv1alpha1.OpenRAG, targetNS string) error {+ type envDef struct {+ name string+ content string+ }+ defs := []envDef{+ {resourceName(o.Name, "be-env"), r.buildBackendEnv(o)},+ {resourceName(o.Name, "lf-env"), r.buildLangflowEnv(o)},+ }+ for _, d := range defs {+ secret := &corev1.Secret{+ ObjectMeta: metav1.ObjectMeta{+ Name: d.name,+ Namespace: targetNS,+ Labels: map[string]string{"app.kubernetes.io/managed-by": "openrag-operator"},+ },+ StringData: map[string]string{".env": d.content},+ }+ if err := r.setOwnerOrLabel(o, secret, targetNS); err != nil {+ return err+ }+ if err := r.createOrUpdate(ctx, secret); err != nil {+ return err+ }+ }+ return nil+}++func (r *OpenRAGReconciler) buildBackendEnv(o *openragv1alpha1.OpenRAG) string {+ var b strings.Builder+ w := func(k, v string) { fmt.Fprintf(&b, "%s=%s\n", k, v) }++ // Operator-derived values+ w("LANGFLOW_URL", "http://"+resourceName(o.Name, "lf")+":7860")++ if o.Spec.TenantID != "" {+ w("TENANT_ID", o.Spec.TenantID)+ }++ // Flow IDs+ if f := o.Spec.Backend.FlowIDs; f != nil {+ if f.Chat != "" {+ w("LANGFLOW_CHAT_FLOW_ID", f.Chat)+ }+ if f.Ingest != "" {+ w("LANGFLOW_INGEST_FLOW_ID", f.Ingest)+ }+ if f.URLIngest != "" {+ w("LANGFLOW_URL_INGEST_FLOW_ID", f.URLIngest)+ }+ if f.Nudges != "" {+ w("NUDGES_FLOW_ID", f.Nudges)+ }+ }++ // OpenSearch+ if os := o.Spec.OpenSearch; os != nil {+ w("OPENSEARCH_HOST", os.Host)+ port := os.Port+ if port == 0 {+ port = 9200+ }+ w("OPENSEARCH_PORT", fmt.Sprintf("%d", port))+ scheme := os.Scheme+ if scheme == "" {+ scheme = "https"+ }+ w("OPENSEARCH_URL", fmt.Sprintf("%s://%s:%d", scheme, os.Host, port))+ if os.IndexName != "" {+ w("OPENSEARCH_INDEX_NAME", os.IndexName)+ }+ // Username injected as env var from credentials secret when set;+ // fall back to the common default.+ if os.CredentialsSecret == "" {+ w("OPENSEARCH_USERNAME", "admin")+ }+ }++ // WatsonX non-sensitive fields+ if wx := o.Spec.WatsonX; wx != nil {+ if wx.Endpoint != "" {+ w("WATSONX_ENDPOINT", wx.Endpoint)+ }+ if wx.ProjectID != "" {+ w("WATSONX_PROJECT_ID", wx.ProjectID)+ }+ }++ // LLM / Embedding+ if l := o.Spec.LLM; l != nil {+ if l.Provider != "" {+ w("LLM_PROVIDER", l.Provider)+ }+ if l.Model != "" {+ w("LLM_MODEL", l.Model)+ }+ }+ if e := o.Spec.Embedding; e != nil {+ if e.Provider != "" {+ w("EMBEDDING_PROVIDER", e.Provider)+ }+ if e.Model != "" {+ w("EMBEDDING_MODEL", e.Model)+ }+ }++ // OAuth non-sensitive fields+ if o.Spec.Backend.IBMAuthEnabled {+ w("IBM_AUTH_ENABLED", "true")+ }+ if o.Spec.Backend.OAuthBrokerURL != "" {+ w("OAUTH_BROKER_URL", o.Spec.Backend.OAuthBrokerURL)+ }+ if oa := o.Spec.Backend.OAuth; oa != nil {+ if oa.Google != nil && oa.Google.ClientID != "" {+ w("GOOGLE_OAUTH_CLIENT_ID", oa.Google.ClientID)+ }+ if oa.Microsoft != nil && oa.Microsoft.ClientID != "" {+ w("MICROSOFT_GRAPH_OAUTH_CLIENT_ID", oa.Microsoft.ClientID)+ }+ }++ // Docling+ if d := o.Spec.Docling; d != nil {+ scheme := d.Scheme+ if scheme == "" {+ scheme = "http"+ }+ port := d.Port+ if port == 0 {+ port = 5001+ }+ w("DOCLING_SERVE_URL", fmt.Sprintf("%s://%s:%d", scheme, d.Host, port))+ }++ // Fixed runtime defaults+ w("LANGFLOW_TIMEOUT", "2400")+ w("LANGFLOW_CONNECT_TIMEOUT", "30")+ w("INGESTION_TIMEOUT", "3600")+ w("UPLOAD_BATCH_SIZE", "25")+ w("LANGFLOW_KEY_RETRIES", "15")+ w("LANGFLOW_KEY_RETRY_DELAY", "2")+ w("LANGFLOW_KEY", "")+ w("LANGFLOW_AUTO_LOGIN", "true")+ w("OPENRAG_DATA_PATH", "/app/backend-data")+ w("OPENRAG_DOCUMENTS_PATH", "/app/openrag-documents")+ w("OPENRAG_DOCUMENT_PATH", "/app/openrag-documents")+ w("OPENRAG_FLOWS_BACKUP_PATH", "/app/backend-data/flow-backups")+ w("OPENRAG_KEYS_PATH", "/app/backend-data/keys")+ w("OPENRAG_CONFIG_PATH", "/app/backend-data/config")+ w("OPENRAG_VERSION", "latest")+ w("OPENSEARCH_DATA_PATH", "./opensearch-data")+ w("LOG_LEVEL", "DEBUG")+ w("LOG_FORMAT", "json")+ w("ACCESS_LOG", "true")+ w("SERVICE_NAME", "openrag")+ w("ENVIRONMENT", "development")+ w("INGEST_SAMPLE_DATA", "true")+ w("DISABLE_INGEST_WITH_LANGFLOW", "false")+ w("MAX_WORKERS", "4")+ w("SEGMENT_WRITE_KEY", "kUm1zOjl8CGbtMmEVOtmAaqyIpU7ExFb")++ return b.String()+}++func (r *OpenRAGReconciler) buildLangflowEnv(o *openragv1alpha1.OpenRAG) string {+ var b strings.Builder+ w := func(k, v string) { fmt.Fprintf(&b, "%s=%s\n", k, v) }++ if o.Spec.TenantID != "" {+ w("TENANT_ID", o.Spec.TenantID)+ }++ // OpenSearch+ if os := o.Spec.OpenSearch; os != nil {+ w("OPENSEARCH_HOST", os.Host)+ port := os.Port+ if port == 0 {+ port = 9200+ }+ w("OPENSEARCH_PORT", fmt.Sprintf("%d", port))+ scheme := os.Scheme+ if scheme == "" {+ scheme = "https"+ }+ w("OPENSEARCH_URL", fmt.Sprintf("%s://%s:%d", scheme, os.Host, port))+ if os.IndexName != "" {+ w("OPENSEARCH_INDEX_NAME", os.IndexName)+ }+ }++ // WatsonX non-sensitive fields+ if wx := o.Spec.WatsonX; wx != nil {+ if wx.Endpoint != "" {+ w("WATSONX_ENDPOINT", wx.Endpoint)+ }+ if wx.ProjectID != "" {+ w("WATSONX_PROJECT_ID", wx.ProjectID)+ }+ }++ // LLM / Embedding+ if l := o.Spec.LLM; l != nil {+ if l.Provider != "" {+ w("LLM_PROVIDER", l.Provider)+ }+ if l.Model != "" {+ w("LLM_MODEL", l.Model)+ }+ }+ if e := o.Spec.Embedding; e != nil {+ if e.Provider != "" {+ w("EMBEDDING_PROVIDER", e.Provider)+ }+ if e.Model != "" {+ w("EMBEDDING_MODEL", e.Model)+ }+ }++ // Docling+ if d := o.Spec.Docling; d != nil {+ scheme := d.Scheme+ if scheme == "" {+ scheme = "http"+ }+ port := d.Port+ if port == 0 {+ port = 5001+ }+ w("DOCLING_SERVE_URL", fmt.Sprintf("%s://%s:%d", scheme, d.Host, port))+ }++ // Database URL+ dbURL := o.Spec.Langflow.DatabaseURL+ if dbURL == "" {+ dbURL = "sqlite:////app/data/langflow.db"+ }+ w("LANGFLOW_DATABASE_URL", dbURL)++ // Fixed runtime defaults+ w("LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT", "JWT,OPENRAG_QUERY_FILTER,OPENSEARCH_PASSWORD,OPENSEARCH_URL,OPENSEARCH_INDEX_NAME,DOCLING_SERVE_URL,OWNER,OWNER_NAME,OWNER_EMAIL,CONNECTOR_TYPE,DOCUMENT_ID,SOURCE_URL,ALLOWED_USERS,ALLOWED_GROUPS,FILENAME,MIMETYPE,FILESIZE,SELECTED_EMBEDDING_MODEL,OPENAI_API_KEY,ANTHROPIC_API_KEY,WATSONX_API_KEY,WATSONX_ENDPOINT,WATSONX_PROJECT_ID,OLLAMA_BASE_URL")+ w("LANGFLOW_SKIP_AUTH_AUTO_LOGIN", "true")+ w("LANGFLOW_NEW_USER_IS_ACTIVE", "false")+ w("LANGFLOW_WORKERS", "4")+ w("LANGFLOW_CONFIG_DIR", "/tmp")+ w("LANGFLOW_LOG_LEVEL", "DEBUG")+ w("HIDE_GETTING_STARTED_PROGRESS", "true")+ w("LANGFLOW_AUTO_LOGIN", "true")+ w("LANGFLOW_ENABLE_SUPERUSER_CLI", "false")+ w("LANGFLOW_ALEMBIC_LOG_TO_STDOUT", "true")+ w("LANGFLOW_DEACTIVATE_TRACING", "true")+ w("LANGFLOW_LOAD_FLOWS_PATH", "/app/flows")+ w("LANGFUSE_HOST", "https://cloud.langfuse.com")+ w("LANGFLOW_KEY_RETRIES", "15")+ w("LANGFLOW_KEY_RETRY_DELAY", "2")+ // Flow context defaults+ w("JWT", "None")+ w("OWNER", "None")+ w("OWNER_NAME", "None")+ w("OWNER_EMAIL", "None")+ w("CONNECTOR_TYPE", "system")+ w("CONNECTOR_TYPE_URL", "url")+ w("DOCUMENT_ID", "")+ w("SOURCE_URL", "")+ w("ALLOWED_USERS", "[]")+ w("ALLOWED_GROUPS", "[]")+ w("OPENRAG_QUERY_FILTER", "{}")+ w("FILENAME", "None")+ w("MIMETYPE", "None")+ w("FILESIZE", "0")+ w("SELECTED_EMBEDDING_MODEL", "")+ w("OPENAI_API_KEY", "None")+ w("ANTHROPIC_API_KEY", "None")+ w("OLLAMA_BASE_URL", "None")++ return b.String()+}++func (r *OpenRAGReconciler) reconcilePVCs(ctx context.Context, o *openragv1alpha1.OpenRAG, targetNS string) error {+ type pvcDef struct {+ name string+ storage *openragv1alpha1.PersistenceSpec+ }+ defs := []pvcDef{+ {resourceName(o.Name, "lf-data"), o.Spec.Langflow.Storage},+ {resourceName(o.Name, "be-data"), o.Spec.Backend.Storage},+ }+ for _, d := range defs {+ if d.storage == nil || !d.storage.Enabled || d.storage.ExistingClaim != "" {+ continue+ }+ pvc := &corev1.PersistentVolumeClaim{+ ObjectMeta: metav1.ObjectMeta{+ Name: d.name,+ Namespace: targetNS,+ Labels: map[string]string{"app.kubernetes.io/managed-by": "openrag-operator"},+ },+ Spec: corev1.PersistentVolumeClaimSpec{+ AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},+ StorageClassName: d.storage.StorageClassName,+ Resources: corev1.VolumeResourceRequirements{+ Requests: corev1.ResourceList{+ corev1.ResourceStorage: d.storage.Size,+ },+ },+ },+ }+ if err := r.setOwnerOrLabel(o, pvc, targetNS); err != nil {+ return err+ }+ // PVCs are immutable once bound — only create, never update.+ existing := &corev1.PersistentVolumeClaim{}+ if err := r.Get(ctx, client.ObjectKeyFromObject(pvc), existing); err != nil {+ if errors.IsNotFound(err) {+ if err := r.Create(ctx, pvc); err != nil {+ return err+ }+ } else {+ return err+ }+ }+ }+ return nil+}+func (r *OpenRAGReconciler) reconcileServices(ctx context.Context, o *openragv1alpha1.OpenRAG, targetNS string) error {type svcDef struct {role string@@ -257,28 +635,38 @@ func (r *OpenRAGReconciler) backendDeployment(o *openragv1alpha1.OpenRAG, targetspec := o.Spec.Backendreplicas := replicasOrDefault(spec.Replicas)- var volumes []corev1.Volume- var mounts []corev1.VolumeMount-- mounts = append(mounts, corev1.VolumeMount{Name: "backend-temp", MountPath: "/tmp"})- volumes = append(volumes, corev1.Volume{- Name: "backend-temp",- VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},- })+ volumes := []corev1.Volume{+ {+ Name: "backend-temp",+ VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},+ },+ {+ Name: "backend-env",+ VolumeSource: corev1.VolumeSource{+ Secret: &corev1.SecretVolumeSource{SecretName: resourceName(o.Name, "be-env")},+ },+ },+ }+ mounts := []corev1.VolumeMount{+ {Name: "backend-temp", MountPath: "/tmp"},+ {Name: "backend-env", MountPath: "/app/.env", SubPath: ".env", ReadOnly: true},+ }- if spec.EnvSecret != "" {+ if spec.Storage != nil && spec.Storage.Enabled {+ pvcName := resourceName(o.Name, "be-data")+ if spec.Storage.ExistingClaim != "" {+ pvcName = spec.Storage.ExistingClaim+ }volumes = append(volumes, corev1.Volume{- Name: "backend-env",+ Name: "backend-data",VolumeSource: corev1.VolumeSource{- Secret: &corev1.SecretVolumeSource{SecretName: spec.EnvSecret},+ PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ClaimName: pvcName},},})- mounts = append(mounts, corev1.VolumeMount{- Name: "backend-env", MountPath: "/app/.env", SubPath: ".env", ReadOnly: true,- })+ mounts = append(mounts, corev1.VolumeMount{Name: "backend-data", MountPath: "/app/backend-data"})}- var envVars []corev1.EnvVar+ envVars := r.backendSensitiveEnvVars(o)if spec.JWTSigningKeySecret != nil {envVars = append(envVars, corev1.EnvVar{Name: "JWT_SIGNING_KEY",@@ -325,29 +713,82 @@ func (r *OpenRAGReconciler) backendDeployment(o *openragv1alpha1.OpenRAG, target}}+// backendSensitiveEnvVars returns env vars sourced from Secrets for the backend pod.+// These override any matching keys in the mounted .env file.+func (r *OpenRAGReconciler) backendSensitiveEnvVars(o *openragv1alpha1.OpenRAG) []corev1.EnvVar {+ genCreds := resourceName(o.Name, "gen-creds")+ var ev []corev1.EnvVar++ // LANGFLOW_SECRET_KEY+ if o.Spec.Langflow.SecretKeySecret != nil {+ ev = append(ev, secretEnvVar("LANGFLOW_SECRET_KEY", o.Spec.Langflow.SecretKeySecret))+ } else {+ ev = append(ev, secretEnvVar("LANGFLOW_SECRET_KEY", &corev1.SecretKeySelector{+ LocalObjectReference: corev1.LocalObjectReference{Name: genCreds},+ Key: "LANGFLOW_SECRET_KEY",+ }))+ }++ // OPENRAG_ENCRYPTION_KEY+ if o.Spec.Backend.EncryptionKeySecret != nil {+ ev = append(ev, secretEnvVar("OPENRAG_ENCRYPTION_KEY", o.Spec.Backend.EncryptionKeySecret))+ } else {+ ev = append(ev, secretEnvVar("OPENRAG_ENCRYPTION_KEY", &corev1.SecretKeySelector{+ LocalObjectReference: corev1.LocalObjectReference{Name: genCreds},+ Key: "OPENRAG_ENCRYPTION_KEY",+ }))+ }++ // OpenSearch credentials+ if o.Spec.OpenSearch != nil && o.Spec.OpenSearch.CredentialsSecret != "" {+ cred := o.Spec.OpenSearch.CredentialsSecret+ ev = append(ev,+ secretEnvVar("OPENSEARCH_USERNAME", &corev1.SecretKeySelector{+ LocalObjectReference: corev1.LocalObjectReference{Name: cred}, Key: "username",+ }),+ secretEnvVar("OPENSEARCH_PASSWORD", &corev1.SecretKeySelector{+ LocalObjectReference: corev1.LocalObjectReference{Name: cred}, Key: "password",+ }),+ )+ }++ // WatsonX API key+ if o.Spec.WatsonX != nil && o.Spec.WatsonX.APIKeySecret != nil {+ ev = append(ev, secretEnvVar("WATSONX_API_KEY", o.Spec.WatsonX.APIKeySecret))+ }++ // OAuth secrets+ if oa := o.Spec.Backend.OAuth; oa != nil {+ if oa.Google != nil && oa.Google.ClientSecret != nil {+ ev = append(ev, secretEnvVar("GOOGLE_OAUTH_CLIENT_SECRET", oa.Google.ClientSecret))+ }+ if oa.Microsoft != nil && oa.Microsoft.ClientSecret != nil {+ ev = append(ev, secretEnvVar("MICROSOFT_GRAPH_OAUTH_CLIENT_SECRET", oa.Microsoft.ClientSecret))+ }+ }++ return ev+}+func (r *OpenRAGReconciler) langflowDeployment(o *openragv1alpha1.OpenRAG, targetNS string) *appsv1.Deployment {spec := o.Spec.Langflowreplicas := replicasOrDefault(spec.Replicas)- var volumes []corev1.Volume- var mounts []corev1.VolumeMount-- mounts = append(mounts, corev1.VolumeMount{Name: "langflow-temp", MountPath: "/tmp"})- volumes = append(volumes, corev1.Volume{- Name: "langflow-temp",- VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},- })-- if spec.EnvSecret != "" {- volumes = append(volumes, corev1.Volume{+ volumes := []corev1.Volume{+ {+ Name: "langflow-temp",+ VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},+ },+ {Name: "langflow-env",VolumeSource: corev1.VolumeSource{- Secret: &corev1.SecretVolumeSource{SecretName: spec.EnvSecret},+ Secret: &corev1.SecretVolumeSource{SecretName: resourceName(o.Name, "lf-env")},},- })- mounts = append(mounts, corev1.VolumeMount{- Name: "langflow-env", MountPath: "/app/.env", SubPath: ".env", ReadOnly: true,- })+ },+ }+ mounts := []corev1.VolumeMount{+ {Name: "langflow-temp", MountPath: "/tmp"},+ {Name: "langflow-env", MountPath: "/app/.env", SubPath: ".env", ReadOnly: true},}if spec.Storage != nil && spec.Storage.Enabled {@@ -364,6 +805,36 @@ func (r *OpenRAGReconciler) langflowDeployment(o *openragv1alpha1.OpenRAG, targemounts = append(mounts, corev1.VolumeMount{Name: "langflow-data", MountPath: "/app/data"})}+ var initContainers []corev1.Container+ if spec.FlowsRef != "" {+ volumes = append(volumes, corev1.Volume{+ Name: "langflow-flows",+ VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},+ })+ mounts = append(mounts, corev1.VolumeMount{Name: "langflow-flows", MountPath: "/app/flows"})++ initImage := spec.FlowsInitImage+ if initImage == "" {+ initImage = "python:3-alpine"+ }+ initContainers = []corev1.Container{+ {+ Name: "download-flows",+ Image: initImage,+ Command: []string{"python3", "-c", flowsDownloadScript},+ Env: []corev1.EnvVar{+ {Name: "FLOWS_REF", Value: spec.FlowsRef},+ },+ VolumeMounts: []corev1.VolumeMount{+ {Name: "langflow-flows", MountPath: "/app/flows"},+ },+ },+ }+ }++ envVars := r.langflowSensitiveEnvVars(o)+ envVars = append(envVars, spec.Env...)+return &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: resourceName(o.Name, "lf"),@@ -382,6 +853,7 @@ func (r *OpenRAGReconciler) langflowDeployment(o *openragv1alpha1.OpenRAG, targeNodeSelector: spec.NodeSelector,Tolerations: spec.Tolerations,Affinity: spec.Affinity,+ InitContainers: initContainers,Volumes: volumes,Containers: []corev1.Container{{@@ -391,11 +863,11 @@ func (r *OpenRAGReconciler) langflowDeployment(o *openragv1alpha1.OpenRAG, targeArgs: []string{"run", "--env-file", "/app/.env"},Command: []string{"langflow"},Ports: []corev1.ContainerPort{{Name: "http", ContainerPort: 7860}},- Env: spec.Env,+ Env: envVars,Resources: spec.Resources,VolumeMounts: mounts,- LivenessProbe: httpProbe("/health", 7860, 120, 30),- ReadinessProbe: httpProbe("/health", 7860, 120, 30),+ LivenessProbe: httpProbe("/health", 7860, 90, 30),+ ReadinessProbe: httpProbe("/health", 7860, 90, 30),},},},@@ -404,6 +876,42 @@ func (r *OpenRAGReconciler) langflowDeployment(o *openragv1alpha1.OpenRAG, targe}}+// langflowSensitiveEnvVars returns env vars sourced from Secrets for the Langflow pod.+func (r *OpenRAGReconciler) langflowSensitiveEnvVars(o *openragv1alpha1.OpenRAG) []corev1.EnvVar {+ genCreds := resourceName(o.Name, "gen-creds")+ var ev []corev1.EnvVar++ // LANGFLOW_SECRET_KEY+ if o.Spec.Langflow.SecretKeySecret != nil {+ ev = append(ev, secretEnvVar("LANGFLOW_SECRET_KEY", o.Spec.Langflow.SecretKeySecret))+ } else {+ ev = append(ev, secretEnvVar("LANGFLOW_SECRET_KEY", &corev1.SecretKeySelector{+ LocalObjectReference: corev1.LocalObjectReference{Name: genCreds},+ Key: "LANGFLOW_SECRET_KEY",+ }))+ }++ // OpenSearch credentials+ if o.Spec.OpenSearch != nil && o.Spec.OpenSearch.CredentialsSecret != "" {+ cred := o.Spec.OpenSearch.CredentialsSecret+ ev = append(ev,+ secretEnvVar("OPENSEARCH_USERNAME", &corev1.SecretKeySelector{+ LocalObjectReference: corev1.LocalObjectReference{Name: cred}, Key: "username",+ }),+ secretEnvVar("OPENSEARCH_PASSWORD", &corev1.SecretKeySelector{+ LocalObjectReference: corev1.LocalObjectReference{Name: cred}, Key: "password",+ }),+ )+ }++ // WatsonX API key+ if o.Spec.WatsonX != nil && o.Spec.WatsonX.APIKeySecret != nil {+ ev = append(ev, secretEnvVar("WATSONX_API_KEY", o.Spec.WatsonX.APIKeySecret))+ }++ return ev+}+func (r *OpenRAGReconciler) reconcileNetworkPolicy(ctx context.Context, o *openragv1alpha1.OpenRAG, targetNS string) error {labels := componentLabels(o.Name, "lf")@@ -447,9 +955,6 @@ func (r *OpenRAGReconciler) reconcileNetworkPolicy(ctx context.Context, o *openrreturn r.createOrUpdate(ctx, np)}-// setOwnerOrLabel sets a controller owner reference when the resource lives in the-// same namespace as the CR. For cross-namespace resources it falls back to a label-// since Kubernetes forbids cross-namespace owner references.func (r *OpenRAGReconciler) setOwnerOrLabel(o *openragv1alpha1.OpenRAG, obj client.Object, targetNS string) error {if targetNS == o.Namespace {return ctrl.SetControllerReference(o, obj, r.Scheme)@@ -464,18 +969,83 @@ func (r *OpenRAGReconciler) setOwnerOrLabel(o *openragv1alpha1.OpenRAG, obj clie}func (r *OpenRAGReconciler) createOrUpdate(ctx context.Context, obj client.Object) error {- existing := obj.DeepCopyObject().(client.Object)- err := r.Get(ctx, client.ObjectKeyFromObject(obj), existing)- if errors.IsNotFound(err) {- return r.Create(ctx, obj)- }+ hash, err := desiredHash(obj)if err != nil {return err}+ setAnnotation(obj, specHashAnnotation, hash)++ existing := obj.DeepCopyObject().(client.Object)+ if err := r.Get(ctx, client.ObjectKeyFromObject(obj), existing); err != nil {+ if errors.IsNotFound(err) {+ return r.Create(ctx, obj)+ }+ return err+ }++ if existing.GetAnnotations()[specHashAnnotation] == hash {+ return nil+ }+obj.SetResourceVersion(existing.GetResourceVersion())return r.Update(ctx, obj)}+func desiredHash(obj client.Object) (string, error) {+ tmp := obj.DeepCopyObject().(client.Object)+ tmp.SetResourceVersion("")+ tmp.SetUID("")+ tmp.SetGeneration(0)+ ann := tmp.GetAnnotations()+ if ann != nil {+ delete(ann, specHashAnnotation)+ if len(ann) == 0 {+ ann = nil+ }+ tmp.SetAnnotations(ann)+ }+ data, err := json.Marshal(tmp)+ if err != nil {+ return "", err+ }+ sum := sha256.Sum256(data)+ return hex.EncodeToString(sum[:])[:16], nil+}++func setAnnotation(obj client.Object, key, value string) {+ ann := obj.GetAnnotations()+ if ann == nil {+ ann = make(map[string]string)+ }+ ann[key] = value+ obj.SetAnnotations(ann)+}++// flowsDownloadScript is run by the init container to fetch all *.json flow+// files from the langflow-ai/openrag GitHub repository at the given ref.+// It uses only Python stdlib so that python:3-alpine suffices.+const flowsDownloadScript = `+import urllib.request, json, os+ref = os.environ['FLOWS_REF']+api = 'https://api.github.com/repos/langflow-ai/openrag/contents/flows?ref=' + ref+req = urllib.request.Request(api, headers={+ 'Accept': 'application/vnd.github.v3+json',+ 'User-Agent': 'openrag-operator/1.0',+})+with urllib.request.urlopen(req) as r:+ entries = json.load(r)+os.makedirs('/app/flows', exist_ok=True)+for e in entries:+ if not e['name'].endswith('.json'):+ continue+ print('Downloading ' + e['name'] + '...', flush=True)+ with urllib.request.urlopen(e['download_url']) as r:+ data = r.read()+ with open('/app/flows/' + e['name'], 'wb') as f:+ f.write(data)+print('All flows downloaded', flush=True)+`+// SetupWithManager registers the controller with the manager.func (r *OpenRAGReconciler) SetupWithManager(mgr ctrl.Manager) error {return ctrl.NewControllerManagedBy(mgr).@@ -483,6 +1053,7 @@ func (r *OpenRAGReconciler) SetupWithManager(mgr ctrl.Manager) error {Owns(&appsv1.Deployment{}).Owns(&corev1.Service{}).Owns(&corev1.ServiceAccount{}).+ Owns(&corev1.Secret{}).Owns(&networkingv1.NetworkPolicy{}).Complete(r)}@@ -550,3 +1121,18 @@ func udpPort(p int32) networkingv1.NetworkPolicyPort {v := intstr.FromInt32(p)return networkingv1.NetworkPolicyPort{Port: &v, Protocol: &proto}}++func secretEnvVar(name string, sel *corev1.SecretKeySelector) corev1.EnvVar {+ return corev1.EnvVar{+ Name: name,+ ValueFrom: &corev1.EnvVarSource{SecretKeyRef: sel},+ }+}++func generateKey(n int) (string, error) {+ b := make([]byte, n)+ if _, err := rand.Read(b); err != nil {+ return "", err+ }+ return base64.URLEncoding.EncodeToString(b), nil+}diff --git a/kubernetes/operator/internal/controller/openrag_controller_test.go b/kubernetes/operator/internal/controller/openrag_controller_test.goindex 2e68858c5..130c11de6 100644--- a/kubernetes/operator/internal/controller/openrag_controller_test.go+++ b/kubernetes/operator/internal/controller/openrag_controller_test.go@@ -180,10 +180,9 @@ func TestReconcile_FrontendEnvContainsBackendHost(t *testing.T) {assert.Equal(t, resourceName(cr.Name, "be"), backendHost)}-func TestReconcile_BackendMountsEnvSecret(t *testing.T) {+func TestReconcile_BackendMountsOperatorManagedEnvSecret(t *testing.T) {s := newScheme(t)cr := minimalCR("my-openrag", "my-ns")- cr.Spec.Backend.EnvSecret = "my-backend-secret"r, c := reconciler(s, cr)reconcileOnce(t, r, cr)@@ -192,14 +191,50 @@ func TestReconcile_BackendMountsEnvSecret(t *testing.T) {require.NoError(t, c.Get(context.Background(),types.NamespacedName{Name: resourceName(cr.Name, "be"), Namespace: "my-ns"}, d))+ expectedSecret := resourceName(cr.Name, "be-env")var found boolfor _, v := range d.Spec.Template.Spec.Volumes {if v.Name == "backend-env" {- assert.Equal(t, "my-backend-secret", v.Secret.SecretName)+ assert.Equal(t, expectedSecret, v.Secret.SecretName)found = true}}- assert.True(t, found, "backend-env volume should exist")+ assert.True(t, found, "backend-env volume should exist with operator-managed secret")+}++func TestReconcile_CreatesEnvSecrets(t *testing.T) {+ s := newScheme(t)+ cr := minimalCR("my-openrag", "my-ns")+ r, c := reconciler(s, cr)++ reconcileOnce(t, r, cr)++ for _, role := range []string{"be-env", "lf-env", "gen-creds"} {+ sec := &corev1.Secret{}+ require.NoError(t, c.Get(context.Background(),+ types.NamespacedName{Name: resourceName(cr.Name, role), Namespace: "my-ns"}, sec),+ "secret for role %s should exist", role)+ }+}++func TestReconcile_BackendEnvContainsLangflowURL(t *testing.T) {+ s := newScheme(t)+ cr := minimalCR("my-openrag", "my-ns")+ r, c := reconciler(s, cr)++ reconcileOnce(t, r, cr)++ sec := &corev1.Secret{}+ require.NoError(t, c.Get(context.Background(),+ types.NamespacedName{Name: resourceName(cr.Name, "be-env"), Namespace: "my-ns"}, sec))++ // In the test environment, StringData is not converted to Data+ // Use StringData if Data is empty (test env), otherwise use Data (real cluster)+ envContent := string(sec.Data[".env"])+ if envContent == "" && sec.StringData != nil {+ envContent = sec.StringData[".env"]+ }+ assert.Contains(t, envContent, "LANGFLOW_URL=http://"+resourceName(cr.Name, "lf")+":7860")}func TestReconcile_LangflowMountsPVC(t *testing.T) {