Skip to content

Commit 5ca7350

Browse files
david-yuclaude
andcommitted
operator: add PodDisruptionBudget support to Pipeline CRD
Add spec.budget field to Pipeline with maxUnavailable/minAvailable options, following the convention used by Strimzi and Prometheus Operator. The PDB is rendered by the Syncer alongside the Deployment and ConfigMap, so it is automatically garbage-collected on CR deletion. CRD validation enforces exactly one of maxUnavailable or minAvailable via CEL rule. RBAC updated for policy/poddisruptionbudgets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d46f37b commit 5ca7350

12 files changed

Lines changed: 571 additions & 289 deletions

File tree

operator/api/redpanda/v1alpha2/pipeline_types.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ package v1alpha2
1212
import (
1313
corev1 "k8s.io/api/core/v1"
1414
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15+
"k8s.io/apimachinery/pkg/util/intstr"
1516
"k8s.io/utils/ptr"
1617

1718
"github.com/redpanda-data/redpanda-operator/operator/pkg/functional"
@@ -178,11 +179,33 @@ type PipelineSpec struct {
178179
// +optional
179180
Zones []string `json:"zones,omitempty"`
180181

182+
// Budget configures a PodDisruptionBudget for the pipeline Deployment,
183+
// protecting pipeline pods from voluntary disruptions such as node drains
184+
// and cluster autoscaler evictions. When not set, no PDB is created.
185+
// +optional
186+
Budget *PipelineBudget `json:"budget,omitempty"`
187+
181188
// ClusterSource is a reference to the Redpanda cluster this pipeline connects to.
182189
// +optional
183190
ClusterSource *ClusterSource `json:"cluster,omitempty"`
184191
}
185192

193+
// PipelineBudget configures a PodDisruptionBudget for the pipeline.
194+
// Exactly one of MaxUnavailable or MinAvailable must be specified.
195+
// +kubebuilder:validation:XValidation:message="exactly one of maxUnavailable or minAvailable must be set",rule="has(self.maxUnavailable) != has(self.minAvailable)"
196+
type PipelineBudget struct {
197+
// MaxUnavailable is the maximum number of pipeline pods that can be
198+
// unavailable during a voluntary disruption. Can be an absolute number
199+
// (e.g. 1) or a percentage (e.g. "25%").
200+
// +optional
201+
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
202+
// MinAvailable is the minimum number of pipeline pods that must remain
203+
// available during a voluntary disruption. Can be an absolute number
204+
// (e.g. 2) or a percentage (e.g. "75%").
205+
// +optional
206+
MinAvailable *intstr.IntOrString `json:"minAvailable,omitempty"`
207+
}
208+
186209
// PipelineStatus defines the observed state of a Connect resource.
187210
type PipelineStatus struct {
188211
// ObservedGeneration is the last observed generation of the Connect resource.

operator/api/redpanda/v1alpha2/testdata/crd-docs.adoc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,35 @@ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-
23252325
|===
23262326

23272327

2328+
[id="{anchor_prefix}-github-com-redpanda-data-redpanda-operator-operator-api-redpanda-v1alpha2-pipelinebudget"]
2329+
==== PipelineBudget
2330+
2331+
2332+
2333+
PipelineBudget configures a PodDisruptionBudget for the pipeline.
2334+
Exactly one of MaxUnavailable or MinAvailable must be specified.
2335+
2336+
2337+
2338+
.Appears In:
2339+
****
2340+
- xref:{anchor_prefix}-github-com-redpanda-data-redpanda-operator-operator-api-redpanda-v1alpha2-pipelinespec[$$PipelineSpec$$]
2341+
****
2342+
2343+
[cols="20a,50a,15a,15a", options="header"]
2344+
|===
2345+
| Field | Description | Default | Validation
2346+
| *`maxUnavailable`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#intorstring-intstr-util[$$IntOrString$$]__ | MaxUnavailable is the maximum number of pipeline pods that can be +
2347+
unavailable during a voluntary disruption. Can be an absolute number +
2348+
(e.g. 1) or a percentage (e.g. "25%"). + | | Optional: \{} +
2349+
2350+
| *`minAvailable`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#intorstring-intstr-util[$$IntOrString$$]__ | MinAvailable is the minimum number of pipeline pods that must remain +
2351+
available during a voluntary disruption. Can be an absolute number +
2352+
(e.g. 2) or a percentage (e.g. "75%"). + | | Optional: \{} +
2353+
2354+
|===
2355+
2356+
23282357
[id="{anchor_prefix}-github-com-redpanda-data-redpanda-operator-operator-api-redpanda-v1alpha2-pipelinephase"]
23292358
==== PipelinePhase
23302359

@@ -2422,6 +2451,10 @@ be spread. When set, the controller configures: +
24222451
- A topology spread constraint to distribute pods evenly across zones +
24232452
The zone label used is "topology.kubernetes.io/zone". + | | Optional: \{} +
24242453

2454+
| *`budget`* __xref:{anchor_prefix}-github-com-redpanda-data-redpanda-operator-operator-api-redpanda-v1alpha2-pipelinebudget[$$PipelineBudget$$]__ | Budget configures a PodDisruptionBudget for the pipeline Deployment, +
2455+
protecting pipeline pods from voluntary disruptions such as node drains +
2456+
and cluster autoscaler evictions. When not set, no PDB is created. + | | Optional: \{} +
2457+
24252458
| *`cluster`* __xref:{anchor_prefix}-github-com-redpanda-data-redpanda-operator-operator-api-redpanda-v1alpha2-clustersource[$$ClusterSource$$]__ | ClusterSource is a reference to the Redpanda cluster this pipeline connects to. + | | Optional: \{} +
24262459

24272460
|===

operator/api/redpanda/v1alpha2/zz_generated.deepcopy.go

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

operator/api/redpanda/v1alpha2/zz_generated.deprecations_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ package v1alpha2
3030
import (
3131
"testing"
3232

33-
"github.com/redpanda-data/common-go/rp-controller-utils/deprecations"
3433
"github.com/stretchr/testify/require"
3534
"k8s.io/apimachinery/pkg/runtime"
3635
"k8s.io/utils/ptr"
3736
"sigs.k8s.io/controller-runtime/pkg/client"
37+
38+
"github.com/redpanda-data/common-go/rp-controller-utils/deprecations"
3839
)
3940

4041
func TestDeprecatedFieldWarnings(t *testing.T) {

operator/chart/files/rbac/pipeline.ClusterRole.yaml

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,22 @@ metadata:
55
name: pipeline
66
rules:
77
- apiGroups:
8-
- cluster.redpanda.com
8+
- ""
99
resources:
10-
- pipelines
10+
- configmaps
1111
verbs:
12+
- create
13+
- delete
1214
- get
1315
- list
14-
- watch
15-
- update
1616
- patch
17-
- apiGroups:
18-
- cluster.redpanda.com
19-
resources:
20-
- pipelines/status
21-
verbs:
22-
- get
23-
- update
24-
- patch
25-
- apiGroups:
26-
- cluster.redpanda.com
27-
resources:
28-
- pipelines/finalizers
29-
verbs:
3017
- update
18+
- watch
3119
- apiGroups:
32-
- cluster.redpanda.com
20+
- ""
3321
resources:
34-
- redpandas
22+
- pods
23+
- secrets
3524
verbs:
3625
- get
3726
- list
@@ -41,37 +30,41 @@ rules:
4130
resources:
4231
- deployments
4332
verbs:
33+
- create
34+
- delete
4435
- get
4536
- list
46-
- watch
47-
- create
48-
- update
4937
- patch
50-
- delete
38+
- update
39+
- watch
5140
- apiGroups:
52-
- ""
41+
- cluster.redpanda.com
5342
resources:
54-
- pods
43+
- pipelines
5544
verbs:
5645
- get
5746
- list
47+
- patch
48+
- update
5849
- watch
5950
- apiGroups:
60-
- ""
51+
- cluster.redpanda.com
6152
resources:
62-
- configmaps
53+
- pipelines/finalizers
6354
verbs:
64-
- get
65-
- list
66-
- watch
67-
- create
6855
- update
56+
- apiGroups:
57+
- cluster.redpanda.com
58+
resources:
59+
- pipelines/status
60+
verbs:
61+
- get
6962
- patch
70-
- delete
63+
- update
7164
- apiGroups:
72-
- ""
65+
- cluster.redpanda.com
7366
resources:
74-
- secrets
67+
- redpandas
7568
verbs:
7669
- get
7770
- list
@@ -81,10 +74,22 @@ rules:
8174
resources:
8275
- podmonitors
8376
verbs:
77+
- create
78+
- delete
8479
- get
8580
- list
81+
- patch
82+
- update
8683
- watch
84+
- apiGroups:
85+
- policy
86+
resources:
87+
- poddisruptionbudgets
88+
verbs:
8789
- create
88-
- update
89-
- patch
9090
- delete
91+
- get
92+
- list
93+
- patch
94+
- update
95+
- watch

0 commit comments

Comments
 (0)