Skip to content

Kubernetes testing

testing-kubernetes-infrastructure Run custom tests on cluster

Testing pyramid

Static analysis

  • kube-score
  • kube-lint
  • yamllint
  • kubectl apply -f <file> --dry-run --validate=true

Dry-run:

  • kubectl apply -f <file> --server-dry-run

Unit tests

Tools / frameworks

https://blog.flant.com/small-local-kubernetes-comparison/ https://thechief.io/c/editorial/k3d-vs-k3s-vs-kind-vs-microk8s-vs-minikube/

  • minikube: see ./minikube.md only run a single node in the local Kubernetes cluster
  • Kind: see ./kind.md
  • k3s
    • k3d is a platform-agnostic, lightweight wrapper that runs K3s in a docker container.
  • microk8s: Created by Canonical, microK8S is a Kubernetes distribution designed to run fast, self-healing, and highly available Kubernetes clusters

Sonobouy

Usage:

cd ~/kubernetes/testing/sonobuoy
sonobuoy run --plugin hello-world.yaml --wait
outfile=$(sonobuoy retrieve) && tar -xf $outfile -C results && cat results/plugins/debug/results/*/out*
sonobuoy delete --wait

Kubetest2, gomega & ginko

etc