**
#查看你的网卡信息
nmcli device show
#设置你的静态IP
nmcli connection modify ens32 ipv4.method manual \
ipv4.addresses 172.16.20.214/24 ipv4.gateway 172.16.20.1 \
ipv4.dns 114.114.114.114
#重启网卡生效
nmcli c down ens32 && nmcli c up ens32
#添加DNS
nmcli con mod ens32 ipv4.dns 114.114.114.114
nmcli connection modify ens3 ipv4.addresses "" ipv4.gateway "" ipv4.dns ""
nmcli connection modify eth0 ipv4.method auto
nmcli c down ens3 && nmcli c up ens3
# 禁用原有软件源
zypper mr -da
#添加国内源
zypper ar -fcg 'https://mirrors.ustc.edu.cn/opensuse/tumbleweed/repo/oss' USTC:OSS
zypper ar -fcg 'https://mirrors.ustc.edu.cn/opensuse/tumbleweed/repo/oss' USTC:NON-OSS
zypper ar -fcg 'https://mirrors.ustc.edu.cn/opensuse/update/tumbleweed' USTC:UPDATE
[USTC:NON-OSS]
enabled=1
autorefresh=1
baseurl=https://mirrors.ustc.edu.cn/opensuse/tumbleweed/repo/oss
gpgcheck=1
开始部署K8s
#!/bin/bash
systemctl disable firewalld
systemctl stop firewalld
cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
net.ipv4.tcp_tw_recycle=0
vm.swappiness=0 # 禁止使用 swap 空间,只有当系统 OOM 时才允许使用它 vm.overcommit_memory=1 # 不检查物理内存是否够用
vm.panic_on_oom=0 # 开启 OOM
fs.inotify.max_user_instances=8192
fs.inotify.max_user_watches=1048576
fs.file-max=52706963
fs.nr_open=52706963
net.ipv6.conf.all.disable_ipv6=1
net.netfilter.nf_conntrack_max=2310720
EOF
cat << EOF >> /etc/security/limits.conf
root soft nofile 655360
root hard nofile 655360
root soft nproc 655360
root hard nproc 655360
root soft core unlimited
root hard core unlimited
* soft nofile 655360
* hard nofile 655360
* soft nproc 655360
* hard nproc 655360
* soft core unlimited
* hard core unlimited
EOF
cat << EOF >> /etc/systemd/system.conf
DefaultLimitCORE=infinity
DefaultLimitNOFILE=655360
DefaultLimitNPROC=655360
EOF
swapoff -a
sed -i 's/.*swap.*/#&/' /etc/fstab
cat <<EOF | tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
modprobe br_netfilter
lsmod | grep br_netfilter
sysctl --system
#安装cri-o的时候依赖所有的k8s的组件,所以就不需要再安装kubernetes的任何软件包了
zypper install -y cri-o
zypper install -y openssh
systemctl enable kubelet.service
#替换国内加速器
sed -i "s#registry.opensuse.org#0k0953tv.mirror.aliyuncs.com#g" /etc/containers/registries.conf
cat > /etc/crictl.yaml <<EOF
runtime-endpoint: unix:///var/run/crio/crio.sock
image-endpoint: unix:///var/run/crio/crio.sock
timeout: 10
debug: false
EOF
systemctl start crio.service
systemctl enable crio.service
echo "测试拉取镜像"
crictl pull nginx
crictl images
EOF
#输出镜像就部署好了
初始化你的集群
kubeadm init --image-repository registry.aliyuncs.com/google_containers --pod-network-cidr=10.244.0.0/16
###不提供kubectl请自己下载
cat << EOF > /etc/ssh/sshd_config
Include /etc/ssh/sshd_config.d/*.conf
PermitRootLogin yes
KbdInteractiveAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/libexec/ssh/sftp-server
EOF