hscloud-docs/01-1-build-on-ubuntu.md

2.2 KiB

Building an environment

In this chapter, I will describe how to build an environment in which we will build hscloud services.

Requirements

You need git and curl. On Ubuntu you can install them with:

sudo apt install git curl

Clone the repository with the source code of the cloud services:

git clone "https://gerrit.hackerspace.pl/hscloud"
cd hscloud

If you want to commit anything on gerrit, we have to do additional steps (source):

mkdir -p .git/hooks/
curl -Lo .git/hooks/commit-msg https://gerrit.hackerspace.pl/tools/hooks/commit-msg 
chmod +x .git/hooks/commit-msg

Steps

We can configure the environment using niix-shell. To do this, we install nix:

sh <(curl -L https://nixos.org/nix/install) --daemon

And we start it (from inside the hscloud folder):

nix-shell

We now use the bazel tool to build and run the necessary services, including prodaccess and kubectl:

bazel build //tools:install
bazel run //tools:install

Now we can request to grant us access to the hscloud cluster through the prodaccess tool. In place of $hs_username insert the username in SSO hackerspace:

hs_username=$USER # if your username is the same as your SSO username
prodaccess -username $hs_username

If you do not have access to the cluster, contact @q3k or @inf within Matrix.

To check if we have access to the cluster, we can run the command:

# shows the Kubernetes version
kubectl version

# shows the statistics of the cluster
kubectl top nodes

We can also call the public Docker image (again, in place of $hs_username, insert the username in SSO hackerspace):

# to create an instance of (sub) alpine
kubectl -n personal-$hs_username run --image=alpine:latest -it foo

If you want to delete the instance, run:

# to delete an instance (sub) of alpine
kubectl -n personal-$hs_username delete pod foo

Next step

Next step: Create http service