Integrating KubeAssert with KUTTL

About KUTTL

Combine KUTTL with KubeAssert

apiVersion: v1
kind: Pod
metadata:
name: my-pod
status:
phase: Successful

Writing Your First Test using KUTTL and KubeAssert

Create a Test Case

mkdir -p tests/e2e/example-test
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
- command: kubectl assert exist-enhanced deployment example-deployment -n $NAMESPACE --field-selector status.readyReplicas=3

Write a Second Test Step

apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
spec:
replicas: 4
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
- command: kubectl assert exist-enhanced deployment example-deployment -n $NAMESPACE --field-selector status.readyReplicas=4
kubectl kuttl test — start-kind=true ./tests/e2e/

Summary

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store