Skip to content

Commit 31bb240

Browse files
committed
operator: k8s: add kuttl test to ensure that brokers start after they change their advertised address
1 parent d83cb0b commit 31bb240

File tree

5 files changed

+124
-0
lines changed

5 files changed

+124
-0
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: redpanda.vectorized.io/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: endpoint-template
5+
status:
6+
replicas: 2
7+
readyReplicas: 2
8+
restarting: false
9+
conditions:
10+
- type: ClusterConfigured
11+
status: "True"
12+
---
13+
14+
apiVersion: kuttl.dev/v1beta1
15+
kind: TestAssert
16+
collectors:
17+
- type: pod
18+
selector: app.kubernetes.io/name=redpanda
19+
tail: -1
20+
- type: pod
21+
namespace: redpanda-system
22+
selector: control-plane=controller-manager
23+
tail: -1
24+
- type: command
25+
command: kubectl get clusters -o jsonpath={@} -n $NAMESPACE
26+
- type: command
27+
command: kubectl get pods -o jsonpath={@} -n $NAMESPACE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: redpanda.vectorized.io/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: endpoint-template
5+
spec:
6+
image: "localhost/redpanda"
7+
version: "dev"
8+
replicas: 2
9+
resources:
10+
requests:
11+
cpu: 100m
12+
memory: 100Mi
13+
limits:
14+
cpu: 1
15+
memory: 500Mi
16+
configuration:
17+
rpcServer:
18+
port: 33145
19+
adminApi:
20+
- port: 9644
21+
kafkaApi:
22+
- port: 9092
23+
- external:
24+
enabled: true
25+
subdomain: example.com
26+
endpointTemplate: "{{.Index}}-{{.HostIP | sha256sum | substr 0 10}}-kafka"
27+
tls:
28+
enabled: true
29+
requireClientAuth: true
30+
pandaproxyApi:
31+
- port: 8082
32+
- external:
33+
enabled: true
34+
subdomain: example.com
35+
endpointTemplate: "{{.Index}}-{{.HostIP | sha256sum | substr 0 10}}-pandaproxy"
36+
tls:
37+
enabled: true
38+
requireClientAuth: true
39+
developerMode: true
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: redpanda.vectorized.io/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: endpoint-template
5+
status:
6+
replicas: 2
7+
readyReplicas: 2
8+
restarting: false
9+
conditions:
10+
- type: ClusterConfigured
11+
status: "True"
12+
---
13+
14+
apiVersion: v1
15+
kind: Pod
16+
metadata:
17+
name: endpoint-template-0
18+
status:
19+
phase: "Running"
20+
---
21+
22+
apiVersion: v1
23+
kind: Pod
24+
metadata:
25+
name: endpoint-template-1
26+
status:
27+
phase: "Running"
28+
---
29+
30+
apiVersion: kuttl.dev/v1beta1
31+
kind: TestAssert
32+
collectors:
33+
- type: pod
34+
selector: app.kubernetes.io/name=redpanda
35+
tail: -1
36+
- type: pod
37+
namespace: redpanda-system
38+
selector: control-plane=controller-manager
39+
tail: -1
40+
- type: command
41+
command: kubectl get clusters -o jsonpath={@} -n $NAMESPACE
42+
- type: command
43+
command: kubectl get pods -o jsonpath={@} -n $NAMESPACE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
# Cordon the node that is running broker 1
5+
- script: kubectl cordon $(kubectl get pod -n $NAMESPACE endpoint-template-1 -o jsonpath='{.spec.nodeName}')
6+
# Delete broker 1 PVC and Pod to move it to another node, changing the corresponding advertised address
7+
- command: kubectl delete pvc datadir-endpoint-template-1 --wait=false
8+
namespaced: true
9+
- command: kubectl delete pod endpoint-template-1
10+
namespaced: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
# Uncordon all nodes (selects all nodes not matching an non-existent label)
5+
- command: kubectl uncordon -l any!=node

0 commit comments

Comments
 (0)