---
# System prepended metadata

title: Daily Note 08/07/2020
tags: [AOI, Daily Notes, Kubernetes, Acumos]

---

# Daily Note 08/07/2020
###### tags: `Daily Notes` , `Kubernetes` , `AOI` , `Acumos`
## Name : Christofel Rio Goenawan
## University : Bandung Institute of Technology (ITB)


---

## Schedule:
1. First Week Meeting and Report.
2. Try to deploy Docker in PC.
3. Study how to run Acumos AI on Kubernetes.
4. Try to connect to NTUST server.
## Outcome : 
1. Build Docker image and container in PC.
2. Explain how to install Acumos on Kubernetes.
3. Connect to NTUST server.
## Further Plan : 
- Try to deploy Kubernetes in PC
- Study more detailed about AIO Installation in Kubernets
- Try to deploy AIO in NTUST server.


---

## Daily Log

### 1. First Week Meeting and Report. <mark>(9.00)</mark>
- In this meeting Writer presents the progress and latest result to Prof Ray, mentors and internee.


### 2. Try to deploy Docker in PC. <mark>(11.30)</mark>
-  Studying [reference](https://www.scalyr.com/blog/create-docker-image/) and [Fandi Azam's Notes](https://hackmd.io/@EHEAmKPKSYmpHcyPeiO8jQ/rkGSGt5HI).
-  Try to deploy Docker in PC.

### 3. Study how to install Acumos AI on Kubernetes. <mark>(13.30)</mark>
- Study explanation in [documentation](https://docs.acumos.org/en/clio/submodules/system-integration/docs/oneclick-deploy/user-guide.html#deployment-notes-for-specific-k8s-distributions).
- Learn deeper detailed from pre- internship notes.

### 4. Try to connect to NTUST server. <mark>(16.30)</mark>
- Connect to NTUST server through ssh.



---

## Report
### 1. Build Docker Image

> In this note writer use Fandi Azam's notes about Docker as reference. The notes can be seen [here](https://hackmd.io/@EHEAmKPKSYmpHcyPeiO8jQ/rkGSGt5HI)

### Installing Docker
First Writer install docker in linux shell as below.

```
sudo apt-get install docker.io
```

![](https://i.imgur.com/TjmX2HO.png)

Then writer enable the docker service and start the docker as below.

```
systemctl enable docker
```
```
systemctl start docker
```

Then docker will start. 

### Create Dockerfile

Then Writer create new files name "myImage" by code below.
```
mkdir ~/myimages
```

```
cd myimages/
```

Then writer create **Dockerfile** using ***touch*** command in Linux shell as below.

```
touch Dockerfile
```

Then write the dockerfile using ***nano*** command in Linux shell as below.

```
nano Dockerfile
```

Then copy this script to dockerfile.

```Dockerfile
#Download base image ubuntu 16.04
FROM ubuntu:16.04

#Update 
RUN apt-get update

#Install Nginx, php-fpm and superfisord as a dependencies from ubuntu repository
RUN apt-get install -y nginx php7.0-fpm supervisor && \
    rm -rf /var/lib/apt/lists/*
    
#Configuring those dependencies,

#Define the ENV variable
ENV nginx_vhost /etc/nginx/sites-available/default
ENV php_conf /etc/php/7.0/fpm/php.ini
ENV nginx_conf /etc/nginx/nginx.conf
ENV supervisor_conf /etc/supervisor/supervisord.conf

#Enable PHP-FPM on Nginx virtual host configuration
COPY default ${nginx_vhost}
RUN sed -i -e 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' ${php_conf} && \
    echo "\ndaemon off;" >> ${nginx_conf}
    
#Configure Supervisord for Nginx and PHP-FPM

#Copy supervisor config
COPY supervisord.conf ${supervisor_conf}

#Create a new directory for php-fpm, changing /var/www/html owner directory and PHP directory to www-data
RUN mkdir -p /run/php && \
    chown -R www-data:www-data /var/www/html && \
    chown -R www-data:www-data /run/php
    
#Define the volume, so we can mount the directories listed to the host machine

#Volume config
VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]

#Last but not least, setup the default container command CMD and open the port for HTTP and HTTPS.

#Creating a new start,sh file for default CMD command when container is starting. This file contains the supervisord command, and copy the file to the new image with the COPY docker command.

#Configure Services and Port
COPY start.sh /start.sh
CMD ["./start.sh"]
 
EXPOSE 80 443
```
![](https://i.imgur.com/aoonq82.png)

Then Writer create a new configuration file for the virtual host named ‘default’ a supervisord configuration file ‘supervisord.conf’ and a service configuration script ‘start.sh’. The code can be shown as below.

**default**
```default
server {
    listen 80 default_server;
    listen [::]:80 default_server;
 
    root /var/www/html;
    index index.html index.htm index.nginx-debian.html;
 
    server_name _;
 
    location / {
        try_files $uri $uri/ =404;
    }
 
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
 
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny all;
    #}
}
```
![](https://i.imgur.com/vX2wuIM.png)

**supervisord.conf**
```conf
[unix_http_server]
file=/dev/shm/supervisor.sock   ; (the path to the socket file)
 
[supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10           ; (num of main logfile rotation backups;default 10)
loglevel=info                ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false               ; (start in foreground if true;default false)
minfds=1024                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)
user=root             ;
 
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
 
[supervisorctl]
serverurl=unix:///dev/shm/supervisor.sock ; use a unix:// URL  for a unix socket
 
; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.
 
[include]
files = /etc/supervisor/conf.d/*.conf
 
 
[program:php-fpm7.0]
command=/usr/sbin/php-fpm7.0 -F
numprocs=1
autostart=true
autorestart=true
 
[program:nginx]
command=/usr/sbin/nginx
numprocs=1
autostart=true
autorestart=true
```

![](https://i.imgur.com/x8OSSSg.png)

**start.sh**

```shell=
#!/bin/sh

/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
```

Then make ***start.sh*** executable using this command.

```
chmod +x start.sh
```

#### Build New Docker Image and Create Container

To build image, use this code in Linux terminal.
```
sudo docker build -t nginx_image .
```

![](https://i.imgur.com/i8LXxgP.png)

#### Create a new container

To create container, first use superuser mode by this code in Linux terminal.

```
sudo -i
```

Then create root directory as below.

```
mkdir -p /webroot
```

Then check container that we built by this code.

```
docker ps
```

![](https://i.imgur.com/Iryj0kR.png)

#### Testing Nginx and Container

To testing Nginx first create HTML file in the webroot with the code below.

```sh
echo '<h1>Hello World</h1>' > /webroot/index.html
```

Then we can testing the server by using ***curl***. First we need to know the server address.

:::info
**How to check IP Address**
Step 1: Know container ID by "docker ps" command
Step 2: Copy the container id
Step 3: "docker inspect <container_id>" in terminal
Step 4: Find the IP Adress
:::

Then we can check it by curl in terminal with the code below.

```
curl <IP Address>
```

The result can be seen as below.

![](https://i.imgur.com/f72A5IY.png)


![](https://i.imgur.com/gzbNMTX.png)

It can be seen that the HTML file works well that show container and Nginx work well.

#### Docker Architecture
By this hands- on we install both Docker **client** and **server**. We can check it by the command below.

```
docker version
```

![](https://i.imgur.com/23IuLnn.png)




:::info
**Next Writer will try to learn deploying Kubernetes in PC.**
:::

---

### 2. How to Install Acumos on Kubernetes ?

> In this note Writer use [documentation](https://docs.acumos.org/en/clio/submodules/system-integration/docs/oneclick-deploy/user-guide.html) as study sources


#### What is AIO Deploy ?
From documentation , All inn One Deploy ( usually called "AIO Deploy" ) are **tools designed for those who want a simple and automated way to deploy an Acumos platform**. By default the AIO deploy tools build an all needed component in  instance of Acumos, with all Acumos data and components running under Docker or its Orchestrator ( Kubernetes ) on a single virtual machine or physical host machine.


There are 3 options for user to deploy AIO as below.
1. On a cluster of Kubernetes nodes.
2. With a subset of components.
3. Use some components that have previously deployed somewhere, example  as a shared service

#### Acumos AIO Architectures in Kubernetes

![](https://i.imgur.com/a6czWiK.png)


:::info
**Next Writer will try to learn each details of this architectures.**
:::

---


### 3. Connect to NTUST Server.

To connect with NTUST server by ssh , Writer use this code in shell terminal.

```
ssh <username>@<IP>
```

And after write the password, Writer successfully connect to NTUST server. The interface can be shown as below.


![](https://i.imgur.com/fvZBgu0.png)

:::info
**Next Writer will try to learn deploying Acumos AI Platform on Kubernetes in this server.**
:::

## Reference
1. https://www.scalyr.com/blog/create-docker-image/
2. https://docs.acumos.org/en/clio/submodules/system-integration/docs/oneclick-deploy/user-guide.html