Migrating to Bonsai
Bonsai is the codename for Garden 0.13.
In Garden Bonsai, actions replace modules as the recommended way to describe components in your your Garden projects. The top-level project configuration is mostly unchanged.
But fear not: Bonsai is mostly backwards compatible with the old configuration! There are very few breaking changes that require editing any existing module-based configuration files - your projects should mostly just work when updating Garden.
On the other hand, the new configuration format is easier to read and write, provides much more flexibility, and adds some completely new functionality. We encourage you to incrementally convert your module configs to actions when you feel the time is right in your project.
If you'd like to learn more about actions before proceeding, check out the actions guide (which describes actions in depth).
Breaking changes first
Here is the list of breaking changes from Garden Acorn (0.12) to Bonsai (0.13). This lets you use your old module configs with minimal changes.
The
cert-manager
integration has been removed. New documentation has been created in the ext dns and cert manager exampledev-mode
has been renamed tosync
(and is now referred to as sync mode), both in configuration as well as in CLI command options.The
garden delete
command has been renamed togarden cleanup
.garden delete env
has been renamed togarden cleanup namespace
, with an alias ofgarden cleanup ns
Changes to the caching behaviour:
Now Garden caches Run results and re-runs the Runs if its dependencies have changed. It is therefore recommended that you make sure your Runs are idempotent (i.e. can safely be run multiple times). This behaviour can be disabled via the
spec.cacheResult
field on Runs.
Changes to project configuration:
The
dotIgnoreFiles
field has been renamed todotIgnoreFile
and only supports one file. The olddotIgnoreFiles
field is still supported with a deprecation warning. Now it supports only 1 filename defined in the array, otherwise an error will be thrown.The
modules.*
field has been renamed toscan.*
. The old syntax is still supported with a deprecation warning.Removed default
environments
(this might require you to explicitly specify a plugin name or two in your project config that were previously inferred implicitly).
The deprecated
hot-reload
mode has been removed: Usesync
instead.Sync mode is faster, more reliable and more full-featured than the old hot reload mode, so we feel confident that you'll be happy with the upgrade.
The deprecated
cluster-docker
build mode has been removed. Please usecluster-buildkit
orkaniko
instead.Dropped support for deploying an in-cluster registry
See the in-cluster build documentation for guidance on how to set up a container registry for using Garden with a remote Kubernetes cluster.
Dropped support for the following providers:
google-app-engine
google-cloud-functions
local-google-cloud-functions
maven-container
(superseded by thejib-container
plugin)npm-package
(theexec
provider is a good replacement there)openfaas
Bonsai follows the YAML 1.2 specification when reading Garden configuration files by default, and Acorn followed the 1.1 standard (Summary of the differences).
To go back to using YAML 1.1 if you intend to make your config compatible with both Bonsai and Acorn, you can add a version directive at the top of the Garden configuration file:
Kubernetes still uses YAML 1.1 by default as of today (Kubernetes issue), and we continue to use YAML 1.1 when reading Kubernetes manifest files.
Note before continuing
It is possible to use both module and action configs in the same project. This should make it easier to convert projects piece by piece.
Internally, Garden converts modules into actions:
The build step of a module (if any) becomes a Build action.
Services become Deploy actions.
Tests become Test actions.
Tasks become Run actions.
This means that converting your project to the actions config can be performed gradually by starting from the end of the dependency tree.
The general flow of the Garden runtime is as follows:
Modules are resolved
Modules are converted to actions
Actions are resolved
However, there are some caveats:
Modules cannot depend on actions
Modules cannot reference actions
Actions can reference and depend on modules, by referencing the actions that are generated from modules.
Deploy actions should explicitly add their corresponding Build action to their
dependency
array (see examples below)Deploy
container
actions should explicitly reference the output of their corresponding Build action in thespec.image
field (see examples below)
Updating the CLI
If you have installed garden
via Homebrew, running brew upgrade garden-cli
will update you to Bonsai (0.13.x).
Alternatively, you can use the built-in update mechanism to update in-place: garden self-update --major
. You can run garden self-update --help
for more details.
Lastly, you can manually download any version on our releases page.
Opt in to the new format
Here are a couple of examples of converting module configs to action configs.
The added granularity and flexibility should make it easier to configure complex projects, and significantly reduce the number of unnecessary rebuilds.
This is a short tutorial, you can find the full reference documentation for Actions here
vote/api
vote/postgres
vote/worker
Mixed use of Garden Acorn (0.12) and Bonsai (0.13)
For backwards compatibility, Garden Bonsai will default to apiVersion: garden.io/v0
in your project configuration (kind: Project
).
Using apiVersion: garden.io/v0
enables teams to gradually move to Bonsai, one team member at a time, because members can already choose to use Bonsai, while still being able to use Acorn (0.12
) when necessary.
As soon as your project is using Actions, apiVersion: garden.io/v1
becomes mandatory in the project configuration.. From that point on, team members can no longer use Acorn (0.12
) as it does not recognize apiVersion: garden.io/v1
. Therefore team members are forced to update to Bonsai (0.13
).
When using Garden Cloud, features like triggered workflows or 1-Click Preview Environments, Garden Cloud will use Bonsai (0.13
) with apiVersion: garden.io/v1
or Acorn (0.12
) with apiVersion: garden.io/v0
. See also the Garden Cloud workflows documentation.
Where is the documentation for modules?
The reference documentation can be found here, but all other documentation has been rewriten to be action specific. If you need to keep working with modules with Bonsai you can reference the 0.12 documentation.
Detecting module/action mode
In 0.12 often string templating was used to detect sync mode and change behaviour accordingly. This can be done much easier with Bonsai via the ${actions.deploy.<name>.mode}
template string or ${this.mode}
if referenced in the action itself, but that would not be backward compatible with 0.12. Below is an example config that works with both Bonsai and 0.12. In this block the variables sync-mode
or dev-mode
are set to true if the relative mode is requested for the api
service/deploy.
Sync mode or dev mode have been requested if either var.sync-mode
or var.dev-mode
are true. You can use a template expression like ${var.sync-mode || var.dev-mode ? 'yes' : 'no'}
to change the behaviour of your actions or modules.
Last updated