How to: Getting started
The minimum hardware requirements for OptScale cluster: CPU: 8+ cores, RAM: 16Gb, SSD: 150+ Gb.

NVMe SSD is recommended.  

**OS Required**: [Ubuntu 24.04](https://releases.ubuntu.com/noble/).

_The current installation process should work also on Ubuntu 22.04_

#### Updating old installation
please follow [this document](documentation/update_to_24.04.md) to upgrade your existing installation on Ubuntu 20.04.

#### Installing required packages

Run the following commands:

```
sudo apt update; sudo apt install python3-pip sshpass git python3-virtualenv python3 python3-venv python3-dev -y
```

#### Pulling optscale-deploy scripts

Clone the repository

```markdown
git clone https://github.com/hystax/optscale.git
```

Change current directory:

```
cd optscale/optscale-deploy
```

#### Preparing virtual environment

Run the following commands:

```
virtualenv -p python3 .venv
source .venv/bin/activate
pip install -r requirements.txt
```

#### Kubernetes installation

Run the following command:
**comma after ip address is required**

```
ansible-playbook -e "ansible_ssh_user=
" -k -K -i "
," ansible/k8s-master.yaml
```

where `
` - actual username; `
` - host ip address,
ip address should be private address of the machine, you can check it with the command `ip a`.

**Note:** do not use `127.0.0.1` or `localhost` as the hostname. Instead, prefer providing the server's hostname (check with the command `hostname`) and make sure it is resolveable from host that the Ansible Playbooks ran from (if needed, add to the ``/etc/hosts`` files).

If your deployment server is the service-host server, add `-e "ansible_connection=local"` to the ansible command.

When ansible is completed, re-login, or simply run

```
source ~/.profile
```
to add local ~/bin path to the system $PATH variable

**Note:** you can build local images running

```
cd .. && ./build.sh --use-nerdctl
```
Images will build with version(tag) = local

#### Creating user overlay

Edit file with overlay - [optscale-deploy/overlay/user_template.yml](optscale-deploy/overlay/user_template.yml); see comments in overlay file for guidance.

Pay attention to "service_credentials" parameter, as OptScale uses it to retrieve cloud pricing data for recommendations calculation.

#### Cluster installation

Run the following command to start cluster from the required version:

```
./runkube.py --with-elk  -o overlay/user_template.yml --
```

or use `--no-pull` to start cluster from local images:

```
./runkube.py --with-elk --no-pull -o overlay/user_template.yml --
local
```

If you want to use socket:

```
./runkube.py --use-socket --with-elk  -o overlay/user_template.yml --
```

If you have insecure registry (with self-signed certificate) you can use --insecure flag with runkube.py:

```
./runkube.py --insecure --with-elk  -o overlay/user_template.yml --
```

**deployment name** must follow the RFC 1123: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/

**version**:

- Use hystax/optscale git tag (eg: latest) if you use optscale public version.
- Use your own tag version if you build your optscale images (eg: local).

**please note**: if you use key authentication, you should have the required key (id_rsa) on the machine

Check the state of the pods using `kubectl get pods` command.
When all the pods are running your OptScale is ready to use. Try to access it by `https://
`.

#### Cluster update

Run the following command:

```
./runkube.py --with-elk  --update-only --
```

#### Get IP access http(s):

```markdown
kubectl get services --field-selector metadata.name=ngingress-nginx-ingress-controller
```

#### Troubleshooting

In case of the following error:

When running  ```build.sh --use-nerdctl```:
```
FATA[0000] rootless containerd not running? (hint: use `containerd-rootless-setuptool.sh install` to start rootless containerd): stat /run/user/1000/containerd-rootless: no such file or directory 
Building image for trapper_worker, build tag: local
FATA[0000] rootless containerd not running? (hint: use `containerd-rootless-setuptool.sh install` to start rootless containerd): stat /run/user/1000/containerd-rootless: no such file or directory 
```
simply re-login or run ```source ~/.profile```

when running ```./runkube.py... <>```
```
python_on_whales.exceptions.DockerException: The command executed was `/usr/local/bin/nerdctl image inspect arcee:local`.
It returned with code 1
The content of stdout is ''
The content of stderr is 'time="2024-12-23T11:05:34Z" level=fatal msg="rootless containerd not running? (hint: use `containerd-rootless-setuptool.sh install` to start rootless containerd): stat /run/user/1000/containerd-rootless: no such file or directory"
```
the solution is also simply re-login or run ```source ~/.profile```

---

```
fatal: [172.22.24.157]: FAILED!