Garden.io: Streamlining Kubernetes Development Workflows
Garden.io is a DevOps automation tool for developing and testing Kubernetes apps faster.
It is a cloud native application development, testing, and deployment platform. It defines the build and deployment procedure for your application in a configuration file named 'garden.yml'.
It is compatible with a variety of programming languages, including JavaScript, and may be used in projects developed using React, VueJS, NodeJS, and other frontend and backend technologies
This is a great video in case you want to get started!
The framework watches for changes to the source code and syncs them to your remote cluster, which does all the heavy lifting of building, deploying and testing.
With dependency-aware rebuilds, full-powered tests and hot reloading against a persistent remote instance of your stack, this yields a fast, consistent and productive development environment.
Installing Homebrew, Docker, Kubernetes and Garden
Install Homebrew using the following documentation: https://brew.sh/
Or just paste the below command in your terminal (Linux, MacOS):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
To utilize Garden.io, we should install Kubernetes and Docker on our machine as Garden.io relies on Docker and Kubernetes to manage and deploy containerized applications.
Kubernetes
Install Kubernetes using NPM:
npm install -g kubernetes-cli
Using Yarn:
yarn global add kubernetes-cli
Using Homebrew:
brew install kubernetes-cli
Docker
Install Docker using NPM:
npm install -g docker
Using Yarn:
yarn global add docker
Using Homebrew:
brew install docker
Garden.io
Using Homebrew:
brew tap garden-io/garden
brew install garden-cli
Installation script (macOS):
First make sure the above are installed, Post that run this automated installation script:
curl -sL https://get.garden.io/install.sh | bash
To later upgrade to the latest version, simply run the script again.
Updating Garden
Once you've installed Garden, you can update it with the Garden self-update
command like so:
garden self-update
To install Garden at a specific version, like 0.13.22, we can run:
garden self-update 0.13.22
To install the latest edge release of Garden we can run:
garden self-update edge-bonsai
For more about the different options by running:
garden self-update --help
Manual download and install (macOS)
If you prefer, you can perform the installation manually, as follows:
Make sure the requirements listed above are installed.
Garden releases page on GitHub and download the macOS archive (under Assets).
Create a
~/.garden/bin
directory, and extract the archive to that directory. Make sure to include all contents of the archive.Lastly, either add the
~/.garden/bin
directory to your PATH, or add a symlink from your/usr/local/bin/garden
to the binary at~/.garden/bin/garden.
The instructions above are designed for MacOS, but you can read more in the documentation if you are using Windows or Linux: https://docs.garden.io/getting-started/installation
After Garden.io finishes installing, you should see a terminal like this:
Setting up Garden.io
In order to setup Garden.io in your project, run the following command:
garden init
Then, configure the project by adding the following as example to the garden.yml
file, which is the file that specifies services, tasks, tests, and so on:
services:
web:
build: .
ports:
- target: 3000
published: 3000
protocol: tcp
The configuration for Garden.io is now complete (based on the specific needs of your project, of course).
Building the application
After having setup the configurations for Garden.io in your project, you can now run it by navigating to the project directory and running the following command:
garden start
Now that you have setup, configured Garden.io in your project and is now running, Garden will start the project and create a container for each service that you defined in the garden.yml
file. If you access http://localhost:3000
in your browser, you should be able to access your project.
Testing the application
In order to setup testing in your Garden, you can do so by first setting up a section in your garden.yml
file called tests
.
tests:
my-tests:
service: web
command: npm run test
Here, you can define the specific testing that you need for your project. Then, when you run the following command, you should be able to see the test suites running:
garden test
This test, for example, will run npm run test
in the web
service.
Deployment
We can deploy it to various cloud providers and Kubernetes clusters, by creating a target environment section to your garden.yml
file:
target:
name: kube-cluster
provider: kubernetes
In this example, we specify that the target environment is a Kubernetes cluster called kube-cluster
. Note that you would need to have kubectl
installed on your machine and have access to it in order to deploy to a Kubernetes cluster.
Then, you run the following command to deploy it:
garden deploy
After completing these steps, Garden.io will start the deployment process and create the necessary resources in your cloud provider or Kubernetes cluster.
And that's a wrap!
For the next steps on how to fine tune your application with garden, please use the following guide.