Contract: ControlPlane resource Most Kubernetes clusters require a cloud-controller-manager or CSI drivers in order to work properly. Before introducing the ControlPlane extension resource Gardener was having several different Helm charts for the cloud-controller-manager deployments for the various providers. Now, Gardener commissions an external, provider-specific controller to take over this. One or More API Servers: Entry point for REST / kubectl. Etcd: Distributed key/value store. Controller-manager: Always evaluating current vs desired state.
envtest (godoc), a package that helps write integration tests for your controllers by setting up and starting an instance of etcd and the Kubernetes API server, without kubelet, controller-manager or other components.
envtest in integration tests follows the general flow of:
kubebuilder does the boilerplate setup and teardown of testEnv for you, in the ginkgo test suite that it generates under the
Logs from the test runs are prefixed with
You can use environment variables and/or flags to specify the
etcd setup within your integration tests.
|Variable name||Type||When to use|
|boolean||Instead of setting up a local control plane, point to the control plane of an existing cluster.|
|path to directory||Point integration tests to a directory containing all binaries (api-server, etcd and kubectl).|
|paths to, respectively, api-server, etcd and kubectl binaries||Similar to |
|durations in format supported by ||Specify timeouts different from the default for the test control plane to (respectively) start and stop; any test run that exceeds them will fail.|
|boolean||Set to |
Here’s an example of modifying the flags with which to start the API server in your integration tests, compared to the default values in
Unless you’re using an existing cluster, keep in mind that no built-in controllers are running in the test context. In some ways, the test control plane will behave differently from “real” clusters, and that might have an impact on how you write tests. One common example is garbage collection; because there are no controllers monitoring built-in resources, objects do not get deleted, even if an
OwnerReference is set up.
To test that the deletion lifecycle works, test the ownership instead of asserting on existence. For example: