使用Kubeadm安装简单集群实战

初始化配置(所有机器执行)

IP hostname
10.0.70.251 n1
10.0.70.252 n2

1.主机配置

vi /etc/hosts
10.0.70.251 n1
10.0.70.252 n2

2.关闭防火墙

# 查看防火墙状态
firewall-cmd --state
#停止firewall #禁止firewall开机启动
systemctl stop firewalld && systemctl disable firewalld

3.关闭selinux

setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config

4.关闭系统交换分区

#永久删除交换分区
vi /etc/fstab #注释swap
echo "vm.swappiness = 0">> /etc/sysctl.conf
sysctl -p
free -m

5. 优化内核参数

vi /etc/security/limits.conf

* soft nofile 32768
* hard nofile 65535
* soft nproc 32768
* hadr nproc 65535

6.SSH免密登录

#生成ssh key
ssh-keygen
#其他服务器免密码:
ssh-copy-id root@n1
ssh-copy-id root@n2
ssh-copy-id root@n3
#测试
ssh root@n2
#退出
exit

kubectl 命令补全

yum -y install bash-completion
chmod +x /usr/share/bash-completion/bash_completion
/usr/share/bash-completion/bash_completion
source /usr/share/bash-completion/bash_completion
source <(kubectl completion bash)

你可能感兴趣的:(kubernetes,linux,bash,服务器)