Kubernetes deployed on multiple ubuntu nodes
This document describes how to deploy kubernetes on multiple ubuntu nodes, including 1 master node and 3 minion nodes, and people uses this approach can scale to any number of minion nodes by changing some settings with ease. Although there exists saltstack based ubuntu k8s installation , it may be tedious and hard for a guy that knows little about saltstack but want to build a really distributed k8s cluster. This approach is inspired by k8s deploy on a single node.
Cloud team from ZJU will keep updating this work.
Prerequisites:
1 The minion nodes have installed docker version 1.2+
2 All machines can communicate with each orther, no need to connect Internet (should use private docker registry in this case)
3 These guide is tested OK on Ubuntu 14.04 LTS 64bit server, but it should also work on most Ubuntu versions
4 Dependences of this guide: etcd-2.0.0, flannel-0.2.0, k8s-0.12.0, but it may work with higher versions
Main Steps
I. Make kubernetes , etcd and flanneld binaries
On your laptop, copy cluster/ubuntu-cluster
directory to your workspace.
The build.sh
will download and build all the needed binaries into ./binaries
.
You can customize your etcd version or K8s version in the build.sh by changing variable ETCD_V
and K8S_V
in build.sh, default etcd version is 2.0.0 and K8s version is 0.12.0.
$ cd cluster/ubuntu-cluster
$ sudo ./build.sh
Please copy all the files in ./binaries
into /opt/bin
of every machine you want to run as Kubernetes cluster node.
Alternatively, if your Kubernetes nodes have access to Internet, you can copy cluster/ubuntu-cluster
directory to every node and run:
# in every node
$ cd cluster/ubuntu-cluster
$ sudo ./build.sh
$ sudo cp ./binaries/* /opt/bin
We used flannel here because we want to use overlay network, but please remember it is not the only choice, and it is also not a k8s' necessary dependence. Actually you can just build up k8s cluster natively, or use flannel, Open vSwitch or any other SDN tool you like, we just choose flannel here as a example.
II. Configue and install every components upstart script
An example cluster is listed as below:
IP Address | Role |
---|---|
10.10.103.223 | minion |
10.10.103.224 | minion |
10.10.103.162 | minion |
10.10.103.250 | master |
First of all, make sure cluster/ubuntu-cluster
exists on this node,and run configue.sh
.
On master( infra1 10.10.103.250 ) node:
# in cluster/ubuntu-cluster
$ sudo ./configure.sh
Welcome to use this script to configure k8s setup
Please enter all your cluster node ips, MASTER node comes first
And separated with blank space like "<ip_1> <ip2> <ip3>": 10.10.103.250 10.10.103.223 10.10.103.224 10.10.103.162
This machine acts as
both MASTER and MINION: 1
only MASTER: 2
only MINION: 3
Please choose a role > 2
IP address of this machine > 10.10.103.250
Configure Success
On every minion ( e.g. 10.10.103.224 ) node:
# in cluster/ubuntu-cluster
$ sudo ./configure.sh
Welcome to use this script to configure k8s setup
Please enter all your cluster node ips, MASTER node comes first
And separated with blank space like "<ip_1> <ip2> <ip3>": 10.10.103.250 10.10.103.223 10.10.103.224 10.10.103.162
This machine acts as
both MASTER and MINION: 1
only MASTER: 2
only MINION: 3
Please choose a role > 3
IP address of this machine > 10.10.103.224
Configure Success
If you want a node acts as both running the master and minion, please choose option 1.
III. Start all components
On the master node:
$ sudo service etcd start
Then on every minion node:
$ sudo service etcd start
The kubernetes commands will be started automatically after etcd
On any node:
$ /opt/bin/etcdctl mk /coreos.com/network/config '{"Network":"10.0.0.0/16"}'
You can use the below command on another node to comfirm if the network setting is correct.
$ /opt/bin/etcdctl get /coreos.com/network/config
If you got
{"Network":"10.0.0.0/16"}
, then etcd cluster is working well. If not , please check/var/log/upstart/etcd.log
to resolve etcd problem before going forward. Finally, useifconfig
to see if there is a new network interface namedflannel0
coming up.On every minion node
Make sure you have
brctl
installed on every minion, otherwise please runsudo apt-get install bridge-utils
$ sudo ./reconfigureDocker.sh
This will make the docker daemon aware of flannel network.
All done !
IV. Validation
You can use kubectl command to see if the newly created k8s is working correctly.
For example , $ kubectl get minions
to see if you get all your minion nodes comming up.
Also you can run kubernetes guest-example to build a redis backend cluster on the k8s.
V. Trouble Shooting
Generally, what of this guide did is quite simple:
Build and copy binaries and configuration files to proper dirctories on every node
Configure
etcd
using IPs based on input from userCreate and start flannel network
So, whenver you have problem, do not blame Kubernetes, check etcd configuration first
Please try:
Check
/var/log/upstart/etcd.log
for suspicisous etcd logCheck
/etc/default/etcd
, as we do not have much input validation, a right config should be like:ETCD_OPTS="-name infra1 -initial-advertise-peer-urls <http://ip_of_this_node:2380> -listen-peer-urls <http://ip_of_this_node:2380> -initial-cluster-token etcd-cluster-1 -initial-cluster infra1=<http://ip_of_this_node:2380>,infra2=<http://ip_of_another_node:2380>,infra3=<http://ip_of_another_node:2380> -initial-cluster-state new"
Remove
data-dir
of etcd and runreconfigureDocker.sh
again, the default path ofdata-dir
is /infra*.etcd/You can also customize your own settings in
/etc/default/{component_name}
after configured success.
Kubernetes deployed on multiple ubuntu nodes的更多相关文章
- 【云计算】Docker云平台—Docker进阶
Docker云平台系列共三讲,此为第二讲:Docker进阶 参考资料: 五个Docker监控工具的对比:http://www.open-open.com/lib/view/open1433897177 ...
- Connecting Elixir Nodes with libcluster, locally and on Kubernetes
转自:https://www.poeticoding.com/connecting-elixir-nodes-with-libcluster-locally-and-on-kubernetes/ Tr ...
- ubuntu物理机上搭建Kubernetes集群 -- 准备
准备工作 1.kubernetes架构 2.三台ubuntu主机: 操作系统:ubuntu-16.04.1-server-amd64 docker: 1.安装 使用命令 sudo apt-get in ...
- 在Ubuntu安装kubernetes
一.安装Docker 1. 配置Docker docker安装完成后需要配置cgroup驱动为systemd来增强稳定性 sudo vim /etc/docker/daemon.json { &quo ...
- 101 More Security Best Practices for Kubernetes
https://rancher.com/blog/2019/2019-01-17-101-more-kubernetes-security-best-practices/ The CNCF recen ...
- 离线环境下使用二进制方式安装配置Kubernetes集群
本文环境 Redhat Linux 7.3,操作系统采用的最小安装方式. Kubernetes的版本为 V1.10. Docker版本为18.03.1-ce. etcd 版本为 V3.3.8. 1. ...
- Ubuntu 14.04主机上部署k8s集群
部署结构 3台虚拟机,其中1台作为master,2台作为minion,都安装了最新版本的docker engine(目前是1.11.2) k8s版本是1.3.0 主要问题 部署步骤基本按照官方文档:h ...
- 基于Containerd安装部署高可用Kubernetes集群
转载自:https://blog.weiyigeek.top/2021/7-30-623.html 简述 Kubernetes(后续简称k8s)是 Google(2014年6月) 开源的一个容器编排引 ...
- 在Azure Container Service创建Kubernetes(k8s)群集运行ASP.NET Core跨平台应用程序
引子 在此前的一篇文章中,我介绍了如何在本地docker环境中运行ASP.NET Core跨平台应用程序(http://www.cnblogs.com/chenxizhang/p/7148657.ht ...
随机推荐
- List集合概述
上篇总结了Set集合,这回总结下List集合....先来框架图: 一.List集合 List集合代表一个元素有序,可重复的集合,集合中每个元素都有对应的顺序索引.List接口中增加了一些根据索引操作元 ...
- Swift使用注意
二.函数的可选参数 参数名:参数类型? = 默认值 // 调用的时候会发现生成了两个函数,一个带imageName,一个不带,选择不带的,调用此函数时将使用参数值nil convenience ini ...
- React Native学习笔记之1
1:运行React Native报连接错误解决 解决方式: 在终端进入项目文件里,然后执行:(cd Pods/React; npm run start) 2:组件生命周期介绍 创建阶段 1. getD ...
- Java中的经典算法之选择排序(SelectionSort)
Java中的经典算法之选择排序(SelectionSort) 神话丿小王子的博客主页 a) 原理:每一趟从待排序的记录中选出最小的元素,顺序放在已排好序的序列最后,直到全部记录排序完毕.也就是:每一趟 ...
- ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布局
本文转自 :http://www.cnblogs.com/wendingding/p/3761730.html ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布 ...
- iOS 自定义的对象类型的解档和归档
自定义的对象的解档和归档 如果想对自己自定义的类进行解档和归档的话 必须遵循一个协议:NSCoding Student.h 文件 #import <Foundation/Foundation.h ...
- #一周五# (视频) 手掌四轴Estes 4606,树莓派2和WRTNode,WinHEC 2015深圳
又到周五,本周<快速创建网站>系列接近尾声,主要部分已经完成,还差最后一篇博主我正在整理.这里给大家分享一些最近看到的有意思的东西. 手掌四轴飞行器 无人机这段时间可是大出风头,DJI或者 ...
- 见证历史 -- 2013 NBA 热火夺冠之路有感
见证历史-- 2013 NBA 热火夺冠之路有感今年NBA季后赛从第一轮看起,到最终的热火夺冠,应该看得是最爽的一次.但一些情节和细节,回忆起来,深有感悟. 1. 做人要低调詹宁斯豪言演黑八雄鹿本赛季 ...
- JavaScript Patterns 4.8 Function Properties - A Memoization Pattern
Gets a length property containing the number of arguments the function expects: function func(a, b, ...
- 关于update set from where
http://blog.csdn.net/xcbsdu/article/details/6736503 下面是这样一个例子: 两个表a.b,想使b中的memo字段值等于a表中对应id的name值 ...