码迷,mamicode.com
首页 > 其他好文 > 详细

K8s一键安装

时间:2019-01-03 11:00:30      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:def   rom   三台   use   不能   npe   nic   roo   root   

安装案例:

系统:Centos
可以多台Master(Master不能低于3台)多台Node
此案例使用三台Master两台Node,用户名root,密码均为123456

master	192.168.20.183
master	192.168.20.96
master	192.168.20.171
node	192.168.20.172
node    192.168.20.54

安装Master集群

下载项目:

git clone https://github.com/zdwork/k8s-install.git
cd k8s-install

修改 conf/master-install.conf
内容如下:

#!/bin/bash
#User-defined information
export node=3 #集群数量
export node_ip="192.168.20.183 192.168.20.96 192.168.20.171" #服务器的ip,以空格分割
export node_name="master-01 master-02 master-03" #主机名 自定义,以空格分割
export node_pass="123456 123456 123456" #每台服务器的root密码,以空格分割
export apiserver_vip="192.168.20.240"#高可用IP 注意此ip要没有被占用
export apiserver_vip_port="4443"
export flaneld_interface="ens33" #你的网卡
export vip_interface="ens33" #你的网卡
export haproxy_name="admin"
export haproxy_pass="123456"
export haproxy_status_port="8000"

安装:

./install.sh

技术分享图片

脚本执行完后会打打印出如下信息:

 ---------------- etcd --------------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:03:46 CST; 1h 44min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:03:47 CST; 1h 44min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:04:07 CST; 1h 43min ago
 ---------------- kube-apiserver -----------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:07:07 CST; 1h 40min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:07:20 CST; 1h 40min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:07:32 CST; 1h 40min ago
 ---------------- kube-scheduler ------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:08:26 CST; 1h 39min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:08:26 CST; 1h 39min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:08:26 CST; 1h 39min ago
 ---------------- kube-controller_manager ----------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:07:59 CST; 1h 40min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:09:08 CST; 1h 38min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:08:02 CST; 1h 40min ago
 ---------------- keepalived ------------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:06:31 CST; 1h 41min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:06:33 CST; 1h 41min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:06:34 CST; 1h 41min ago
 ---------------- haproxy ---------------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:05:03 CST; 1h 43min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:05:20 CST; 1h 42min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:05:34 CST; 1h 42min ago
 ---------------- flanneld --------------------------------
192.168.20.183::master-01
   Active: active (running) since 三 2018-11-28 16:04:39 CST; 1h 43min ago
192.168.20.96::master-02
   Active: active (running) since 三 2018-11-28 16:04:41 CST; 1h 43min ago
192.168.20.171::master-03
   Active: active (running) since 三 2018-11-28 16:04:43 CST; 1h 43min ago
 ################ Current cluster state ####################
NAME                 STATUS    MESSAGE             ERROR
scheduler            Healthy   ok                  
controller-manager   Healthy   ok                  
etcd-1               Healthy   {"health":"true"}   
etcd-2               Healthy   {"health":"true"}   
etcd-0               Healthy   {"health":"true"}   

安装Node

修改 conf/node-install.conf
内容如下:

#!/bin/bash

#User-defined information
export node=2
export node_ip="192.168.20.172 192.168.20.54"
export node_name="node-1 node-2"
export node_pass="123456 123456"
export flaneld_interface="ens33"

安装:

./install.sh

技术分享图片

脚本执行完后会打打印出如下信息:

---------------- flanneld --------------------------------
192.168.20.172::node-1
   Active: active (running) since 三 2018-11-28 18:28:34 CST; 26s ago
192.168.20.54::node-2
   Active: active (running) since 三 2018-11-28 18:28:37 CST; 25s ago
 ---------------- docker --------------------------------
192.168.20.172::node-1
   Active: active (running) since 三 2018-11-28 18:28:38 CST; 24s ago
192.168.20.54::node-2
   Active: active (running) since 三 2018-11-28 18:28:42 CST; 21s ago
 ---------------- kubelet --------------------------------
192.168.20.172::node-1
   Active: active (running) since 三 2018-11-28 18:28:52 CST; 11s ago
192.168.20.54::node-2
   Active: active (running) since 三 2018-11-28 18:28:54 CST; 10s ago
 ---------------- kube-proxy --------------------------------
192.168.20.172::node-1
   Active: active (running) since 三 2018-11-28 18:28:59 CST; 5s ago
192.168.20.54::node-2
   Active: active (running) since 三 2018-11-28 18:29:00 CST; 5s ago

测试:

[root@localhost k8s-install]# bash
[root@master-01 k8s-install]# source /etc/profile
[root@master-01 k8s-install]# kubectl get nodes
NAME      STATUS    ROLES     AGE       VERSION
node-1    Ready     <none>    35s       v1.10.4
node-2    Ready     <none>    34s       v1.10.4
[root@master-01 k8s-install]#

K8s一键安装

标签:def   rom   三台   use   不能   npe   nic   roo   root   

原文地址:https://www.cnblogs.com/cy0917/p/10212566.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!