Deploing to Google Cloud


Google Cloud Compute VMs can be used to run Zenaton workers. The following example will show you how to deploy your code to a Linux-based VM and have it execute your workflows and tasks. You will see how to:

Set up a firewall rule to allow communication with Zenaton.
Create an instance and set the security to allow your Agent to talk with Zenaton
Install the files needed to run Zenaton, and to execute your Workflows and Tasks.
Set you Agent to automatically run when the VM is started.

# Set Up Firewall Rule

You will need to set up a firewall rule to allow outbound traffic from ports 443 and 5672. To do this, go to the list of Firewall rules, and clilck the "Create Firewall Rule" button at the top.

Give the rule a name so you can easily identify it later (ie "zenaton") and then set it to allow outgoing traffic (egress) to ports 443 and 5672. You can read more about this here.

google-firewall

If you set this to be a default rule, it will automatically apply to all VM instances in your project. You can also chose to have it only apply to those VMs on which you specifically enable it.

# Set Up VM Instance

This example was tested with the "f1-micro" machine type. This was used because the example is simple, and it reduces the cost of running it. You may need to scale up, depending on the amount of power your Tasks need. Also note that, for this example, the default settings were used.

google-vm

Once your instance is up and runnning, you can connect to it and set it up to run your Zenaton Tasks:

gcloud compute --project "<project-name>" ssh --zone <zone> <instance-name>

Next, install Zenaton:

curl https://install.zenaton.com | sh

Now you can copy your project to your instance. Create a directory for it:

mkdir app

And then use scp to copy your files from your computer:

gcloud compute --project "<project-name>" scp -r app/* <instance-name>:app/

Now you can log back into your instance, and install your project's dependencies:

Your project can now be run on your instance. Just make sure you have a valid .env in your project directory. All that remains is to set it to automatically start when your instance is launched. We will do this using systemd. Make sure you know your username on your instance; you can use the whoami command if you need to. As root (ie, via sudo), create the service file at /etc/systemd/system/zenaton-agent.service:

Finally, start the Agent, and tell systemd to start it each time your instance is launched:

sudo systemctl daemon-reload
sudo systemctl start zenaton-agent
sudo systemctl enable zenaton-agent

Your instance will now execute your Workflows and Tasks. To test, you can start Zenaton locally in client mode, and check zenaton.out on your VM instance to verify the tasks are being executed on the instance.