Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Markdown
- [Introduction](#introduction)
  - [Target Audience](#target-audience)
  - [End User License Agreement](#end-user-license-agreement)
- [Prerequisites](#prerequisites)
  - [Gateway Hostname](#gateway-hostname)
  - [Hardware Requirements](#hardware-requirements)
  - [Operating System](#operating-system)
  - [Root User](#root-user)
  - [Docker](#docker)
  - [PowerShell](#powershell)
  - [HTTPS](#https)
  - [Gateway Basic Auth Password](#gateway-basic-auth-password)
  - [Service User uid](#user#service-uiduser)
  - [DockerInstallation group gidDirectory](#docker#installation-group-giddirectory)
- [Installing](#installing)
  - [Running the Install Script](#running-the-install-script)
  - [Enable Smart Classifier Feature](#enable-smart-classifier-feature)

# Introduction
The Smart Classifier ML is a set of APIs for training machine learning (ML) models and making predictions based on these models. The Smart Classifier ML APIs are required by the Smart Classifier feature in the Saga platform.

## Target Audience
This guide is directed towards system administrators that are to install the Smart Classifier ML.

## End User License Agreement
By installing the software one is accepting the [End User License Agreement](https://www.ayfie.com/hubfs/terms/eula.pdf).

# Prerequisites

## Gateway Hostname
The first prerequisite to completefulfill is to decide on the Gateway Hostname of the Smart Classifier ML API's APIsGateway asHostname. otherOther prerequisites as well as the Saga Installerinstall script dependsdepend on knowing it. The recommended Gateway Hostname isUsing the FQDN of the Smart Classifier ML host. Setting is the easiest alternative as setting it to anything else will requiresrequire a DNS entry.

## Hardware Requirements
The more CPU cores, the faster ML model training.
|CPU Speed|CPU Cores   |RAM     | Drive Size|
|:-------:|:----------:|:------:|:---------:|
|   ~2 GHz|           4|    8 GB|      50 GB|

## Operating System
Tested on Ubuntu 22.04.

## Root User
A root user is required to install the prerequisites for Smart Classifier ML. All *sudo* commands in the sections below needs to be run as the root user.

## Docker
Install Docker:
```
sudo apt-get update

sudo apt-get install ca-certificates curl gnupg lsb-release

sudo mkdir -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
```

## PowerShell
The Smart Classifier ML installerinstall script requires that PowerShell is installed. Consult [Install PowerShell on LinuxUbuntu](https://docslearn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linuxinstall-ubuntu?view=powershell-7.2) on how to install PowerShell on Linux.

## HTTPS
Thethis.

## HTTPS
The Smart Classifier ML APIs require the use of the HTTPS protocol. To facilitate that, the Smart Classifier ML requires the HTTPS protocol. The steps to configure HTTPS are the same as in the Saga platform. Please refer to the [Saga Install Guide APIs need to be set up with an SSL certificate. The prerequisite for this depends on how the certificate is to be provided:

- Received from a commercial Certificate Authority (CA) such as for instance IdenTrust, DigiCert, Sectigo, GoDaddy, etc.
- Automatically generated by Let’s Encrypt during the Smart Classifier ML installation

The prerequisites in regard to the first option are:
- two PEM formatted files, \<name\>.crt and \<name\>.key.
- the \<name\>.crt has [Gateway Hostname](#gateway-hostname) set in the Subject Alternative Name attribute. This applies even if there technically are no alternative names.
- the \<name\>.key has an unencrypted private key.

See [Obtaining Correctly Formatted SSL Certificate Files](https://ayfie-dev.atlassian.net/wiki/spaces/SAGA/pages/2400714758/Ayfie+Locator+Installation+Guide2987327489/Obtaining+Correctly+Formatted+SSL+Certificate+Files) for how to configure HTTPS.

 details.

The two files are to be placed into directory _/var/ayfie/smart-classifier-ml/volumes/traefik/certs_ during installation.

The prerequisites in regard to the second option of using Let’s Encrypt's are network related:

- One is using an approved public Top Level Domain (TLD)
- The Smart Classifier ML server is exposed to the public Internet
- The firewall is open for port 80 on the Smart Classifier ML host
- There is a DNS A record entry for the Smart Classifier ML host FQDN and its public IP

## Gateway Basic Auth Password
The Smart Classifier APIs are secured with Basic Auth in the Gateway. The Basic Auth user is set to *smart-classifier-ml*. The Basic Auth password needs to be generated. The password must be and hashed using MD5, SHA1, or BCrypt. WhenThat configuringcan theon SmartUbuntu Classifierbe featuredone inthis Sagaway:
platform,```
onesudo needsapt-get to set the un-hashed version of this password. The hashed Basic Auth password is required by the installer.

One can use the *htpasswd* application on Ubuntu to generate the hashed password. Replace password with the password.
install apache2-utils
```

Replace *\<password\>* and run the command:
```
htpasswd -nb smart-classifier-ml password\<password\>
```

ThisThe command output will outputbe something like this:
```
smart-classifier-ml:$apr1$fhrtmbJR$og2srnFdPPFpDiTaFUOxZ0
```

Copy the 
The*\<password\>* and the encrypted password, (*$apr1$fhrtmbJR$og2srnFdPPFpDiTaFUOxZ0*, will be input when running the install script later.

## User uid
Decide which user should run One should run the Smart Classifiin our example above) as both will be required later, the *\<password\>* when enabling the Smart Classifier ML and log in as this user.
* Get the *uid* of this user. The *uid* is required by the installer. The *uid* is used to set the file permission:
    ```
    id
    ```
* Thisfeature in the Saga install script and the encrypted password when running the Smart Classifier ML install script.

## Service User
One should run the Smart Classifier ML installer as a non-root service user. Create the non-root service user with these commands after having replaced *\<username\>*:
```
sudo useradd <username>
sudo passwd <username>
```

This service user needs to be member of the *docker* group to run the installer wihtoutwithout *sudo*:. Add the service user  ```to the *docker* group:
  ```
  sudo usermod -a -G docker username
    ```

* Log out and in if you are logged in with this user. Verify that the user is a member <username>
  ```

The *uid* of the service user and the *gid* of the *docker* group will be required later when [installing](#installing).

Then log in as the service user:
  ```
  su <username>
  ```

Take note of the *uid* of the service user and the *gid* of the *docker* group with:
  from the output of the command below, they will be required later:
  ```
  id
  ```

Then log  id | grep docker
 back out to the root user:
  ```
  exit
  ```

## Docker group gid
* Get the gid of the Docker group. The *gid* is required by the installer. The *gid* is used to set the file permissions:
    ```
    id | grep docker
  Installation Directory

Run the command below to create the install directory for Smart Classifier ML:
  ```
  sudo mkdir -p /var/ayfie/smart-classifier-ml
  ```
Grant permissions with these commands after having replaced *\<username\>* with the service user:
  ```
  sudo chown <username>:docker /var/ayfie/smart-classifier-ml
  sudo chmod g+s /var/ayfie/smart-classifier-ml
  ```

# Installing
New versions of the Smart Classifier ML is released using the continuous delivery approach. The Smart Classifier ML is versioned using semantic versioning. When new versions within the same major version are released, *the smart-classifier-ml.ps1* script will discover that a new version is available and automatically upgrade to that new minor version.

## Running the Install Script

*Log in Createas the folder for Smart Classifier ML
  service user with this command:
  ```
  su <username>
  ```

Download the  sudo mkdir -pSmart Classifier ML installs script:
 ```
  cd /var/ayfie/smart-classifier-ml
  wget  ```
* Set permissions. Replace *username* with the name of the userhttps://nexus.ayfie.dev/repository/Raw-Hosted/smart-classifier-ml-releases/5/smart-classifier-ml.ps1
  ```
Run the install script:
    ```
    sudo chown username:docker /var/ayfie/pwsh smart-classifier-ml.ps1
  ```

sudoIn chmodthe g+s /var/ayfie/smart-classifier-ml
    ```
* Download the Smart Classifier ML installer:
   ```
    cd /var/ayfie/smart-classifier-ml
    wget https://nexus.ayfie.dev/repository/Raw-Hosted/smart-classifier-ml-releases/5/smart-classifier-ml.ps1
    ```
* Run the installer:
    ```
    pwsh smart-classifier-ml.ps1
    ```install script menu, fill in the information obtained in the prerequisites sections.

## Enable Smart Classifier Feature
Consult the *Smart Classifier* section of the [Install Guide](https://ayfie-dev.atlassian.net/wiki/spaces/SAGA/pages/2400714758/Ayfie+Locator+Installation+Guide) for how to enable the Smart Classifier feature. See also the *Managing Users and Roles* section for how to grant the *search.smart-classifier* permission to users that are to manage the Smart Classifiers.