kubernetes 部署--环境安装①
一 所有机器彼此网路互通,并且k8s-m1 SSH登入其他节点为passwdless(如果不互信可以后面操作)。
初始化环境(所有节点)
设置主机名
hostnamectl set-hostname master1 hostnamectl set-hostname master2 hostnamectl set-hostname master3 hostnamectl set-hostname node1 hostnamectl set-hostname node2 hostnamectl set-hostname node3 cat <<EOF >> /etc/hosts 192.168.22.101 master1 192.168.22.102 master2 192.168.22.103 master3 192.168.22.111 node1 192.168.22.112 node2 192.168.22.113 node3 EOF
ssh免密登陆
ssh-keygen #一路回车即可 ssh-copy-id master1 ssh-copy-id master2 ssh-copy-id master3
二 所有防火墙与SELinux 已关闭。如CentOS
否则后续 K8S 挂载目录时可能报错 Permission denied
systemctl disable --now firewalld NetworkManager setenforce 0 sed -ri '/^[^#]*SELINUX=/s#=.+$#=disabled#' /etc/selinux/config
* 关闭 dnsmasq (可选)
* linux 系统开启了 dnsmasq 后(如 GUI 环境),将系统 DNS Server 设置为 127.0.0.1,这会导致 docker 容器无法解析域名,需要关闭它
systemctl disable --now dnsmasq
三 优化limit
echo "* soft nofile 65536" >> /etc/security/limits.conf echo "* hard nofile 65536" >> /etc/security/limits.conf echo "* soft nproc 65536" >> /etc/security/limits.conf echo "* hard nproc 65536" >> /etc/security/limits.conf echo "* soft memlock unlimited" >> /etc/security/limits.conf echo "* hard memlock unlimited" >> /etc/security/limits.conf
四 Kubernetes v1.8+要求关闭系统Swap,若不关闭则需要修改kubelet设定参数( –fail-swap-on 设置为 false 来忽略 swap on),在所有机器使用以下指令关闭swap并注释掉/etc/fstab中swap的行
swapoff -a && sysctl -w vm.swappiness=0 sed -ri '/^[^#]*swap/s@^@#@' /etc/fstab
目录 返回
首页