Kubespray
Kubespray is a project under the Kubernetes incubator. Its mission is to provide a production-ready Kubernetes deployment solution. The project is based on Ansible Playbook to define system and Kubernetes cluster deployment tasks, with the following characteristics:
It can be deployed on AWS, GCE, Azure, OpenStack, and bare metal.
It allows for the deployment of highly available Kubernetes clusters.
It is composable, allowing users to choose Network Plugin (flannel, calico, canal, weave) for deployment.
It supports various Linux distributions (CoreOS, Debian Jessie, Ubuntu 16.04, CentOS/RHEL7).
This article will explain how to deploy Kubernetes to bare metal nodes using Kubespray. The versions will be as follows:
Kubernetes v1.7.3
Etcd v3.2.4
Flannel v0.8.0
Docker v17.04.0-ce
Node Information
The operating system for the installation test environment will be Ubuntu 16.04 Server and the other details are as follows:
IP Address | Role | CPU | Memory |
---|---|---|---|
192.168.121.179 | master1 + deploy | 2 | 4G |
192.168.121.106 | node1 | 2 | 4G |
192.168.121.197 | node2 | 2 | 4G |
192.168.121.123 | node3 | 2 | 4G |
Here, the master is the primary control node, and the node is the work node.
Preparatory Information
All nodes' networks can communicate with each other.
The deployment node (here, master1) can log in to other nodes without needing SSH passwords.
All nodes possess Sudoer permissions and don't require password input.
All nodes need to have Python installed.
All nodes need to set
/etc/hosts
to resolve all hosts.Modify all nodes'
/etc/resolv.conf
The deployment node (here, master1) installs Ansible >= 2.3.0.
The process for installing Ansible on Ubuntu 16.04 is as follows:
Installing Kubespray and Preparing Deployment Information
First, install kubespray-cli through pypi. Although the official sources say they have switched to a Go language version of the tool, it hasn't been updated, so we'll use the pypi version for now:
After installation, add a configuration file ~/.kubespray.yml
and include the following content:
Then use the kubespray cli to generate an inventory file:
Add some content in the inventory.cfg:
You can also create a new
inventory
to describe the deployment nodes.
After completing the above, execute the following command to deploy the Kubernetes cluster:
The
-n
refers to the type of network plugin to be deployed, currently supporting calico, flannel, weave, and canal.
Verifying the Cluster
After Ansible has run, if no errors have occurred, you can start operating the Kubernetes, such as obtaining version information:
Get the current cluster node status:
Check the current cluster Pod status:
最后更新于