Skip to content

Commit 596a716

Browse files
committed
service account and service in CRD
1 parent 1b8b473 commit 596a716

5 files changed

Lines changed: 481 additions & 147 deletions

File tree

kubernetes/operator/api/v1alpha1/openrag_types.go

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,46 +47,60 @@ type ComponentSpec struct {
4747
// Labels are custom labels to add to the Deployment/StatefulSet object metadata.
4848
// These labels appear on the workload resource itself, not the pods.
4949
// Useful for querying and grouping Deployment/StatefulSet objects.
50-
// Label keys must be valid Kubernetes label keys: optional prefix (DNS subdomain) + name.
51-
// Label values must be 63 characters or less, alphanumeric with '-', '_', '.'.
5250
// +optional
5351
// +kubebuilder:validation:MaxProperties=64
54-
// +kubebuilder:validation:XValidation:rule="self.all(key, size(key) <= 253 && (key.contains('/') ? key.split('/')[0].matches('^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$') && key.split('/')[1].matches('^([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9]$') : key.matches('^([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9]$')))",message="label keys must be valid Kubernetes label keys (prefix/name or name)"
55-
// +kubebuilder:validation:XValidation:rule="self.all(key, size(self[key]) <= 63 && self[key].matches('^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$'))",message="label values must be 63 characters or less and match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$"
5652
Labels map[string]string `json:"labels,omitempty"`
5753

5854
// Annotations are custom annotations to add to the Deployment/StatefulSet object metadata.
5955
// These annotations appear on the workload resource itself, not the pods.
6056
// Useful for GitOps metadata, deployment tracking, and automation tools.
61-
// Annotation keys must be valid Kubernetes annotation keys: optional prefix (DNS subdomain) + name.
62-
// Annotation values can be arbitrary strings.
6357
// +optional
6458
// +kubebuilder:validation:MaxProperties=64
65-
// +kubebuilder:validation:XValidation:rule="self.all(key, size(key) <= 253 && (key.contains('/') ? key.split('/')[0].matches('^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$') && key.split('/')[1].matches('^([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9]$') : key.matches('^([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9]$')))",message="annotation keys must be valid Kubernetes annotation keys (prefix/name or name)"
6659
Annotations map[string]string `json:"annotations,omitempty"`
6760

6861
// PodLabels are custom labels to add to the pod template.
6962
// These labels appear on the actual pods created by the Deployment/StatefulSet.
7063
// Useful for pod selectors, monitoring queries, network policies, and service mesh.
7164
// Merged with operator-managed labels (app.kubernetes.io/*).
7265
// Cannot override operator-managed labels.
73-
// Label keys must be valid Kubernetes label keys: optional prefix (DNS subdomain) + name.
74-
// Label values must be 63 characters or less, alphanumeric with '-', '_', '.'.
7566
// +optional
7667
// +kubebuilder:validation:MaxProperties=64
77-
// +kubebuilder:validation:XValidation:rule="self.all(key, size(key) <= 253 && (key.contains('/') ? key.split('/')[0].matches('^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$') && key.split('/')[1].matches('^([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9]$') : key.matches('^([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9]$')))",message="label keys must be valid Kubernetes label keys (prefix/name or name)"
78-
// +kubebuilder:validation:XValidation:rule="self.all(key, size(self[key]) <= 63 && self[key].matches('^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$'))",message="label values must be 63 characters or less and match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$"
7968
PodLabels map[string]string `json:"podLabels,omitempty"`
8069

8170
// PodAnnotations are custom annotations to add to the pod template.
8271
// These annotations appear on the actual pods created by the Deployment/StatefulSet.
8372
// Useful for sidecar injection (Istio, Vault), monitoring (Prometheus), and backup (Velero).
84-
// Annotation keys must be valid Kubernetes annotation keys: optional prefix (DNS subdomain) + name.
85-
// Annotation values can be arbitrary strings.
8673
// +optional
8774
// +kubebuilder:validation:MaxProperties=64
88-
// +kubebuilder:validation:XValidation:rule="self.all(key, size(key) <= 253 && (key.contains('/') ? key.split('/')[0].matches('^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$') && key.split('/')[1].matches('^([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9]$') : key.matches('^([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9]$')))",message="annotation keys must be valid Kubernetes annotation keys (prefix/name or name)"
8975
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
76+
77+
// ServiceAccountName is the name of the ServiceAccount to use for this component's pod.
78+
// When CreateServiceAccount is true, the operator will create a ServiceAccount with this name.
79+
// When CreateServiceAccount is false, the ServiceAccount must already exist in the target namespace.
80+
// If not specified, defaults to "openrag-{role}" (e.g., "openrag-fe", "openrag-be", "openrag-lf").
81+
// +optional
82+
ServiceAccountName string `json:"serviceAccountName,omitempty"`
83+
84+
// CreateServiceAccount indicates whether the operator should create the ServiceAccount.
85+
// If true (default), the operator creates a ServiceAccount with the name specified in ServiceAccountName.
86+
// If false, the operator assumes the ServiceAccount already exists and will only reference it.
87+
// +optional
88+
// +kubebuilder:default=true
89+
CreateServiceAccount *bool `json:"createServiceAccount,omitempty"`
90+
91+
// ServiceName is the name of the Service to use for this component.
92+
// When CreateService is true, the operator will create a Service with this name.
93+
// When CreateService is false, the Service must already exist in the target namespace.
94+
// If not specified, defaults to "openrag-{role}" (e.g., "openrag-fe", "openrag-be", "openrag-lf").
95+
// +optional
96+
ServiceName string `json:"serviceName,omitempty"`
97+
98+
// CreateService indicates whether the operator should create the Service.
99+
// If true (default), the operator creates a Service with the name specified in ServiceName.
100+
// If false, the operator assumes the Service already exists and will only reference it.
101+
// +optional
102+
// +kubebuilder:default=true
103+
CreateService *bool `json:"createService,omitempty"`
90104
}
91105

92106
// FrontendSpec configures the OpenRAG frontend (Next.js).

kubernetes/operator/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)