![cover](https://halo-1302156017.cos.ap-shanghai.myqcloud.com/images.jpg)
初始化Ubuntu Server
目标还是初始化一个Ubuntu用于搭建K8S
可直接做成脚本
重置虚拟机
启用ROOT并开启登录
sudo su -
passwd root
# vim /etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes
systemctl restart sshd
重置网卡
cat <<-"EOF" > /etc/netplan/00-installer-config.yaml
network:
ethernets:
ens160:
dhcp4: false
addresses: [10.10.8.202/24]
optional: true
routes:
- to: default
via: 10.10.8.253
nameservers:
addresses: [10.10.8.253, 114.114.114.114]
version: 2
EOF
netplan apply
修改主机名
# 修改 hostname
hostnamectl set-hostname k8s-master-01
# 查看修改结果
hostnamectl status
# 设置 hostname 解析
echo "127.0.0.1 $(hostname)" >> /etc/hosts
关闭IPTABLES与一些初始化
sudo timedatectl set-timezone Asia/Shanghai
iptables -P FORWARD ACCEPT
/etc/init.d/ufw stop
ufw disable
#关闭swap
swapoff -a
# 防止开机自动挂载 swap 分区
sed -i '/swap/ s/^\(.*\)$/#\1/g' /etc/fstab
# 修改内核参数
cat <<-"EOF" > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward=1
vm.max_map_count=262144
EOF
modprobe br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf
设置apt源
apt-get update && apt-get install -y apt-transport-https ca-certificates software-properties-common
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add
add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main"
apt-get update
若上步出现NO_PUBLICKEY问题,参考https://www.cnblogs.com/jiangzuo/p/13667011.html
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 Hunter
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果