Todo Manager (Node) Example App
Estimated Time: 10 minutes
Although you normally need your own cluster to use Kelda, this guide uses a precreated Hosted Kelda cluster so that you can dive right in to the example app.
In this guide we will deploy the Node Todo Manager application and observe Kelda syncing an update to our code.
Run the following command to download and install Kelda.
curl -fsSL 'https://kelda.io/install.sh' | sh
Download the Kelda examples repository
This repository contains the source code and Kelda config for the Todo Manager.
git clone https://github.com/kelda-inc/examples
Configure Kelda to work on the Todo Manager project
The following command creates a file that's required for the
keldacommands to work.
Most users can just use the defaults by hitting [Enter] for each prompt.
In the root directory of the examples repository, run:
If the command succeeded, you should see something like:
Wrote config to /Users/kevin/.kelda.yaml
Kelda maintains a public cluster for demos. If you've already setup a Kelda cluster, just omit the
Developing with Kelda
Each service that you want to develop must have a kelda.yaml that describes what files to sync, and what Kelda should do after each sync.
Start development on the Todo service
Run the following command from the examples repo. It will boot the Todo Manager service and its dependencies, start the code syncing, and start the tunnel to the app's frontend.
kelda dev ./node-todo/web-server
Wait for all of the services to become
Ready. The first boot may take several minutes while all the services boot.
View the Todo frontend
Open http://localhost:8080 in your browser and add some new items to your todo list.
Modify the service code
./node-todo/web-server/app/routes.jsin your preferred text editor, uncomment the code on line 12, and save the file. Kelda will sync the change into your development environment and restart the Node server.
View the change in your browser
Reload http://localhost:8080, you will now see each todo prepended with "Kelda:"
Exit Kelda by entering
Ctrl + cinto the terminal window where the Kelda CLI is running.
Delete your development namespace
kelda deleteto delete your development namespace so that it stops consuming resources in the remote cluster.
Deep Dive into the Kelda Configuration
Let's take a closer look at this project's Kelda configuration files to better understand what Kelda is doing under the hood.
First, take a look at the workspace.yaml file. Every Kelda project requires this Workspace config file. It, along with the Kubernetes YAML files in the same directory, defines the services that will be deployed into Kubernetes.
The Todo app has two services:
||This service deploys a Docker container which runs a Node web server on port 8080. One of the YAML files for the service contains an init container, which waits until the database service is live before deploying the web server.|
||This service deploys the MongoDB container that stores the todo items.|
In the Kelda CLI window you will see each of these services and their status.
Synced when the initial sync finishes and
Ready when the database is ready to accept connections.
tunnels section of the
workspace.yaml file sets up the HTTP tunnel to
the cluster. It tunnels port 8080 on
localhost to port 8080 in the
service. This lets you easily and privately access the app on the cluster.
Please see our guide on writing the Workspace configuration for more information.
Another required Kelda file is kelda.yaml. This is the sync configuration for the project. It starts the Node server, performs an initial sync based on the defined rules, then resyncs files as they are changed.
|2||version||The Kelda config format version.|
|5||name||The name of the service that Kelda is syncing to. It must match a service in the output of
|8||command||The commands that are run after each sync. For the Todo app, the command starts the Node server.|
|12||initCommand||The commands that are run after a sync on any rule with
|14-28||sync||The local and remote paths of files to sync. The first section syncs
Please see our guide on writing the Sync configuration for more information.