- list item
一、master節點上部署etcd:
1、編寫指令碼:
vim /root/scripts/etcd_master_install.sh
#!/bin/bash
master_ip=`cat /etc/hosts |grep master|awk ''`
node01_ip=`cat /etc/hosts |grep node01|awk ''`
node02_ip=`cat /etc/hosts |grep node02|awk ''`
node03_ip=`cat /etc/hosts |grep node03|awk ''`
#建立etcd集群的配置檔案:
eof#建立系統檔案,通過systemctl管理etcd:
cat >/usr/lib/systemd/system/etcd.service
type=notify
environmentfile=-/opt/kubernetes/cfg/etcd
execstart=/opt/kubernetes/bin/etcd \\
--name=\$ \\
--data-dir=\$ \\
--listen-peer-urls=\$ \\
--listen-client-urls=\$, \\
--advertise-client-urls=\$ \\
--initial-advertise-peer-urls=\$ \\
--initial-cluster=\$ \\
--initial-cluster-token=\$ \\
--initial-cluster-state=new \\
--cert-file=/opt/kubernetes/ssl/server.pem \\
--key-file=/opt/kubernetes/ssl/server-key.pem \\
--peer-cert-file=/opt/kubernetes/ssl/server.pem \\
--peer-key-file=/opt/kubernetes/ssl/server-key.pem \\
--trusted-ca-file=/opt/kubernetes/ssl/ca.pem \\
--peer-trusted-ca-file=/opt/kubernetes/ssl/ca.pem
restart=on-failure
limitnofile=65536
[install]
wantedby=multi-user.target
eof#啟動etcd服務:
systemctl daemon-reload
systemctl restart etcd
systemctl enable etcd
2、執行指令碼:
sh /root/scripts/etcd_master_install.sh
二、node節點上部署etcd:
1、主機間互信:
1>在master節點編寫主機間互信指令碼:
vim /root/scripts/believe.sh
#!/bin/bash
[ -x /usr/bin/expect ] || yum install expect -y &>/dev/null
if [ ! -f /root/.ssh/id_rsa.pub ]
then
/usr/bin/expect
scp -r /opt/kubernetes/ 192.168.1.75:/opt/kubernetes/
scp -r /opt/kubernetes/ 192.168.1.76:/opt/kubernetes/
scp -r /opt/kubernetes/ 192.168.1.77:/opt/kubernetes/
scp /usr/lib/systemd/system/etcd.service 192.168.1.75:/usr/lib/systemd/system/
scp /usr/lib/systemd/system/etcd.service 192.168.1.76:/usr/lib/systemd/system/
scp /usr/lib/systemd/system/etcd.service 192.168.1.77:/usr/lib/systemd/system/
#讓命令全域性可用
ln -s /opt/kubernetes/bin/* /usr/local/sbin/
2>執行指令碼:
sh /root/scripts/believe.sh
2、在三颱node節點上修改配置檔案並啟動etcd服務:
vim /root/scripts/change.sh
#!/bin/bash
hostname=`hostname`
master_ip=`cat /etc/hosts|grep master|awk ''`
local_ip=`cat /etc/hosts|grep $|awk ''`
number=$((`hostname|awk -f"0" ''`+1))
etcd_name=etcd0$
#修改etcd名字
eval sed -i '1,2s/etcd01/$/' /opt/kubernetes/cfg/etcd
#修改etcd的ip
eval sed -i '1,9s/$/$/' /opt/kubernetes/cfg/etcd
#讓命令全域性可用
ln -s /opt/kubernetes/bin/* /usr/local/sbin/
#啟動etcd服務
systemctl daemon-reload
systemctl restart etcd
systemctl enable etcd
3、在任意乙個節點上檢視etcd集群健康狀態:
4、驗證集群可用性:
集群做好的四台伺服器的etcd資料應該是互通的,即在mater上建立乙個檔案或者目錄,在任意node上都是可以查詢到的,同理,在node上設定的key值,在master上也是可以get到的
二進位制安裝K8S(四) 部署flannel網路
執行指令碼 sh root scripts flannel.sh 檢視新增的子網 如果返回error 100 key not found coreos.com 11 則代表沒有設定網路 二 node節點編寫flannel指令碼 三颱node節點指令碼內容相同 vim root scripts fla...
二進位制安裝K8S(六) 部署master節點元件
一 在master上安裝apiserver元件 1 編寫apiserver指令碼 vim root scripts apiserver.sh bin bash 編寫apiserver配置檔案 2 執行指令碼 sh root scripts apiserver.sh 二 在master上安裝contr...
二進位制部署K8s集群 二 docker部署
etcd集群部署 proxy cd web site vim hostlist docker2 192.168.1.40 42 docker3 192.168.1.39 42 vim ansible.cfg cat ansible.cfg grep v grep v defaults invento...