How to deploy Kubernetes on Fuga Cloud
kubernetes containers

How to deploy Kubernetes on Fuga Cloud

Containerizing is a new way of deploying apps, when high availability and fast increments are required. Kubernetes is an amazing tool for orchestration of these apps. In this tutorial, we will configure Fuga and deploy Kubernetes on multiple instances.

First create a security group with access to all ports for inside the security group, so these instances can communicate freely between each other. Go the security tab, create an new security group and add the rule all TCP in the ‘ingress’ direction with remote ‘Security Group’ and security group current. If you only want to export specific ports, look at the table at the bottom of the page.

Spin up two or more instances with a minimum memory of 2gb (c1.small or up), this is what Kubernetes recommends. Connect these instances to a network. Also let the instances use the new security group, don’t forget to add a keypair. In this tutorial we will use Ubuntu 16.04, but other distro’s are also supported (take a look at https://kubernetes.io/docs/setup/independent/install-kubeadm/). Finally, allocate floating ip addresses for each instance.

Kubernetes Network

Afterwards, these floating ip addresses can be added to the ~/.ssh/config file on your local machine. This will make it easier to ssh to them. For example:

Host kubernetes1
    Hostname xxx.xxx.xxx.xxx
    user ubuntu
Host kubernetes2
    Hostname yyy.yyy.yyy.yyy
    user ubuntu

Now we SSH to the master instance.

Kubernetes

We will need docker to run Kubernetes.

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce

Afterwards, We will need to add the Google repository to the sources, so we can install Kubernetes.

sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl

We now can use kubeadm init to start our Kubernetes cluster. But first we need a pod network. This allows the pods to communicate with each other. If you have already used this command, kubeadm reset reverts this step. In this tutorial we will use Calico as the pod network.

Pod network

Stated below are the steps from the Calico quickstart guide:

https://docs.projectcalico.org/latest/getting-started/kubernetes/

Initialize the master node. The output from this step will be a kubeadm join command with the following format:

sudo kubeadm join 10.0.0.xxx:xxxxx --token aaaaa.aaaaaaaaaaaaaaaa --discovery-token-ca-cert-hash sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

We will save this for later somewhere, because we will need it in the next step when we join the workers to the master node.

sudo kubeadm init --pod-network-cidr=10.10.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Apply Calico on the master node.

kubectl apply -f \
https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml

Now we can see if the pods are running.

watch kubectl get pods --all-namespaces

Joining

Now, install docker, kubelet, kubeadm and kubectl on each instance with the steps explained above and then we can join the instances to the master with the command that we saved earlier. If you configured the master instance and ‘joined’ (with kubeadm join ...) all instances to master, you can check with this command if every instance is recognized correctly:

kubectl get nodes
Kubernetes Nodes

Now you have a Kubernetes cluster on your Fuga instances.

Port table

from https://kubernetes.io/docs/setup/independent/install-kubeadm/

Master node(s)

Protocol Direction Port Range Purpose
TCP Inbound 6443* Kubernetes API server
TCP Inbound 2379-2380 etcd server client API
TCP Inbound 10250 Kubelet API
TCP Inbound 10251 kube-scheduler
TCP Inbound 10252 kube-controller-manager
TCP Inbound 10255 Read-only Kubelet API

Worker node(s)

Protocol Direction Port Range Purpose
TCP Inbound 10250 Kubelet API
TCP Inbound 10255 Read-only Kubelet API
TCP Inbound 30000-32767 NodePort

** Default port range for NodePort Services. Any port numbers marked with * are overridable, so you will need to ensure any custom ports you provide are also open.

Was this article helpful?


Next article:

OpenStack disk and container formats for images

When you add an image to your image library in Fuga Cloud, you can specify its disk and container formats. An image is a bootable filesystem that contains an operating system. Images are the basis of instances (a virtual machine in OpenStack terminology). Disk formats The disk format of a virtual machine image is the format of the underlying disk image. Virtual appliance vendors have different formats for laying out the information contained in a virtual machine disk image.