1. 程式人生 > 實用技巧 >Rancher安裝環境準備

Rancher安裝環境準備

5.1.1、主機配置

5.1.1.1、配置要求

硬體需求根據Rancher部署的規模進行擴充套件。根據需求配置每個節點。

部署大小叢集(個)節點(個)vCPU記憶體
不超過5 最多50 4C 16GB
不超過100 最多500 8C 32GB

5.1.1.2、作業系統選擇

  • Ubuntu 16.04(64位)
  • Centos/RedHat Linux 7.5+(64位)
  • RancherOS 1.3.0+(64位)
  • Windows Server 1803(64位)

5.1.1.3、Docker版本選擇

支援的Docker版本

  • 1.12.6
  • 1.13.1
  • 17.03.2
  • 17.06 (for Windows)

5.1.1.4、主機名配置

因為K8S的規定,主機名只支援包含-.(中橫線和點)兩種特殊符號,並且主機名不能出現重複。

5.1.1.5、Hosts

配置每臺主機的hosts(/etc/hosts),新增host_ip $hostname/etc/hosts檔案中。

5.1.1.6、CentOS關閉selinux

sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

5.1.1.7、關閉防火牆(可選)或者放行相應埠

對於剛剛接觸Rancher的使用者,建議在關閉防火牆的測試環境或桌面虛擬機器來執行rancher,以避免出現網路通訊問題。

  • 關閉防火牆
    1、CentOS
    systemctl stop firewalld.service && systemctl disable firewalld.service
    
    2、Ubuntu
    ufw disable
    
  • 埠放行
    埠放行請檢視埠需求

5.1.1.8、配置主機時間、時區、系統語言

  • 檢視時區
    date -R
    或者
    timedatectl
    
  • 修改時區
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    
  • 修改系統語言環境
    sudo echo 'LANG="en_US.UTF-8"' >> /etc/profile;source /etc/profile
    
  • 配置主機NTP時間同步

5.1.1.9、Kernel效能調優

【注意】: 數值根據實際環境自行配置
cat >> /etc/sysctl.conf<<EOF
net.ipv4.ip_forward=1
net.bridge.bridge-nf-call-iptables=1
net.ipv4.neigh.default.gc_thresh1=4096
net.ipv4.neigh.default.gc_thresh2=6144
net.ipv4.neigh.default.gc_thresh3=8192
EOF

最後執行儲存配置

sysctl -p

5.1.1.10、核心模組

載入以下模組

modprobe br_netfilter
modprobe ip6_udp_tunnel
modprobe ip_set
modprobe ip_set_hash_ip
modprobe ip_set_hash_net
modprobe iptable_filter
modprobe iptable_nat
modprobe iptable_mangle
modprobe iptable_raw
modprobe nf_conntrack_netlink
modprobe nf_conntrack
modprobe nf_conntrack_ipv4
modprobe nf_defrag_ipv4
modprobe nf_nat
modprobe nf_nat_ipv4
modprobe nf_nat_masquerade_ipv4
modprobe nfnetlink
modprobe udp_tunnel
modprobe VETH
modprobe VXLAN
modprobe x_tables
modprobe xt_addrtype
modprobe xt_conntrack
modprobe xt_comment
modprobe xt_mark
modprobe xt_multiport
modprobe xt_nat
modprobe xt_recent
modprobe xt_set
modprobe xt_statistic
modprobe xt_tcpudp

5.1.1.11、ETCD叢集容錯表

建議在ETCD叢集中使用奇數個成員,通過新增額外成員可以獲得更高的失敗容錯。

叢集大小MAJORITY失敗容錯
1 1 0
2 2 0
3 2 1
4 3 1
5 3 2
6 4 2
7 4 3
8 5 3
9 5 4