Kubernetes deployed on multiple ubuntu nodes

时间:2021-12-12 22:24:57

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

  1. 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

  2. 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, use ifconfig to see if there is a new network interface named flannel0 coming up.

  3. On every minion node

    Make sure you have brctl installed on every minion, otherwise please run sudo 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:

  1. Build and copy binaries and configuration files to proper dirctories on every node

  2. Configure etcd using IPs based on input from user

  3. Create and start flannel network

So, whenver you have problem, do not blame Kubernetes, check etcd configuration first

Please try:

  1. Check /var/log/upstart/etcd.log for suspicisous etcd log

  2. Check /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"
  3. Remove data-dir of etcd and run reconfigureDocker.shagain, the default path of data-dir is /infra*.etcd/

  4. You can also customize your own settings in /etc/default/{component_name} after configured success.

Kubernetes deployed on multiple ubuntu nodes的更多相关文章

  1. 【云计算】Docker云平台—Docker进阶

    Docker云平台系列共三讲,此为第二讲:Docker进阶 参考资料: 五个Docker监控工具的对比:http://www.open-open.com/lib/view/open1433897177 ...

  2. Connecting Elixir Nodes with libcluster&comma; locally and on Kubernetes

    转自:https://www.poeticoding.com/connecting-elixir-nodes-with-libcluster-locally-and-on-kubernetes/ Tr ...

  3. ubuntu物理机上搭建Kubernetes集群 -- 准备

    准备工作 1.kubernetes架构 2.三台ubuntu主机: 操作系统:ubuntu-16.04.1-server-amd64 docker: 1.安装 使用命令 sudo apt-get in ...

  4. 在Ubuntu安装kubernetes

    一.安装Docker 1. 配置Docker docker安装完成后需要配置cgroup驱动为systemd来增强稳定性 sudo vim /etc/docker/daemon.json { &quo ...

  5. 101 More Security Best Practices for Kubernetes

    https://rancher.com/blog/2019/2019-01-17-101-more-kubernetes-security-best-practices/ The CNCF recen ...

  6. 离线环境下使用二进制方式安装配置Kubernetes集群

    本文环境 Redhat Linux 7.3,操作系统采用的最小安装方式. Kubernetes的版本为 V1.10. Docker版本为18.03.1-ce. etcd 版本为 V3.3.8. 1. ...

  7. Ubuntu 14&period;04主机上部署k8s集群

    部署结构 3台虚拟机,其中1台作为master,2台作为minion,都安装了最新版本的docker engine(目前是1.11.2) k8s版本是1.3.0 主要问题 部署步骤基本按照官方文档:h ...

  8. 在Azure Container Service创建Kubernetes(k8s)群集运行ASP&period;NET Core跨平台应用程序

    引子 在此前的一篇文章中,我介绍了如何在本地docker环境中运行ASP.NET Core跨平台应用程序(http://www.cnblogs.com/chenxizhang/p/7148657.ht ...

  9. Ceph集群搭建及Kubernetes上实现动态存储(StorageClass)

    集群准备 ceph集群配置说明   节点名称 IP地址 配置 作用 ceph-moni-0 10.10.3.150 centos7.5 4C,16G,200Disk 管理节点,监视器 monitor ...

随机推荐

  1. 关于ebox

         看了介绍,觉得挺不错的东西,希望能够一路走下去       老话题STM32编程,新思路,一样是编程,味道却大有不同.这就是STM32之eBox编程.让你提议不一样的编程,让开发快到你意想不 ...

  2. C&plus;&plus;14使用std&colon;&colon;integer&lowbar;sequence展开tuple作为函数的参数

    元组是一种长度固定的允许有不同类型元素的集合,根据元素的个数不同又分别称作一元组.二元组.三元组等.C++11中标准库增加了一个叫std::tuple的类模板,用于表示元组. 下面的代码演示了使用C+ ...

  3. zTree实现地市县三级级联Action类

    zTree实现地市县三级级联Action类 ProvinceAction.java: /** * @Title:ProvinceAction.java * @Package:com.gwtjs.str ...

  4. 前端MVVM框架:Knockout&period;JS(一)

    前言 在我们平时开发 Web 应用程序的时候,如果项目不算特别大的话,一般都是拿 jQuery 再配合一些前端 UI 框架就在项目上面应用了.如果页面逻辑稍微复杂的话,那个在写前端 JavaScrip ...

  5. phantomjs api文档

    phantomjs实现了一个*面的webkit浏览器.虽然没有界面,但dom渲染.js运行.网络访问.canvas/svg绘制等功能都很完备,在页面抓取.页面输出.自动化测试等方面有广泛的应用. 详 ...

  6. vim打开不同的文件

    sp   vim -o file1 file2    纵向打开文件 Ctrl+w Ctrl+v         vim -O file1 file2   横向打开文件

  7. &vert;ERROR&vert;ERROR&colon; missing data for column &quot&semi;createtime&quot&semi; &lpar;seg3 slice1 192&period;168&period;66&period;23&colon;40001 pid&equals;33370&rpar;之mysql换行符或者空格引起的问题

    1.最近的kettle的数据交换配置,启动kettle引起的错误,如下所示: |ERROR|ERROR: missing data pid=) 引发这个错误,并不是这个字段引起的错误,一般是这个字段临 ...

  8. 基于nginx&plus;xxl-job&plus;springboot高可用分布式任务调度系统

    技术.原理讲解: <分布式任务调度平台XXL-JOB--源码解析一:项目介绍> <分布式任务调度平台XXL-JOB--源码解析二:基于docker搭建admin调度中心和execut ...

  9. JAVA体系的线程的实现,线程的调度,状态的转换

    java体系中线程的实现 1.使用内核线程实现 内核线程就是直接由操作系统内核支持的线程,这种线程由内核来完成线程切换,内核通过操作调度器对线程进行调度,并负责将线程的任务映射到各个处理器上,每个内核 ...

  10. Hadoop生态圈-CDH与HUE使用案例

    Hadoop生态圈-CDH与HUE使用案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.HUE的介绍 1>.HUE的由来 HUE全称是HadoopUser Experi ...