logo

Kubernetes - Testing

Unit Tests

Use a fake client: sigs.k8s.io/controller-runtime/pkg/client/fake

Integration Tests

Some of the tools to facilitate integration tests (ordered by complexity of the test cases.)

Tool Note
kuttl only for CRUD
envtest only k8s API server + etcd
kind complete k8s cluster

More details:

  • kuttl: test k8s operators using only YAML (no Go code), good for CRUD testing.
  • envtest:
    • Running locally, only k8s API server + etcd; NO kubelet, controller-manager or other components.
    • Good for testing controllers.
    • Part of controller-runtime (sigs.k8s.io/controller-runtime/pkg/envtest)
  • kind:

E2E Tests

In a real or simulated environment.

E.g. functional, load & performance, disaster recovery, upgrade.