Note
This guide is suitable for users with some experience using MyElits (Openstack) and Linux.
Kubernetes (k8s) is an open-source system for automating deployment, scaling, and management of containerized applications. You can use it to:
- Deploy your applications quickly and predictably.
- Scale your applications on the fly.
- Roll out new features seamlessly.
- Limit hardware usage to required resources only.
Kubespray is a tool that can be used to deploy Kubernetes on Openstack. It supports most popular Linux distributions and is highly customizable.
In this guide we will:
- Launch and configure a management server which will be used to run Kubespray.
- Deploy Kubernetes on three servers (one master and two nodes).
Management Server
Let's start by creating the management server in our Openstack project.
Name | kubespray |
Source | Ubuntu 16.04 (Xenial Xerus) |
Volume Size | 10 GB |
Flavour | 1 CPU 1 GB |
Networks | default-network |
Security Groups | default, ssh |
Key Pair | Your own keypair |
Assign your server a floating IP so you can SSH to it.
SSH to the kubespray server and run:
$ ssh-keygen -t rsa
$ sudo apt-get update
$ sudo apt-get install python-pip
$ sudo pip install ansible kubespray shade
Copy your new SSH-key from ~/.ssh/id_rsa.pub and add it as a new key in MyELITS or copy your existing key to the kubespray server.
A configuration file will be created in ~/.kubespray.yml. Edit it to your liking, example:
# OpenStack options
os_auth_url: "https://lpi-api.elits.com:5000/v2.0"
os_username: "Your MyELITS email"
os_password: "Your MyELITS password"
os_project_name: "Your MyELITS project name"
os_region_name: "RegionOne" # RegionOne for Linkoping or Stockholm
masters_flavor: "general1-2" # 2 CPU 2 GB RAM
nodes_flavor: "general1-2" # 2 CPU 2 GB RAM
etcds_flavor: "general1-2" # 2 CPU 2 GB RAM
image: "Ubuntu 16.04 (Xenial Xerus)"
network: "default-network"
sshkey: "kubespray"
#
After everything is configured, run:
# 1 master and 2 workers
$ kubespray openstack --masters 1 --nodes 2 --etcds 1
This will create three servers in MyELITS and configure kubespray in ~/.kubespray/.
Ubuntu 16.04 only ships with python3 while python2 is required on all hosts for ansible to work correctly. Therefore we use ansible to install it:
$ ansible -i ~/.kubespray/inventory/inventory.cfg all --sudo -m raw -a "apt-get update && apt-get install -y python python-simplejson"
Now it's time to deploy kubernetes on the nodes:
$ kubespray deploy
If everything was successful you should now see:
Kubernetes deployed successfuly
You can look in ~/.kubespray/inventory/inventory.cfg to see which of your servers is master.
SSH to the master and run:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-antagonism-161lhh Ready node 1h v1.8.4+coreos.0
k8s-antagonism-b7jqrj Ready node 1h v1.8.4+coreos.0
k8s-antagonism-df6eyf Ready master 1h v1.8.4+coreos.0
If it's your first time running Kubernetes you can continue with this guide to deploy a stateless application.
Sources:
- https://kubernetes.io/
- https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/
- https://github.com/kubernetes-incubator/kubespray
Comments
Article is closed for comments.