How to deploy Kubernetes and Containerum on Digital Ocean
How to deploy Kubernetes and Containerum on Digital Ocean
![](https://cdn-images-1.medium.com/freeze/max/60/1*xd50axfTOf06pr9y7Nm8Gw.png?q=20)
![](https://cdn-images-1.medium.com/max/1600/1*xd50axfTOf06pr9y7Nm8Gw.png)
by Nikita Mazur
Foreword
Several days ago we decided that Containerum Online — a hosted PaaS for launching and managing docker images, which has been running for about a year by now — will not be supported anymore and will be closed for registration within a week.
It was not a spontaneous decision — back in February we started rewriting Containerum for open source, and in May Containerum Platform 1.0 was released on GitHub. Since then we concentrated on the open source version, and the more time and effort we invested in it, the clearer it became that this model gives us more flexibility and opportunities for development and communication with community.
As of now, Containerum Platform 1.2.0 provides many of the features introduced with Containerum Online and brings in new functionality, but now it works on top of a Kubernetes cluster and can be installed via Helm (a dedicated installer is a WIP now). This article will describe the installation steps to run your own Kubernetes+Containerum cluster on Digital Ocean machine(s).
Let’s start
We will assume that you don’t have a Kubernetes cluster yet (in case you have one, skip Kubernetes installation process). In this tutorial we will install Containerum Platform on a small demo K8s cluster. We will setup it on a Digital Ocean instance since it is very easy to provision a machine, and the price is very reasonable.
Here’s what we will do in this tutorial:
- Buy machines on Digital Ocean
- Install Kubernetes with Kubeadm
- Install ingress-controller
- Install Helm
- Install Containerum
So, let’s go!
Buy a machine on Digital Ocean
For the sake of simplicity we will setup a single-node Kubernetes cluster. Of course, a production-ready Kubernetes cluster demands a lot more that just one node — you need at least one master, three workers, three etcd and three storage nodes. However, if you want to try working with Kubernetes in cloud, the basic configuration used throughout this article will do.
We recommend using a machine that is at least 2CPU and 2GB RAM. The machine I will use has 2CPU, 4GB RAM to ensure better performance. Machines on DO are billed on an hourly basis, so if you just want to bootstrap a cluster for experimentation, you can buy a powerful machine for several hours/days and pay very little.
→ We will use Ubuntu 18.04 x64 throughout the manual.
Install Kubernetes with Kubeadm
Once we have bought a machine, ssh to it:
ssh [email protected]'S_IP
We will use kubeadm to bootstrap a single-node cluster. Kubeadm is an easy Kubernetes installer which allows setting up a cluster in a matter of minutes. We will Docker as container runtime. So, first install Docker:
apt-get updateapt-get install -y docker.io
Then install kubeadm, kubelet (node agent) and kubectl (Kubernetes cli):
apt-get update && apt-get install -y apt-transport-https curlcurl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -cat <<EOF >/etc/apt/sources.list.d/kubernetes.listdeb http://apt.kubernetes.io/ kubernetes-xenial mainEOFapt-get updateapt-get install -y kubelet kubeadm kubectlapt-mark hold kubelet kubeadm kubectl
→ Optional: in case you want to use worker nodes, you should run the commands above (including Docker installation) on all nodes.
Now initialize kubeadm. First, we have to choose the CNI plugin for our cluster and pass the flag to kubeadm init
. We will use Calico, but if you want to use Flannel or another plugin, you can see the flags here. Let’s initialize kubeadm with Calico:
kubeadm init --pod-network-cidr=192.168.0.0/16
To make kubectl work for your non-root user, run:
mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/config
→ Optional: in case you use more than one node, run the command starting with kubeadm join
(you can find it in the output after kubeadm intialization) on all worker nodes.
Now let’s install the CNI. For Calico run:
By default, deployments are not scheduled on the master node. To enable it on a single-node cluster, run:
kubectl taint nodes --all node-role.kubernetes.io/master-
Done! You’ve just bootstrapped a Kubernetes cluster. Check if it works by running
kubectl get pods --all-namespaces
You should now see that all pods are running.
![](https://cdn-images-1.medium.com/freeze/max/60/1*Rfj3kfVYCpU1t0GUwQhSww.png?q=20)
![](https://cdn-images-1.medium.com/max/1600/1*Rfj3kfVYCpU1t0GUwQhSww.png)
Now let’s install Nginx Ingress-Controller.
Install ingress-controller
In order to configure an HTTP load balancer Kubernetes uses an object called Ingress. But for the Ingress resource to work, the cluster must have an Ingress controller running. In this manual we will use Nginx Ingress-Controller.
Installing an ingres-controller is pretty simple. First, install it from the Kubernetes repository:
Second, create ingress-controller.yaml
for the service with the following content (change %EXTERNAL IP% to the machine’s external ip address):
apiVersion: v1kind: Servicemetadata: name: ingress-nginx namespace: ingress-nginxspec: ports: - name: http port: 80 targetPort: 80 protocol: TCP - name: https port: 443 targetPort: 443 protocol: TCP selector: app.kubernetes.io/name: ingress-nginx externalIPs: - %EXTERNAL IP%
Now create the service:
kubectl create -f ingress-controller.yaml
Check it:
kubectl get svc -n ingress-nginx
Output:
![](https://cdn-images-1.medium.com/max/1600/1*kMsL1q_kq31_pBjiipn6SA.png)
Ok, now let’s install Helm.
Install Helm
Helm is a package manager for Kubernetes that makes it easy to install many applications (including Containerum Platform) just like yum for CentOS and apt for Ubuntu. To install Helm download the binary from the official repository. We will use v. 2.10.0 Summer Edition ?:
Unpack the archive:
tar xvf helm-v2.10.0-linux-amd64.tar.gz
Move Helm to /usr/bin:
mv linux-amd64/helm /usr/bin
Now we need to create a service account for Helm. Create rbac-config.yaml
as follows:
apiVersion: v1kind: ServiceAccountmetadata: name: tiller namespace: kube-system---apiVersion: rbac.authorization.k8s.io/v1beta1kind: ClusterRoleBindingmetadata: name: tillerroleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-adminsubjects: - kind: ServiceAccount name: tiller namespace: kube-system
Now run:
kubectl create -f rbac-config.yaml
Finally, initialize Helm:
helm init --service-account tiller
You should get a message like this:
![](https://cdn-images-1.medium.com/freeze/max/60/1*8E1-VOvtUDR5HuNKHbR49A.png?q=20)
![](https://cdn-images-1.medium.com/max/1600/1*8E1-VOvtUDR5HuNKHbR49A.png)
All right, all we have left to do now is install Containerum Platform!
Install Containerum Platform
You can install Containerum in its basic configuration with helm install containerum/containerum
, but will pass some flags to launch it with Prometheus for metrics collection and mail server that allows you to use mail templates for registering new users.
Before we run the commands, let’s look at the two flags we will use in Helm. The following flag enables node monitoring and installs Prometheus.
--set tags.monitoring=true
The next flag enables smtp-server.
Don’t forget to change the fields appropriately: - mail:465
- mail smtp server address and port- [email protected]
— your login- verystrongpassword
- your password - [email protected]
- sender’s email
You can use your mail account, for example smtp.gmail.com:465
if you use gmail, and your credentials there.
Let’s install Containerum Platform as follows:
Check that all pods are up:
kubectl get po
![](https://cdn-images-1.medium.com/freeze/max/60/1*2FmhRDi1a5qMH7oM1IF6Vg.png?q=20)
![](https://cdn-images-1.medium.com/max/1600/1*2FmhRDi1a5qMH7oM1IF6Vg.png)
Now add the machine’s IP address to /etc/hosts
on your local machine:
sudo nano /etc/hosts
Add the following string and save:
EXTERNAL_IP local.containerum.io api.local.containerum.io
Note, that Containerum Platform launches pods only on nodes labelled as slave
, so for our single-node cluster we have to run the following command on the master (and in case of a multi-node cluster — on each application node):
kubectl label node NODENAME role=slave
where NODENAME
is the nome of your host.
Go to local.containerum.io and login using the standard credentials [email protected]
and verystrongpassword
:
![](https://cdn-images-1.medium.com/freeze/max/60/1*qxfaJ0dkmkhG4HEtO-ZIjg.png?q=20)
![](https://cdn-images-1.medium.com/max/1600/1*qxfaJ0dkmkhG4HEtO-ZIjg.png)
Now you can launch and manage your applications using Containerum Platform, see node utilization metrics, manage users, and more!
![](https://cdn-images-1.medium.com/freeze/max/60/1*IvMhiH5m3GVXXzJlHKVyqw.png?q=20)
![](https://cdn-images-1.medium.com/max/1600/1*IvMhiH5m3GVXXzJlHKVyqw.png)
![](https://cdn-images-1.medium.com/freeze/max/60/1*-6BT3eFf-k1ozfK0yUXOkQ.png?q=20)
![](https://cdn-images-1.medium.com/max/1600/1*-6BT3eFf-k1ozfK0yUXOkQ.png)
You can start with creating a project and launching an application from Docker Hub, but I recommend you to spend five minutes configuring the platform first — add a private registry, external IP, etc. (see docs).
After that you will have a Kubernetes cluster with Helm and Containerum Platform on board. Containerum allows abstracting users from Kubernetes and working with Deployments, Services, and others Kubernetes objects from an intuitive Web UI.
As of September 2018, Containerum Platform is quite young, but full of enthusiasm and ambitions. We are constantly working on new features (and bugfixes), delivering new releases every several weeks or so. We have a team of great developers and engineers, but what we really lack is feedback. And building a good solution without feedback is tough. So if you have something to add or advice us, suggest a new feature or report a bug, please share on the GitHub page! This will help us shape Containerum Platform in the right direction.
Thanks for reading! I hope the instructions here are quite clear and easy to follow, but please comment if I missed something.
Don’t forget to follow us on Twitter and join our Telegram chat to stay tuned!