# 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: ```bash sudo apt install git curl ``` Clone the repository with the source code of the cloud services: ```bash git clone "https://gerrit.hackerspace.pl/hscloud" cd hscloud ``` If you want to commit anything on gerrit, we have to do additional steps ([source](https://gerrit.hackerspace.pl/admin/repos/hscloud,general)): ```bash 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`: ```bash sh <(curl -L https://nixos.org/nix/install) --daemon ``` And we start it (from inside the `hscloud` folder): ```bash nix-shell ``` We now use the `bazel` tool to build and run the necessary services, including `prodaccess` and `kubectl`: ```bash bazel build //tools:install bazel run //tools:install ``` Now we can request to grant us access to the hscloud cluster through the [prodaccess](https://pkg.go.dev/code.hackerspace.pl/hscloud/cluster/prodaccess#section-readme) tool. In place of `$hs_username` insert the username in SSO hackerspace: ```bash 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](q3k:hackerspace.pl) or [@inf](informatic:hackerspace.pl) within [Matrix](https://matrix.hackerspace.pl/). To check if we have access to the cluster, we can run the command: ```bash # 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): ```bash # 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: ```bash # to delete an instance (sub) of alpine kubectl -n personal-$hs_username delete pod foo ``` ## Next step Next step: [Create http service](02-create-service.md)