Skip to content

Commit 1f15d73

Browse files
authored
Merge pull request #29 from slauger/feature/pool-refactoring
refactor: move pool membership to Server poolRefs
2 parents de99c2a + 82b5af4 commit 1f15d73

30 files changed

Lines changed: 148 additions & 189 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ graph TD
5151
CN_D -->|mounts| Code
5252
```
5353

54-
A **Config** is the root resource - it holds shared configuration (puppet.conf, PuppetDB connection), manages code deployment, and references a **CertificateAuthority** via `authorityRef`. A **CertificateAuthority** initializes the CA infrastructure and periodically refreshes the CRL. Each **Certificate** is signed by the CA and stored as a Kubernetes Secret. A **Server** references a Certificate and creates a Deployment - it can run as CA, catalog server, or both. **Pools** create Services that select Server pods by label, with optional Gateway API TLSRoute for SNI-based routing.
54+
A **Config** is the root resource - it holds shared configuration (puppet.conf, PuppetDB connection), manages code deployment, and references a **CertificateAuthority** via `authorityRef`. A **CertificateAuthority** initializes the CA infrastructure and periodically refreshes the CRL. Each **Certificate** is signed by the CA and stored as a Kubernetes Secret. A **Server** references a Certificate and creates a Deployment - it can run as CA, catalog server, or both. Servers declare pool membership via `poolRefs`. **Pools** are pure networking resources that create Services selecting Server pods by pool label, with optional Gateway API TLSRoute for SNI-based routing.
5555

5656
Puppet code is mounted into Server pods via **OCI image volumes** (immutable, automatic rollout on image change, K8s 1.31+) or a **PVC** (mutable, externally managed). See [Code Deployment](docs/concepts/code-deployment.md) for details.
5757

@@ -111,8 +111,8 @@ All resources use the API group `openvox.voxpupuli.org/v1alpha1`.
111111
| **`SigningPolicy`** | Declarative CSR signing policy (any, pattern, DNS SANs, CSR attributes) | *(rendered into Config's autosign Secret)* |
112112
| **`NodeClassifier`** | External Node Classifier (ENC) endpoint (Foreman, PE, custom HTTP) | *(rendered into Config's ENC Secret)* |
113113
| **`Certificate`** | Lifecycle of a single certificate (request, sign) | TLS Secret |
114-
| **`Server`** | OpenVox Server instance pool (CA and/or server role) | Deployment |
115-
| **`Pool`** | Service + optional Gateway API TLSRoute for Server Pods | Service, TLSRoute (optional) |
114+
| **`Server`** | OpenVox Server instance pool (CA and/or server role), declares pool membership via `poolRefs` | Deployment |
115+
| **`Pool`** | Networking resource: Service + optional Gateway API TLSRoute for Servers that reference this Pool | Service, TLSRoute (optional) |
116116

117117
### Planned (not yet implemented)
118118

api/v1alpha1/config_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ type GraphiteSpec struct {
219219

220220
// CodeSpec defines the source of Puppet code to mount into Server pods.
221221
// Either ClaimName (PVC) or Image (OCI image volume) may be set, not both.
222-
// +kubebuilder:validation:XValidation:rule="!(has(self.image) && self.image != '' && has(self.claimName) && self.claimName != '')",message="image and claimName are mutually exclusive"
223-
// +kubebuilder:validation:XValidation:rule="(has(self.image) && self.image != '') || (has(self.claimName) && self.claimName != '')",message="either image or claimName must be set"
222+
// +kubebuilder:validation:XValidation:rule="!(has(self.image) && size(self.image) > 0 && has(self.claimName) && size(self.claimName) > 0)",message="image and claimName are mutually exclusive"
223+
// +kubebuilder:validation:XValidation:rule="(has(self.image) && size(self.image) > 0) || (has(self.claimName) && size(self.claimName) > 0)",message="either image or claimName must be set"
224224
type CodeSpec struct {
225225
// ClaimName references an existing PVC containing Puppet code.
226226
// Mutually exclusive with Image.

api/v1alpha1/nodeclassifier_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type NodeClassifierSpec struct {
5858

5959
// NodeClassifierRequest defines the HTTP request to the classifier.
6060
// +kubebuilder:validation:XValidation:rule="self.method == 'GET' || self.method == 'POST'",message="method must be GET or POST"
61-
// +kubebuilder:validation:XValidation:rule="self.method == 'POST' || !has(self.body) || self.body == ''",message="body is only allowed with POST method"
61+
// +kubebuilder:validation:XValidation:rule="self.method == 'POST' || !has(self.body) || size(self.body) == 0",message="body is only allowed with POST method"
6262
type NodeClassifierRequest struct {
6363
// Method is the HTTP method (GET or POST).
6464
// +kubebuilder:default="GET"

api/v1alpha1/pool_types.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import (
77

88
// +kubebuilder:object:root=true
99
// +kubebuilder:subresource:status
10-
// +kubebuilder:printcolumn:name="Config",type=string,JSONPath=`.spec.configRef`
1110
// +kubebuilder:printcolumn:name="Type",type=string,JSONPath=`.spec.service.type`
1211
// +kubebuilder:printcolumn:name="Endpoints",type=integer,JSONPath=`.status.endpoints`
1312
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
1413

1514
// Pool is the Schema for the pools API.
16-
// It owns a Kubernetes Service that selects Server Pods matching the Pool's Selector.
15+
// It owns a Kubernetes Service that selects Server Pods whose poolRefs include this Pool.
1716
type Pool struct {
1817
metav1.TypeMeta `json:",inline"`
1918
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -33,15 +32,6 @@ type PoolList struct {
3332

3433
// PoolSpec defines the desired state of Pool.
3534
type PoolSpec struct {
36-
// ConfigRef references the Config this Pool belongs to.
37-
ConfigRef string `json:"configRef"`
38-
39-
// Selector is a set of labels used to select Server Pods for this Pool's Service.
40-
// The config label is always added automatically.
41-
// If empty or nil, the Pool selects all Server Pods in the Config.
42-
// +optional
43-
Selector map[string]string `json:"selector,omitempty"`
44-
4535
// Service defines the Kubernetes Service configuration.
4636
// +optional
4737
Service PoolServiceSpec `json:"service,omitempty"`

api/v1alpha1/server_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ type ServerSpec struct {
4040
// CertificateRef references the Certificate whose SSL Secret is mounted into the Server pods.
4141
CertificateRef string `json:"certificateRef"`
4242

43+
// PoolRefs lists the Pools this Server joins.
44+
// The Server controller adds a pool label for each entry, making the pod
45+
// selectable by the corresponding Pool's Service.
46+
// +optional
47+
PoolRefs []string `json:"poolRefs,omitempty"`
48+
4349
// Image overrides the Config's default image.
4450
// +optional
4551
Image ImageSpec `json:"image,omitempty"`

api/v1alpha1/zz_generated.deepcopy.go

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

charts/openvox-operator/crds/openvox.voxpupuli.org_configs.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ spec:
8484
type: object
8585
x-kubernetes-validations:
8686
- message: image and claimName are mutually exclusive
87-
rule: '!(has(self.image) && self.image != '''' && has(self.claimName)
88-
&& self.claimName != '''')'
87+
rule: '!(has(self.image) && size(self.image) > 0 && has(self.claimName)
88+
&& size(self.claimName) > 0)'
8989
- message: either image or claimName must be set
90-
rule: (has(self.image) && self.image != '') || (has(self.claimName)
91-
&& self.claimName != '')
90+
rule: (has(self.image) && size(self.image) > 0) || (has(self.claimName)
91+
&& size(self.claimName) > 0)
9292
image:
9393
description: Image defines the default container image for all Servers
9494
in this Config.

charts/openvox-operator/crds/openvox.voxpupuli.org_nodeclassifiers.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ spec:
188188
- message: method must be GET or POST
189189
rule: self.method == 'GET' || self.method == 'POST'
190190
- message: body is only allowed with POST method
191-
rule: self.method == 'POST' || !has(self.body) || self.body == ''
191+
rule: self.method == 'POST' || !has(self.body) || size(self.body)
192+
== 0
192193
response:
193194
description: Response defines how to interpret the classifier response.
194195
properties:

charts/openvox-operator/crds/openvox.voxpupuli.org_pools.yaml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ spec:
1515
scope: Namespaced
1616
versions:
1717
- additionalPrinterColumns:
18-
- jsonPath: .spec.configRef
19-
name: Config
20-
type: string
2118
- jsonPath: .spec.service.type
2219
name: Type
2320
type: string
@@ -32,7 +29,7 @@ spec:
3229
openAPIV3Schema:
3330
description: |-
3431
Pool is the Schema for the pools API.
35-
It owns a Kubernetes Service that selects Server Pods matching the Pool's Selector.
32+
It owns a Kubernetes Service that selects Server Pods whose poolRefs include this Pool.
3633
properties:
3734
apiVersion:
3835
description: |-
@@ -54,9 +51,6 @@ spec:
5451
spec:
5552
description: PoolSpec defines the desired state of Pool.
5653
properties:
57-
configRef:
58-
description: ConfigRef references the Config this Pool belongs to.
59-
type: string
6054
route:
6155
description: Route configures external access via Gateway API TLSRoute.
6256
properties:
@@ -94,14 +88,6 @@ spec:
9488
rule: '!self.enabled || size(self.hostname) > 0'
9589
- message: gatewayRef.name is required when route is enabled
9690
rule: '!self.enabled || size(self.gatewayRef.name) > 0'
97-
selector:
98-
additionalProperties:
99-
type: string
100-
description: |-
101-
Selector is a set of labels used to select Server Pods for this Pool's Service.
102-
The config label is always added automatically.
103-
If empty or nil, the Pool selects all Server Pods in the Config.
104-
type: object
10591
service:
10692
description: Service defines the Kubernetes Service configuration.
10793
properties:
@@ -139,8 +125,6 @@ spec:
139125
NodePort).
140126
type: string
141127
type: object
142-
required:
143-
- configRef
144128
type: object
145129
status:
146130
description: PoolStatus defines the observed state of Pool.

charts/openvox-operator/crds/openvox.voxpupuli.org_servers.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ spec:
117117
type: object
118118
x-kubernetes-validations:
119119
- message: image and claimName are mutually exclusive
120-
rule: '!(has(self.image) && self.image != '''' && has(self.claimName)
121-
&& self.claimName != '''')'
120+
rule: '!(has(self.image) && size(self.image) > 0 && has(self.claimName)
121+
&& size(self.claimName) > 0)'
122122
- message: either image or claimName must be set
123-
rule: (has(self.image) && self.image != '') || (has(self.claimName)
124-
&& self.claimName != '')
123+
rule: (has(self.image) && size(self.image) > 0) || (has(self.claimName)
124+
&& size(self.claimName) > 0)
125125
configRef:
126126
description: ConfigRef references the Config this Server belongs to.
127127
type: string
@@ -170,6 +170,14 @@ spec:
170170
Pod.
171171
format: int32
172172
type: integer
173+
poolRefs:
174+
description: |-
175+
PoolRefs lists the Pools this Server joins.
176+
The Server controller adds a pool label for each entry, making the pod
177+
selectable by the corresponding Pool's Service.
178+
items:
179+
type: string
180+
type: array
173181
replicas:
174182
default: 1
175183
description: Replicas is the number of Server instances.

0 commit comments

Comments
 (0)