Setting Environment Variables for Plugins on the Fly with Sonobuoy 0.15.0
Jun 26, 2019
With the release of Sonobuoy 0.15.0, we continue to support one of our top roadmap goals: enhanced support for custom plugins. It is now possible to easily modify the environment variables of any plugin without editing a YAML file.
Sonobuoy, an open source diagnostic tool, runs upstream Kubernetes tests to generate reports that help you understand the state of your cluster. Sonobuoy is the underlying technology powering the Certified Kubernetes Conformance Program, which was created by the Cloud Native Computing Foundation (CNCF) and is used by every Certified Kubernetes Service Provider.
The new flag (
--plugin-env) ensures that plugins will no longer require Sonobuoy to add new flags in order to support setting a simple environment variable. So as plugins (like the Kubernetes end-to-end tests) expose more customizability through environment variables, that functionality is immediately available via the Sonobuoy command-line interface. In addition, custom plugins have the same flexibility and can have their environment variables tweaked from the command-line, too.
Use Case: Running E2E Tests in Dry-Run Mode
When running Sonobuoy, you’re often faced with two questions:
- What tests actually get run?
- How can you be sure that the custom focus or skip parameters that you provide will lead to the tests you want being run?
The answer to both of those questions is to run the tests in “dry-run” mode. The underlying test framework exposes this mode in the test image through the environment variable
E2E_DRYRUN. When that variable is set, the test run skips all the execution logic of the tests and just reports the tests it would have run as “passed” and the others as “skipped.”
Until now, using the dry-run variable was not very user-friendly — it was not particularly well known and required you to save the
sonobuoy gen output and manually add the environment variable to the YAML file.
Now you can do all that with a simple one-liner:
sonobuoy run --plugin-env e2e.E2E_DRYRUN=true
Use Case: Customizing Your Own Plugin
You can edit not only the two built-in plugins (
systemd-logs) this way, but also custom plugins of your own. The
--plugin-env flag takes values of the form:
[plugin name].[env var]=[value]
For instance, here’s how you would instruct Sonobuoy to load your custom plugin and then customize it:
sonobuoy run --plugin myPlugin --plugin-env myPlugin.ENV=VAL
These changes make it easier than ever to modify the runs of your plugins, and I’m excited to see what you will do with it.
A big thank you goes out to the Sonobuoy community for your continuous feedback and contributions for this release — and a special thanks to padlar for his contribution.
Join the Sonobuoy community:
It is now possible to easily create a plugin from a Docker image and run it within Sonobuoy without manually editing any YAML files.
With support for running Kubernetes end-to-end tests in air-gapped environments, it is now possible to run the end-to-end suite and validate your cluster’s state without Internet connectivity.
There are many ways to create Kubernetes clusters and many environments that can host them. As a result, platform operators find it difficult to determine whether a cluster is properly configured and whether it is working as it should.