Skip to content

Commit 13aeda8

Browse files
committed
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.
1 parent 830c9ef commit 13aeda8

29 files changed

+491
-329
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ tasks:
161161
vars:
162162
CLI_ARGS: '--load {{.CLI_ARGS}}'
163163

164+
build:charts:
165+
desc: "Run helm dep build for all charts"
166+
cmds:
167+
- helm dep build ./charts/redpanda/chart
168+
164169
test:unit:
165170
desc: "Run all unit tests (~5m)"
166171
vars:
@@ -179,6 +184,7 @@ tasks:
179184
- task: build:image
180185
vars:
181186
CLI_ARGS: '' # Don't forward CLI args to build:image
187+
- task: build:charts
182188
vars:
183189
RUN: '{{ default `"^TestIntegration"` .RUN }}'
184190
cmds:
@@ -195,6 +201,7 @@ tasks:
195201
- task: build:image
196202
vars:
197203
CLI_ARGS: '' # Don't forward CLI args to build:image
204+
- task: build:charts
198205
vars:
199206
RUN: '{{ default `"^TestAcceptance"` .RUN }}'
200207
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/chart" 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/chart" with values:
66
"""
77
# tag::helm-values[]
88
fullnameOverride: name-override

acceptance/features/operator-upgrades.feature

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,8 @@
11
@operator:none @vcluster
22
Feature: Upgrading the operator
3-
@skip:gke @skip:aks @skip:eks
4-
Scenario: Operator upgrade from 2.4.5
5-
Given I install local CRDs from "../operator/config/crd/bases"
6-
And I install redpanda helm chart version "v2.4.5" with the values:
7-
"""
8-
console:
9-
enabled: false
10-
"""
11-
And I apply Kubernetes manifest:
12-
"""
13-
---
14-
apiVersion: cluster.redpanda.com/v1alpha2
15-
kind: Redpanda
16-
metadata:
17-
name: operator-upgrade
18-
spec:
19-
clusterSpec:
20-
console:
21-
enabled: false
22-
statefulset:
23-
replicas: 1
24-
sideCars:
25-
image:
26-
tag: dev
27-
repository: localhost/redpanda-operator
28-
"""
29-
# use just a Ready status check here since that's all the
30-
# old operator supports
31-
And cluster "operator-upgrade" is available
32-
Then I can upgrade to the latest operator with the values:
33-
"""
34-
image:
35-
tag: dev
36-
repository: localhost/redpanda-operator
37-
crds:
38-
experimental: true
39-
"""
40-
# use the new status as this will eventually get set
41-
And cluster "operator-upgrade" should be stable with 1 nodes
42-
433
@skip:gke @skip:aks @skip:eks
444
Scenario: Operator upgrade from 25.1.3
45-
And I install redpanda helm chart version "v25.1.3" with the values:
5+
Given I helm install "redpanda-operator" "redpanda/operator" --version v25.1.3 with values:
466
"""
477
crds:
488
enabled: true
@@ -68,7 +28,7 @@ Feature: Upgrading the operator
6828
# use just a Ready status check here since that's all the
6929
# old operator supports
7030
And cluster "operator-upgrade" is available
71-
Then I can upgrade to the latest operator with the values:
31+
Then I can helm upgrade "redpanda-operator" "../operator/chart" with values:
7232
"""
7333
image:
7434
tag: dev

acceptance/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ var setupSuite = sync.OnceValues(func() (*framework.Suite, error) {
9292
return
9393
}
9494
t.Log("Installing default Redpanda operator chart")
95-
t.InstallLocalHelmChart(ctx, "../operator/chart", helm.InstallOptions{
95+
t.InstallHelmChart(ctx, "../operator/chart", helm.InstallOptions{
9696
Name: "redpanda-operator",
9797
Namespace: namespace,
9898
Values: operatorchart.PartialValues{
@@ -204,7 +204,7 @@ func OperatorTag(ctx context.Context, t framework.TestingT, args ...string) cont
204204
}
205205

206206
t.Logf("Installing Redpanda operator chart: %q", name)
207-
t.InstallLocalHelmChart(ctx, "../operator/chart", helm.InstallOptions{
207+
t.InstallHelmChart(ctx, "../operator/chart", helm.InstallOptions{
208208
Name: "redpanda-operator",
209209
Namespace: t.Namespace(),
210210
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
@@ -166,6 +166,25 @@ func shutdownRandomClusterNode(ctx context.Context, t framework.TestingT, cluste
166166
t.ShutdownNode(ctx, pod.Spec.NodeName)
167167
}
168168

169+
func shutdownNodeOfPod(ctx context.Context, t framework.TestingT, podName string) {
170+
t.ResourceKey(podName)
171+
172+
var pod corev1.Pod
173+
require.NoError(t, t.Get(ctx, t.ResourceKey(podName), &pod))
174+
175+
var node corev1.Node
176+
require.NoError(t, t.Get(ctx, t.ResourceKey(pod.Spec.NodeName), &node))
177+
178+
node.Spec.Taints = append(node.Spec.Taints, corev1.Taint{
179+
Key: "node.kubernetes.io/out-of-service",
180+
Effect: corev1.TaintEffectNoExecute,
181+
})
182+
183+
require.NoError(t, t.Update(ctx, &node))
184+
185+
t.ShutdownNode(ctx, pod.Spec.NodeName)
186+
}
187+
169188
func deleteNotReadyKubernetesNodes(ctx context.Context, t framework.TestingT) {
170189
var nodes corev1.NodeList
171190
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
@@ -12,40 +12,45 @@ package steps
1212
import (
1313
"context"
1414
"fmt"
15+
"strings"
1516

1617
"github.com/cucumber/godog"
1718
"github.com/stretchr/testify/require"
1819
corev1 "k8s.io/api/core/v1"
1920
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20-
"k8s.io/client-go/rest"
2121
"sigs.k8s.io/yaml"
2222

2323
framework "github.com/redpanda-data/redpanda-operator/harpoon"
2424
"github.com/redpanda-data/redpanda-operator/pkg/helm"
2525
)
2626

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

32-
helmClient, err := helm.New(helm.Options{
33-
KubeConfig: rest.CopyConfig(t.RestConfig()),
37+
t.InstallHelmChart(ctx, chart, helm.InstallOptions{
38+
Name: name,
39+
Version: version,
40+
Values: valuesMap,
41+
Namespace: t.Namespace(),
3442
})
35-
require.NoError(t, err)
36-
37-
require.NoError(t, helmClient.RepoAdd(ctx, "console", "https://charts.redpanda.com"))
43+
}
3844

39-
path := "../charts/redpanda/chart"
40-
require.NoError(t, helmClient.DependencyBuild(ctx, path))
45+
func iHelmUpgrade(ctx context.Context, t framework.TestingT, name, chart, version string, values *godog.DocString) {
46+
var valuesMap map[string]any
47+
require.NoError(t, yaml.Unmarshal([]byte(values.Content), &valuesMap))
4148

42-
t.Logf("installing chart %q", path)
43-
_, err = helmClient.Install(ctx, path, helm.InstallOptions{
44-
Name: helmReleaseName,
45-
Namespace: t.Namespace(),
49+
t.UpgradeHelmChart(ctx, name, chart, helm.UpgradeOptions{
50+
Version: version,
4651
Values: valuesMap,
52+
Namespace: t.Namespace(),
4753
})
48-
require.NoError(t, err)
4954
}
5055

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

acceptance/steps/helpers.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ import (
3232
authenticationv1 "k8s.io/api/authentication/v1"
3333
corev1 "k8s.io/api/core/v1"
3434
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35-
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3635
"k8s.io/apimachinery/pkg/labels"
37-
"k8s.io/apimachinery/pkg/runtime/schema"
3836
"k8s.io/client-go/kubernetes"
3937
"k8s.io/utils/ptr"
4038
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -651,20 +649,6 @@ func clientsForOperator(ctx context.Context, includeTLS bool, serviceAccountName
651649
}
652650
}
653651

654-
func removeAllFinalizers(ctx context.Context, t framework.TestingT, gvk schema.GroupVersionKind) {
655-
list := &unstructured.UnstructuredList{}
656-
list.SetGroupVersionKind(gvk)
657-
658-
// swallow errors for non-existent crds
659-
if err := t.List(ctx, list); err == nil {
660-
for i := range list.Items {
661-
item := list.Items[i]
662-
item.SetFinalizers(nil)
663-
require.NoError(t, t.Update(ctx, &item))
664-
}
665-
}
666-
}
667-
668652
func getVersion(t framework.TestingT, version string) string {
669653
version = strings.TrimSpace(version)
670654
if version != "" {

0 commit comments

Comments
 (0)