Skip to content

Commit 1296990

Browse files
chrissetoRafalKorepta
authored andcommitted
charts/redpanda: use new sidecar --selector flag
This commit builds upon a previous commit that added the `--selector` flag to the sidecar. It updates the chart to appropriate set this new flag and adds acceptance tests to assert the functionality works as expected. This commit is separate as the v2.x.x branches need to release the updated sidecar before it can be used. (cherry picked from commit 13aeda8)
1 parent cc128b4 commit 1296990

34 files changed

+5394
-275
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
project: charts/redpanda
2+
kind: Deprecated
3+
body: '- `statefulset.sideCars.controllers.createRBAC` is deprecated and no longer respected. In most cases, setting this field to `false` would result in a broken deployment. RBAC may be controlled via `rbac.enabled` or per controller via `statefulset.sideCars.controllers.{pvcUnbinder,brokerDecommissioner}.enabled`.'
4+
time: 2025-10-21T14:38:34.206376-04:00
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
project: charts/redpanda
2+
kind: Deprecated
3+
body: '`statefulset.sideCars.controllers.run` has been unused for many releases and is now deprecated. Individual controllers may be enabled/disabled by setting their enabled field: `statefulset.sideCars.pvcUnbinder.enabled`, `statefulset.sideCars.brokerDecommissioner.enabled`.'
4+
time: 2025-10-21T14:44:13.331483-04:00

Taskfile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ tasks:
187187
- task: build:image
188188
vars:
189189
CLI_ARGS: '' # Don't forward CLI args to build:image
190+
- task: build:charts
190191
vars:
191192
RUN: '{{ default `"^TestIntegration"` .RUN }}'
192193
cmds:
@@ -204,6 +205,7 @@ tasks:
204205
- task: build:charts
205206
vars:
206207
CLI_ARGS: '' # Don't forward CLI args to build:image
208+
- task: build:charts
207209
vars:
208210
RUN: '{{ default `"^TestAcceptance"` .RUN }}'
209211
GO_TEST_RUNNER: '{{default "go test" .GO_TEST_RUNNER}}'
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@operator:none
2+
Feature: Redpanda Helm Chart
3+
4+
Scenario: Tolerating Node Failure
5+
Given I helm install "redpanda" "../charts/redpanda" with values:
6+
```yaml
7+
nameOverride: foobar
8+
fullnameOverride: bazquux
9+
10+
statefulset:
11+
sideCars:
12+
image:
13+
tag: dev
14+
repository: localhost/redpanda-operator
15+
pvcUnbinder:
16+
enabled: true
17+
unbindAfter: 15s
18+
brokerDecommissioner:
19+
enabled: true
20+
decommissionAfter: 15s
21+
```
22+
When I stop the Node running Pod "bazquux-2"
23+
And Pod "bazquux-2" is eventually Pending
24+
Then Pod "bazquux-2" will eventually be Running
25+
And kubectl exec -it "bazquux-0" "rpk redpanda admin brokers list | sed -E 's/\s+/ /gm' | cut -d ' ' -f 1,6" will eventually output:
26+
```
27+
ID MEMBERSHIP
28+
0 active
29+
1 active
30+
3 active
31+
```
32+
And kubectl exec -it "bazquux-0" "rpk redpanda admin brokers list --include-decommissioned | sed -E 's/\s+/ /gm' | cut -d ' ' -f 1,6" will eventually output:
33+
```
34+
ID MEMBERSHIP
35+
0 active
36+
1 active
37+
3 active
38+
2 -
39+
```

acceptance/features/migration.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Feature: Helm chart to Redpanda Operator migration
22

33
@skip:gke @skip:aks @skip:eks
44
Scenario: Migrate from a Helm chart release to a Redpanda custom resource
5-
Given a Helm release named "redpanda-migration-example" of the "redpanda/redpanda" helm chart with the values:
5+
Given I helm install "redpanda-migration-example" "../charts/redpanda" with values:
66
"""
77
# tag::helm-values[]
88
fullnameOverride: name-override

acceptance/features/operator-upgrades.feature

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
@operator:none
22
Feature: Upgrading the operator
3+
34
@skip:gke @skip:aks @skip:eks
45
Scenario: Operator upgrade from 2.3.x
5-
Given I install redpanda helm chart version "v2.3.9-24.3.11" with the values:
6+
Given I kubectl kustomize "https://github.com/redpanda-data/redpanda-operator//operator/config/crd?ref=v2.3.9-24.3.11" | kubectl apply -f - --server-side
7+
And I helm install "redpanda-operator" "redpanda/operator" --version v2.3.9-24.3.11 with values:
68
"""
7-
9+
810
"""
911
And I apply Kubernetes manifest:
1012
"""
@@ -21,11 +23,53 @@ Feature: Upgrading the operator
2123
# use just a Ready status check here since that's all the
2224
# old operator supports
2325
And cluster "operator-upgrade" is available
24-
Then I can upgrade to the latest operator with the values:
26+
Then I can helm upgrade "redpanda-operator" "../operator/chart" with values:
2527
"""
2628
image:
2729
tag: dev
2830
repository: localhost/redpanda-operator
31+
crds:
32+
enabled: true
33+
experimental: true
34+
"""
35+
36+
@skip:gke @skip:aks @skip:eks
37+
Scenario: Operator upgrade from 2.4.x
38+
Given I kubectl kustomize "https://github.com/redpanda-data/redpanda-operator//operator/config/crd?ref=operator/v2.4.5" | kubectl apply -f - --server-side
39+
And I can helm install "redpanda-operator" "redpanda/operator" --version v2.4.5 with values:
40+
"""
41+
console:
42+
enabled: false
43+
"""
44+
And I apply Kubernetes manifest:
45+
"""
46+
---
47+
apiVersion: cluster.redpanda.com/v1alpha2
48+
kind: Redpanda
49+
metadata:
50+
name: operator-upgrade
51+
spec:
52+
clusterSpec:
53+
console:
54+
enabled: false
55+
statefulset:
56+
replicas: 1
57+
sideCars:
58+
image:
59+
tag: dev
60+
repository: localhost/redpanda-operator
61+
"""
62+
# use just a Ready status check here since that's all the
63+
# old operator supports
64+
And cluster "operator-upgrade" is available
65+
Then I can helm upgrade "redpanda-operator" "../operator/chart" with values:
66+
"""
67+
image:
68+
tag: dev
69+
repository: localhost/redpanda-operator
70+
crds:
71+
enabled: true
72+
experimental: true
2973
"""
3074
# use the new status as this will eventually get set
3175
And cluster "operator-upgrade" should be stable with 1 nodes

acceptance/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/redpanda-data/redpanda-operator/acceptance
33
go 1.24.3
44

55
require (
6+
github.com/cockroachdb/errors v1.11.3
67
github.com/cucumber/godog v0.14.1
78
github.com/prometheus/common v0.64.0
89
github.com/redpanda-data/common-go/rpadmin v0.1.14
@@ -75,7 +76,6 @@ require (
7576
github.com/chai2010/gettext-go v1.0.2 // indirect
7677
github.com/cisco-open/k8s-objectmatcher v1.9.0 // indirect
7778
github.com/cloudhut/common v0.10.0 // indirect
78-
github.com/cockroachdb/errors v1.11.3 // indirect
7979
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
8080
github.com/cockroachdb/redact v1.1.5 // indirect
8181
github.com/containerd/containerd v1.7.27 // indirect

acceptance/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ var setupSuite = sync.OnceValues(func() (*framework.Suite, error) {
7676
return
7777
}
7878
t.Log("Installing default Redpanda operator chart")
79-
t.InstallLocalHelmChart(ctx, "../operator/chart", helm.InstallOptions{
79+
t.InstallHelmChart(ctx, "../operator/chart", helm.InstallOptions{
8080
Name: "redpanda-operator",
8181
Namespace: namespace,
8282
Values: map[string]any{
@@ -140,7 +140,7 @@ func OperatorTag(ctx context.Context, t framework.TestingT, args ...string) cont
140140
}
141141

142142
t.Logf("Installing Redpanda operator chart: %q", name)
143-
t.InstallLocalHelmChart(ctx, "../operator/chart", helm.InstallOptions{
143+
t.InstallHelmChart(ctx, "../operator/chart", helm.InstallOptions{
144144
Name: "redpanda-operator",
145145
Namespace: t.Namespace(),
146146
ValuesFile: filepath.Join("operator", fmt.Sprintf("%s.yaml", name)),

acceptance/steps/cluster.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,25 @@ func shutdownRandomClusterNode(ctx context.Context, t framework.TestingT, cluste
125125
t.ShutdownNode(ctx, pod.Spec.NodeName)
126126
}
127127

128+
func shutdownNodeOfPod(ctx context.Context, t framework.TestingT, podName string) {
129+
t.ResourceKey(podName)
130+
131+
var pod corev1.Pod
132+
require.NoError(t, t.Get(ctx, t.ResourceKey(podName), &pod))
133+
134+
var node corev1.Node
135+
require.NoError(t, t.Get(ctx, t.ResourceKey(pod.Spec.NodeName), &node))
136+
137+
node.Spec.Taints = append(node.Spec.Taints, corev1.Taint{
138+
Key: "node.kubernetes.io/out-of-service",
139+
Effect: corev1.TaintEffectNoExecute,
140+
})
141+
142+
require.NoError(t, t.Update(ctx, &node))
143+
144+
t.ShutdownNode(ctx, pod.Spec.NodeName)
145+
}
146+
128147
func deleteNotReadyKubernetesNodes(ctx context.Context, t framework.TestingT) {
129148
var nodes corev1.NodeList
130149
require.NoError(t, t.List(ctx, &nodes))

acceptance/steps/helm.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,45 @@ package steps
33
import (
44
"context"
55
"fmt"
6+
"strings"
67

78
"github.com/cucumber/godog"
89
"github.com/stretchr/testify/require"
910
corev1 "k8s.io/api/core/v1"
1011
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11-
"k8s.io/client-go/rest"
1212
"sigs.k8s.io/yaml"
1313

1414
framework "github.com/redpanda-data/redpanda-operator/harpoon"
1515
"github.com/redpanda-data/redpanda-operator/pkg/helm"
1616
)
1717

18-
// The unused parameter is meant to specify a Helm chart place (remote or local in the file system).
19-
func iInstallHelmRelease(ctx context.Context, t framework.TestingT, helmReleaseName, _ string, values *godog.DocString) {
18+
func iHelmInstall(ctx context.Context, t framework.TestingT, name, chart, version string, values *godog.DocString) {
19+
// We don't really reference anything other than the redpanda repo, so just
20+
// handle repos as a naive check here.
21+
if strings.HasPrefix(chart, "redpanda/") {
22+
t.AddHelmRepo(ctx, "redpanda", "https://charts.redpanda.com")
23+
}
24+
2025
var valuesMap map[string]any
2126
require.NoError(t, yaml.Unmarshal([]byte(values.Content), &valuesMap))
2227

23-
helmClient, err := helm.New(helm.Options{
24-
KubeConfig: rest.CopyConfig(t.RestConfig()),
28+
t.InstallHelmChart(ctx, chart, helm.InstallOptions{
29+
Name: name,
30+
Version: version,
31+
Values: valuesMap,
32+
Namespace: t.Namespace(),
2533
})
26-
require.NoError(t, err)
27-
28-
require.NoError(t, helmClient.RepoAdd(ctx, "console", "https://charts.redpanda.com"))
34+
}
2935

30-
path := "../charts/redpanda"
31-
require.NoError(t, helmClient.DependencyBuild(ctx, path))
36+
func iHelmUpgrade(ctx context.Context, t framework.TestingT, name, chart, version string, values *godog.DocString) {
37+
var valuesMap map[string]any
38+
require.NoError(t, yaml.Unmarshal([]byte(values.Content), &valuesMap))
3239

33-
t.Logf("installing chart %q", path)
34-
_, err = helmClient.Install(ctx, path, helm.InstallOptions{
35-
Name: helmReleaseName,
36-
Namespace: t.Namespace(),
40+
t.UpgradeHelmChart(ctx, name, chart, helm.UpgradeOptions{
41+
Version: version,
3742
Values: valuesMap,
43+
Namespace: t.Namespace(),
3844
})
39-
require.NoError(t, err)
4045
}
4146

4247
func iDeleteHelmReleaseSecret(ctx context.Context, t framework.TestingT, helmReleaseName string) {

0 commit comments

Comments
 (0)