Deploying Susi.AI on Servers
What is Susi?
Social Universal Super Intelligence shortly SUSI ;), is a open source personal assistant. It is capable of doing many intelligent tasks. Founders of susi wanted to create wikipedia model of intelligence, where anyone can contribute and correct susi.They created susi and robust skills framework. If you want to contribute, please have a look at Susi Skill Development Tutorial .
Deploying Susi with Docker
First let us discuss, what is docker and why use docker? Docker is open source tool which provides higher level of abstraction to run a program ie., docker has its own operating system and other configurations. Docker container can run on windows, mac os and linux based system. Docker is much more efficient than VM in allocating shared resources between various containers as shown in figure.
To deploy susi we need to create docker container. There are two ways to build it. First way is fork the susi project in github. Then you can signup in dockerhub and create autobuild docker container. The second way is to manually build docker file from command prompt of your computer. The following instructions needs to be executed in cloud shell or linux machine.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get -y install docker.io
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo docker build https://github.com/fossasia/susi_server.git
First three commands install docker software to the machine. Next three lines give required permissions and execution abilities to docker. Final command builds docker container from github. We have succesfully made docker container. We can deploy it on cloud by using following command.
sudo docker run -d -p 80:80 -p 443:443 susi
Introduction to kubernetes
Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications. Kubernetes is designed to horizontally scale the application according to load from the servers. It enables higher level of abstraction ie., we need not worry about single server’s host ip, ports and other stuff. Kubernetes enables us to abstract collections of servers as single computing machine. To do that kubernetes has various tools.
“Master” refers to a collection of processes managing the cluster state. When you use “Kubectl” command, you are referencing to master of the cluster.
nodes in a cluster are the machines that run your applications and cloud workflows. Kubernetes master controls each node; you’ll rarely interact with nodes directly.
It manages and schedules various nodes. It has ability to create new nodes and match the load according to requirement. Each replica will run on a different Kubernetes node.
A Pod represents a unit of deployment: a single instance of an application in Kubernetes, which might consist of either a single container or a small number of containers that are tightly coupled and that share resources. A Pod encapsulates an application containers, storage resources, a unique network IP, and other details. Containers in same pod will work like on same machine. They will have same life cycle.
To learn more about kubernetes, Please go through their documentation.
Deploying Application on cloud with kubernetes
We will use Google Cloud Service platform for demonstration. Create your GCS account. Goto console and enter following commands
gcloud config set compute/zone us-central1-a
gcloud container clusters create example-cluster
gcloud auth application-default login
kubectl run myapp — image= docker-id — port=8080
kubectl expose deployment myapp — type=”LoadBalancer”
kubectl get service myapp
The first command sets your compute zone to us-central-1a. You can change it to any location of your choice. Second command creates an cluster for deployment of app. Fourth command runs your docker container on kubernetes and exposes the port of container. Fifth command deploys your app on kubernetes and connects it to external load balancer. Sixth command gives you, the ip address, where the app is running .You can view the app by going to “ip:port”.
In case of doubts, please feel free to contact me at firstname.lastname@example.org