---
# System prepended metadata

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

---

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


---

## Schedule:
1. Study detailed background ( what ? why ? how ? ) of Docker and Kubernetes.
2. Study works of Kubernetes.
3. Study how to run Acumos AI on Kubernetes.
## Outcome : 
1. Explain characteristics and detailed work of Docker.
2. Explain characteristics of Kubernetes.
3. Explain basic how to run Acumos AI on Kubernetes.
## Further Plan : 
- Learn how to install Acumos AI in Kubernetes.
- Try to use Docker in PC.


---

## Daily Log

### 1. Study detailed background ( what ? why ? how ? ) of Docker and Kubernetes. <mark>(9.00)</mark>
- Write detailed characteristics of Docker from [Johny's slide](https://drive.google.com/file/d/16u1ePiD053ddtsdWN5bRT7Pg3gpi8HAj/view) and other references.
- Write detailed works of Docker form [Docker's Documentation](https://docs.docker.com/get-started/overview/).

### 2. Study works of Kubernetes. <mark>(12.30)</mark>
- Write detailed explanation of Acumos AI Architectures by reading [Zhui Sao's Paper](https://drive.google.com/file/d/1zKe5CBkIy35jH2PFl2hngqndKHMbpmjo/view?usp=sharing).

### 3. Study how to run Acumos AI on Kubernetes. <mark>(13.30)</mark>
- Watch detailed explanation video in [reference [2]](https://drive.google.com/file/d/1aBP0IMIXiSXIw2nT3Q9K-AaImHEixSID/view?usp=sharing).
- Learn deeper detailed from pre- internship notes.



---

## Report
### 1. How Docker Works ?

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

#### What is Docker ?
Docker is a open platform for developing, shipping, and running applications that designed to make it easier to **create, deploy, and run applications** by using **containers**. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.

#### What is Container ?
![](https://i.imgur.com/Z2btap6.png)


Containers are an **abstraction at the app layer that packages code and dependencies together**. Some containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space. Containers take up less space than VMs (container images are typically tens of MBs in size), can handle more applications and require fewer VMs and Operating systems. The difference between Container and VM can be shown as below.

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


Containers can be thought of as necessitating three categories of software:

1. Builder: Tools to build a container.
2. Engine: Tools to run a container.
3. Orchestration: Tools to manage many containers.

#### How Docker Works ?
One of the main component of Docker is **Docker Engine**. Docker Engine used **client-server model** with these 3 major components:

1. A server which is a type of long-running program called a **daemon process** (the dockerd command).
2. A **REST API** which specifies interfaces that programs can use to talk to the daemon and instruct it what to do.
3. A command line interface (**CLI**) client (the docker command). 

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

The CLI uses the Docker REST API to control or interact with the Docker daemon through scripting or direct CLI commands. Many other Docker applications use the underlying API and CLI.

First the Docker client talks to the Docker daemon, which does the building, running, and distributing your Docker containers. The Docker client and daemon can run on the same system or we can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate using a REST API through UNIX sockets or a network interface. The simple Docker architecture can be seen as below.

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

#### Why using Docker ?
From [Johny's Slide](https://drive.google.com/file/d/16u1ePiD053ddtsdWN5bRT7Pg3gpi8HAj/view) there are 4 advantages of Docker.
1. **It can use only one machine to deploy cluster.**
2. **Easy to expand.**
3. **Create VM is much quickly than installing physiscal machines.**
4. **Easy to isolate machine.**



---

### 2. How Kubernetes Works ?

#### What is Kubernetes ?
Kubernetes is a **portable, extensible, open-source platform** for **managing containerized workloads and services**, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.Kubernetes can orchestrate host across on-premise, public, private, or hybrid clouds. For this reason, Kubernetes is an ideal platform for hosting cloud-native applications that require rapid scaling, like real-time data streaming through Apache Kafka.

#### How Kubernetes works ?
The simple scheme of Kubernetes cluster structures can be seen as below.

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


There are some main components in Kubernetes Cluster.

1. **Kubernetes API Server**
Kubernetes API server is a  Kubernetes API using JSON over HTTP, which provides both the internal and external interface to Kubernetes.

3. **Scheduler and Controler Manager**
The controllers through API server  create, update, and delete the resources they manage . Scheduler tracks resource use on each node to checking whether the workload is not scheduled in excess of available resources. In a cluster, Nodes that meet the scheduling requirements for a Pod are called ***feasible nodes***. If none of the nodes are suitable, the pod remains unscheduled until the scheduler is able to place it.

5. **Etcd**
Etcd is a distributed key-value store in Kubernetes Cluster. It storing and replicating all Kubernetes cluster state. 

7. **Kubelet**
The kubelet is the primary “node agent” that runs on each node. The kubelet works in terms of a PodSpec. A PodSpec is a YAML or JSON object that describes a pod. The kubelet takes a set of PodSpecs that are provided through various mechanisms (primarily through the apiserver) and ensures that the containers described in those PodSpecs are running and healthy. The kubelet doesn’t manage containers which were not created by Kubernetes.

9. **Kubernetes Proxy**
Kubernetes proxy runs on each node. This reflects services as defined in the Kubernetes API on each node and can do simple TCP, UDP, and SCTP stream forwarding or round robin TCP, UDP, and SCTP forwarding across a set of backends.It is responsible for routing traffic to the appropriate container based on IP and port number of the incoming request.

11. **Pod**
A Pod is the basic execution unit of a Kubernetes application. It is the smallest and simplest unit in the Kubernetes object model that you create or deploy. A Pod represents processes running on your cluster.
![](https://i.imgur.com/DzRdq33.png)

#### Deployment and Services in Kubernetes
Deployment in Kubernetes is used to **create, manage and delete pods**. It provides declarative updates for Pods and Replica Sets. You describe a desired state in a Deployment, and the **Deployment Controller** changes the actual state to the desired state at a controlled rate. You can define Deployments to create new Replica Sets, or to remove existing Deployments and adopt all their resources with new Deployments. The simple master- worker deployment can be shown as below.

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

In the deployment The scheduler would see which nodes are free and can be allocated. The full architecture deployment can bee seen as below.

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




---

### 3. Run Acumos AI on Kubernetes.
> In this note writer use documentation in [here](https://docs.acumos.org/en/athena/submodules/system-integration/docs/k8s-deployment.html)

#### Why using Kubernetes?
From documentation, the main goal of k8s-based deployment is to enable advanced features provided by k8s environments, including:

1. **scalability**
2. **resiliency**
3. **distributed, multi-node deployment


:::info
**Next Writer will try to learn deploying Acumos AI Platform on Kubernetes from documentation.**
:::



---

## Reference
1. https://docs.docker.com/get-started/overview/
2. https://www.redhat.com/en/topics/containers/what-is-kubernetes
3. https://drive.google.com/file/d/16u1ePiD053ddtsdWN5bRT7Pg3gpi8HAj/view
4. https://docs.acumos.org/en/clio/submodules/system-integration/docs/oneclick-deploy/user-guide.html#deployment-notes-for-specific-k8s-distributions