Skip to content

Running as a Cloud Service

vzakaznikov edited this page May 29, 2024 · 4 revisions

Instead of running github-hetzner-runners program locally as a standalone application or as a service. You can easily deploy github-hetzner-runners to run on a Hetzner Cloud instance.

See -h, --help for all the available commands.

✋ Note: By default, the server name where the github-hetzner-runners service will be running is github-hetzner-runners. If you want to use a custom server name, then you must use the cloud --name option for any cloud commands.
github-hetzner-runners cloud -h

Deploying

You can deploy github-hetzner-runners as a service to a new Hetzner Cloud server instance, that will be created for you automatically, using the cloud deploy command.

✋ Note: The options that are passed to the github-hetzner-runners <options> cloud deploy command will be the same options with which the service will be executed.
export GITHUB_TOKEN=ghp_...
export GITHUB_REPOSITORY=...
export HETZNER_TOKEN=GJzdc...

github-hetzner-runners cloud deploy

You can specify the version of the package to be installed using the --version option. By default, the current local package version will be installed on the cloud service server. You can also pass latest as the value to install the latest available version.

github-hetzner-runners cloud deploy --version latest

The deploy command will use the following default values:

location: ash
type: cpx11
image: x86:system:ubuntu-22.04

The cloud deploy command uses the following setup script defined in testflows/github/hetzner/runners/scripts/deploy/setup.sh

setup script:
set -x

apt-get update

apt-get -y install python3-pip
apt-get -y install openssh-client

echo "Create and configure ubuntu user"

adduser ubuntu --disabled-password --gecos ""
echo "%wheel   ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
addgroup wheel
usermod -aG wheel ubuntu
usermod -aG sudo ubuntu

echo "Generate SSH Key"
sudo -u ubuntu ssh-keygen -t rsa -q -f "/home/ubuntu/.ssh/id_rsa" -N ""

You can customize deployment server location, type, and image using the --location, --type, and --image options.

github-hetzner-runners cloud deploy --location nbg1 --type cx11 --image x86:system:ubuntu-22.04

The cloud instance that runs the github-hetzner-runners service can either be x64 or ARM64 instance. By default, cpx11 AMD, 2 vCPU, 2GB RAM, shared-cpu x64 instance type is used.

Using an ARM64 Instance

If you want to deploy the github-hetzner-runners service to an ARM64 instance, then you must specify the instance type using the --type option.

✋ Note: Currently, Hetzner Cloud has ARM64 instances only available in Germany, Falkenstein (fsn1) location.

For example, to use an Ampere Altra, 4 vCPU, 8GB RAM shared-cpu ARM64 instance, you must specify cax21 as the value of the --type as follows:

github-hetzner-runners cloud deploy --location fsn1 --type cax21 --image arm:system:ubuntu-22.04

Using x64 Instance

By default, the cpx11 AMD, 2 vCPU, 2GB RAM, shared-cpu x64 instance type is used. If you want to use a different x64 instance, then specify the desired type using the --type option.

Redeploying Cloud Service

You can change the cloud service configuration or cloud service package version without deleting the existing cloud service server using the cloud redeploy command.

github-hetzner-runners <options> cloud redeploy
✋ Note: The options that are passed to the github-hetzner-runners <options> cloud redeploy command will be the same options with which the service will be executed.

You can specify the version of the package to be installed using the --version option.

Cloud Service Log

You can check the log for the github-hetzner-runners service running on a cloud instance using the github-hetzner-runners cloud log command. Specify -f, --follow if you want to follow the log journal.

For example,

dump the full log:
github-hetzner-runners cloud log
follow the log journal:
github-hetzner-runners cloud log -f

You can also specify the --raw option to output the raw log as well as use the -c name[:width][,...], --columns name[:width][,...] option to specify a comma separated list of columns to include in the output and their optional width.

Cloud Service Status

You can check the status of the github-hetzner-runners service running on a cloud instance using the github-hetzner-runners cloud status command.

For example,

github-hetzner-runners cloud status

Stopping Cloud Service

You can manually stop the github-hetzner-runners service running on a cloud instance using the github-hetzner-runners cloud stop command.

github-hetzner-runners cloud stop

Starting Cloud Service

You can manually start the github-hetzner-runners service running on a cloud instance after it was manually stopped using the github-hetzner-runners cloud start command.

github-hetzner-runners cloud start

Installing Cloud Service

You can manually force installation of the github-hetzner-runners service running on a cloud instance using the github-hetzner-runners cloud install command.

✋ Note: Just like with the github-hetzner-runners <options> service install command, the options that are passed to the github-hetzner-runners <options> cloud install command will be the same options with which the service will be executed.

You can specify -f, --force option to force service reinstallation if it is already installed.

github-hetzner-runners <options> cloud install -f

Uninstalling the Cloud Service

You can manually force the uninstallation of the github-hetzner-runners service running on a cloud instance using the github-hetzner-runners cloud uninstall command.

github-hetzner-runners cloud uninstall

Upgrading the Cloud Service Package

You can manually upgrade the github-hetzner-runners service package running on a cloud instance using the github-hetzner-runners cloud upgrade command.

If a specific '--version' is specified, then the testflows.github.hetzner.runners package is upgraded to the specified version, otherwise the version is upgraded to the latest available.

✋ Note: The service is not reinstalled during the package upgrade process. Instead, it is stopped before the upgrade and then started back up after the package upgrade is complete.
github-hetzner-runners cloud upgrade --version <version>

The service is not reinstalled during the package upgrade process. Instead, it is stopped before the upgrade and then started back up

Changing Cloud Service Options

If you need to change cloud service options such as the --scripts or the --max-runners etc., you can keep the existing server and use cloud redeploy command.

github-hetzner-runners <options> cloud redeploy --version latest

When needed, you can also SSH into the cloud service manually and perform changes manually.

You can do a complete service teardown using the cloud delete and then the cloud deploy commands.

github-hetzner-runners cloud delete
github-hetzner-runners <options> cloud deploy --version latest
✋ Note: A complete teardown will not affect any current jobs, as the service is designed to be restartable. However, some servers might be left in an unfinished state but they will be cleaned up when the service is restarted.

Deleting the Cloud Service

You can delete the github-hetzner-runners cloud service and the cloud instance that is running on it using the github-hetzner-runners cloud delete command.

The cloud delete command, deletes the cloud service by first stopping the service and then deleting the server instance.

❗Warning: The default server name where the cloud service is deployed is github-hetzner-runners. Please make sure to specify the cloud --name option if you have deployed the service to a server with a different name.

For example,

default name:
github-hetzner-runners cloud delete
custom name:
github-hetzner-runners cloud --name <custom_name> delete

SSH in to Cloud Service

You can open an SSH client to the cloud service using the cloud ssh command. For example,

github-hetzner-runners cloud ssh

You can also manually SSH into the cloud service using the ssh utility. For convenience, you can retrieve the SSH client command using the cloud ssh command command. For example,

github-hetzner-runners cloud ssh command

The output will contain the full ssh command including the IP address of the cloud service server.

ssh -q -o "StrictHostKeyChecking no" root@5.161.87.21
Clone this wiki locally