-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
operator: add kuttl test for decommission
- Loading branch information
1 parent
a44f36e
commit 9052ac1
Showing
8 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: redpanda.vectorized.io/v1alpha1 | ||
kind: Cluster | ||
metadata: | ||
name: decommissioning | ||
status: | ||
replicas: 3 | ||
--- | ||
|
||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
collectors: | ||
- type: pod | ||
selector: app.kubernetes.io/name=redpanda | ||
tail: -1 | ||
- type: pod | ||
namespace: redpanda-system | ||
selector: control-plane=controller-manager | ||
tail: -1 | ||
- type: command | ||
command: kubectl get clusters -o jsonpath={@} -n $NAMESPACE | ||
- type: command | ||
command: kubectl get pods -o jsonpath={@} -n $NAMESPACE |
25 changes: 25 additions & 0 deletions
25
src/go/k8s/tests/e2e/decommission/00-redpanda-cluster.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: redpanda.vectorized.io/v1alpha1 | ||
kind: Cluster | ||
metadata: | ||
name: decommissioning | ||
spec: | ||
image: "localhost/redpanda" | ||
version: "dev" | ||
replicas: 3 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
limits: | ||
cpu: 1 | ||
memory: 500Mi | ||
configuration: | ||
rpcServer: | ||
port: 33145 | ||
kafkaApi: | ||
- port: 9092 | ||
adminApi: | ||
- port: 9644 | ||
pandaproxyApi: | ||
- port: 8082 | ||
developerMode: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
job-name: wait-for-3-brokers | ||
status: | ||
containerStatuses: | ||
- name: curl | ||
state: | ||
terminated: | ||
message: | | ||
3 | ||
phase: Succeeded | ||
--- | ||
|
||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
collectors: | ||
- type: pod | ||
selector: app.kubernetes.io/name=redpanda | ||
tail: -1 | ||
- type: pod | ||
namespace: redpanda-system | ||
selector: control-plane=controller-manager | ||
tail: -1 | ||
- type: command | ||
command: kubectl get clusters -o jsonpath={@} -n $NAMESPACE | ||
- type: command | ||
command: kubectl get pods -o jsonpath={@} -n $NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: wait-for-3-brokers | ||
spec: | ||
backoffLimit: 10 | ||
template: | ||
spec: | ||
activeDeadlineSeconds: 90 | ||
containers: | ||
- name: curl | ||
image: curlimages/curl:latest | ||
env: | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
command: | ||
- /bin/sh | ||
- -c | ||
- -ex | ||
args: | ||
- > | ||
url=http://decommissioning-0.decommissioning.$NAMESPACE.svc.cluster.local:9644/v1/brokers | ||
res=$(curl --silent -L $url | tr '{' '\n' | grep node_id | wc -l) && | ||
echo $res > /dev/termination-log && | ||
if [[ "$res" != "3" ]]; then | ||
exit 1; | ||
fi | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: redpanda.vectorized.io/v1alpha1 | ||
kind: Cluster | ||
metadata: | ||
name: decommissioning | ||
status: | ||
replicas: 2 | ||
--- | ||
|
||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
collectors: | ||
- type: pod | ||
selector: app.kubernetes.io/name=redpanda | ||
tail: -1 | ||
- type: pod | ||
namespace: redpanda-system | ||
selector: control-plane=controller-manager | ||
tail: -1 | ||
- type: command | ||
command: kubectl get clusters -o jsonpath={@} -n $NAMESPACE | ||
- type: command | ||
command: kubectl get pods -o jsonpath={@} -n $NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: redpanda.vectorized.io/v1alpha1 | ||
kind: Cluster | ||
metadata: | ||
name: decommissioning | ||
spec: | ||
replicas: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
job-name: wait-for-2-brokers | ||
status: | ||
containerStatuses: | ||
- name: curl | ||
state: | ||
terminated: | ||
message: | | ||
2 | ||
phase: Succeeded | ||
--- | ||
|
||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
collectors: | ||
- type: pod | ||
selector: app.kubernetes.io/name=redpanda | ||
tail: -1 | ||
- type: pod | ||
namespace: redpanda-system | ||
selector: control-plane=controller-manager | ||
tail: -1 | ||
- type: command | ||
command: kubectl get clusters -o jsonpath={@} -n $NAMESPACE | ||
- type: command | ||
command: kubectl get pods -o jsonpath={@} -n $NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: wait-for-2-brokers | ||
spec: | ||
backoffLimit: 10 | ||
template: | ||
spec: | ||
activeDeadlineSeconds: 90 | ||
containers: | ||
- name: curl | ||
image: curlimages/curl:latest | ||
env: | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
command: | ||
- /bin/sh | ||
- -c | ||
- -ex | ||
args: | ||
- > | ||
url=http://decommissioning-0.decommissioning.$NAMESPACE.svc.cluster.local:9644/v1/brokers | ||
res=$(curl --silent -L $url | tr '{' '\n' | grep node_id | wc -l) && | ||
echo $res > /dev/termination-log && | ||
if [[ "$res" != "2" ]]; then | ||
exit 1; | ||
fi | ||
restartPolicy: Never |