k8s一鍵安裝指令碼(二進位制)
阿新 • • 發佈:2018-11-29
安裝案例:
系統: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
測試:
[[email protected] k8s-install]# bash
[[email protected] k8s-install]# source /etc/profile
[[email protected] 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
[[email protected] k8s-install]#