业务要求必须在不关闭swap的情况下搭建k8s:
curl -o /etc/yum.repos.d/CentOS-Base.repo \ https://mirrors.aliyun.com/repo/Centos-7.repo
yum install ntpdate bash-completion vim wget
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
# docker-ce 源
[k8s]
name=kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
#k8s源
yum clean all
yum repolist
yum install kubeadm-1.18.3 kubectl-1.18.3 kubelet-1.18.3
yum install docker-ce ntpdate bash-completion vim wget
systemctl restart docker && systemctl enable docker kubelet
setenforce 0
systemctl stop firewalld
#防火墙千万千万不要忘记关
ntpdate ntp1.aliyun.com
#时间同步
echo “net.ipv4.ip_forward = 1” >> /etc/sysctl.conf
echo “net.bridge.bridge-nf-call-ip6tables = 1” >> /etc/sysctl.conf
echo “net.bridge.bridge-nf-call-iptables = 1” >> /etc/sysctl.conf
dd if=/dev/zero of=swapfile bs=1024 count=130000000
mkswap swapfile
swapon swapfile # 130G的swap空间
vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="–fail-swap-on=false"
–ignore-preflight-errors=Swap
# 最关键的地方
kubeadm config images list #查看需要下载什么镜像
#!/bin/bash
##使用如下脚本下载国内镜像,并修改tag为google的tag
set -e
KUBE_VERSION=v1.16.0
KUBE_PAUSE_VERSION=3.1
ETCD_VERSION=3.3.15-0
CORE_DNS_VERSION=1.6.2
GCR_URL=k8s.gcr.io
ALIYUN_URL=registry.cn-hangzhou.aliyuncs.com/google_containers
images=(kube-proxy: K U B E V E R S I O N k u b e − s c h e d u l e r : {KUBE_VERSION} kube-scheduler: KUBEV<