Garden App
This is a Go application with a CLI and web backend for working with the garden controller.
Getting Started
- Clonse this repository
git clone https://github.com/calvinmclean/automated-garden.git
- Start up all services
docker compose -f deploy/docker-compose.yml --profile demo up
- In a new terminal, create a
config.yaml
file from the provided example
cd garden-app
cp config.yaml.example config.yaml
- Create a
gardens.yaml
file from the provided example
cp gardens.yaml.example gardens.yaml
- Run the server:
go run main.go serve --config config.yaml
To run this in a more long-term setup, I recommend using K3s and deploying the manifests from /deploy/k8s
.
Don't forget to update the config.yaml
and gardens.yaml
in the ConfigMap
. Also, to use ConfigMap
storage client you will have to enable the correct permissions in your cluster with this command:
kubectl create clusterrolebinding default --clusterrole=admin --serviceaccount=default:default
Additional Usage Details
Server
The server
command is the main program that runs the webserver backend for managing Gardens.
Storage Clients
The storage
package defines a Client
interface and multiple implementations of it. The NewStorageClient
will create a client based on the configuration. The available clients are:
YAMLClient
- Writes objects to a YAML file on the local filesystem
- Requires a filename to use
ConfigMapClient
Controller
The controller
command behaves as a mock garden-controller
that makes it easier to develop, test, and debug without using a standalone microcontroller. This has extensive options using flags to control different behaviors. In most cases, the defaults will work perfectly fine.