# Daily Note 10/07/2020
###### tags: `Daily Notes` , `Kubernetes` , `AOI` , `Acumos`
## Name : Christofel Rio Goenawan
## University : Bandung Institute of Technology (ITB)
---
## Schedule:
1. Study deeper how to install Acumos AIO using aio_k8s_deployer.
2. Study deeper how to install Acumos AIO using PrepDeploy Process.
## Outcome :
1. Explain deeper how to install Acumos AIO using aio_k8s_deployer.
2. Explain deeper how to install Acumos AIO using PrepDeploy Process.
## Further Plan :
- Study more detailed about AIO Installation in Kubernets
- Study more detailed about Acumos AI architectures in Kubernetes.
- Try to deploy AIO in NTUST server.
---
## Daily Log
### 1. Study deeper how to install Acumos AIO using aio_k8s_deployer. <mark>(9.00)</mark>
- Study more detail explanation in [documentation](https://docs.acumos.org/en/clio/submodules/system-integration/docs/oneclick-deploy/user-guide.html#deployment-notes-for-specific-k8s-distributions) and other resources.
### 2. Study deeper how to install Acumos AIO using PrepDeploy Process. <mark>(14.00)</mark>
- Study more detail explanation in [documentation](https://docs.acumos.org/en/clio/submodules/system-integration/docs/oneclick-deploy/user-guide.html#deployment-notes-for-specific-k8s-distributions) and other resources.
---
## Report
### 1. Install and Deploying Acumos AIO via aio_k8s_deployer
> In this note Writer study deeper than the previous notes and use [documentation](https://docs.acumos.org/en/clio/submodules/system-integration/docs/oneclick-deploy/user-guide.html) as study sources. See previous notes [here ](https://hackmd.io/@christofel04/TEEP_Daily_Notes_09_7_2020).
#### Prerequisite
If the user has **cluster admin role** can include these prerequisite steps in the process below. The prerequisite steps can be shown as below.
1. The user has installed and has accessed to a remote k8s cluster (single/multi-node)
2. if the k8s cluster does not provide an ingress service with a registered DNS name for the platform ingress, the user needs to ensure that the external IP address to be used by the ingress controller is registered in DNS or configured in the hosts file of their workstation.
3. the user has installed a bash shell and docker on their workstation
4. the user has created a folder (referred to here as the “staging” folder) to contain any customizations to be used in this process, as described below
5. the user cloned the system-integration repo into the staging folder as subfolder “system-integration”
6. the user has prepared any desired customizations in the staging folder, as described under Customizing the aio_k8s_deployer environment
7. if not providing a k8s config file in the staging folder as described in Customizing the aio_k8s_deployer environment, the user has logged into the k8s cluster using the applicable client (kubectl or oc), so that the correct k8s config is present in ~/.kube/config
#### Installation
If the prerequisites fulfilled deployment can be launched with the single command below:
```script
$ bash system-integration/tools/tools/aio_k8s_deployer/aio_k8s_deployer.sh \
all <host> <user> <k8s distribution> [as-pod=<docker image>]
```
with:
- all: build the acumos_deployer image, prep, and deploy the platform
- host: hostname of k8s cluster master node
- user: SSH-enabled sudo user on the platform
- k8s distribution: type of k8s cluster (generic|openshift)
- as-pod: (optional) run the oneclick_deploy.sh script from within the cluster as an acumos-deployer pod
- as-pod provides the advantage of being able to run the deployer under the platform, and use it later as a platform maintenance/debug tool, containing all the customized and configured data for the deployment, as well as any additional tools/data you want to package in it
- you can specify the image “acumos-deployer” which will be built locally by aio_k8s_deployer.sh, or a pre-built/customized image in a docker registry, e.g. blsaws/acumos-deployer in Docker Hub, which offers tags for use with generic k8s (tag: latest or kubectl) or OpenShift (tag: oc)
When aio_k8s_deployer.sh is called with first parameter “all” , the process step can be shown below.
1. Archive any earlier deployment in folder ``aio_k8s_deployer`` into a timestamped subfolder of “archived”.
2. Create a new subfolder “aio_k8s_deployer”.
3. Copy everything in the staging folder (except for folders “archived” and “aio_k8s_deployer”) as staged customizations into “aio_k8s_deployer/deploy”.
4. If there is a version of aio_k8s_deployer.sh in the staging folder, copy that to “aio_k8s_deployer” since presumably the user has customized it; otherwise the current version will be copied from the system-integration clone.
5. Kick off the build, prep, and deploy process.
The full detailed scheme of how to instal Acumos AI using aio_k8s_deployer can be seen as below.

---
### 2. Install and Deploying Acumos AIO using PrepDeploy Process.
> In this note Writer use [documentation] (https://docs.acumos.org/en/clio/submodules/system-integration/docs/oneclick-deploy/user-guide.html) and other references as study sources.
#### What is PrepDeploy Process?
**PrepDeploy** is the **original two-stage process which has been automated by the aio_k8s_deployer for k8s based deployments**. It is required for docker based deployments.
The process is called Prep-Deploy as it is broken down into two stages:
1. **Host/cluster preparation**, executed by a host/cluster admin (sudo user) through the system-integration/AIO/setup_prereqs.sh script
2. **Platform deployment**, executed by a normal user through the oneclick_deploy.sh script
#### Using PrepDeploy Process as Privileged User
This process is for a privileged (sudo, not root) user that wants to execute deployment process using their host account. To deploy the Acumos platform with the default options, as a user on a linux host with **at least 16GB RAM** and **admin (sudo) permission**, the process can be shown as below.
1. Clone the system-integration repo.
```
$ git clone https://gerrit.acumos.org/r/system-integration
```
2. Using bash, check if the user is part of the docker group, and add if not.
```
$ if [[ "$(id -nG "$USER" | grep docker)" == "" ]]; then sudo usermod -aG docker $USER; fi
```
3. If we don’t have an existing k8s cluster, set up cluster by command below.
:::info
**NOTE:** This command will setup a single-node k8s cluster using the generic k8s distribution (for Ubuntu) or OpenShift (for Centos). It also installs docker-ce and links /var/lib/docker to /mnt/docker to avoid out of space issues on the root volume, which can destabilize your k8s cluster. Make sure you have the /mnt folder on a device with adequate disk, e.g. at least 256GB.
:::
```
$ bash system-integration/tools/setup_k8s_stack.sh setup
```
3. Install/configure prerequisites, including k8s, MariaDB, and the ELK stack, using your user account, and the hostname or domain name we will use to access the deployed platform using command below.
```
$ bash system-integration/AIO/setup_prereqs.sh k8s <domain> $USER <generic|openshift> 2>&1 | tee aio_prep.log
```
4. When we see ***“Prerequisites setup is complete.”*** as the result of the command above, complete platform setup by execute the following commands.
```
$ cd system-integration/AIO
$ bash oneclick_deploy.sh 2>&1 | tee aio_deploy.log
```
5. The commands above include saving of the detailed deployment actions to a log file ‘deploy.txt’. This aim for getting support from the Acumos project team, to overcome issues we might encounter. If we don’t want to save the log, just leave out the part of the commands above that starts with the ‘pipe’ (‘|’).
:::info
**Next Writer will try to learn more details of the Acumos AIO Architectures and try to install Acumos in NTUST server.**
:::
---
## Reference
1. https://docs.acumos.org/en/clio/submodules/system-integration/docs/oneclick-deploy/user-guide.html#deployment-notes-for-specific-k8s-distributions
2. https://www.programmersought.com/article/3984216951/