
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
exclude=kubelet kubeadm kubectl
EOF
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
# 其他版本docker,阿里云镜像
yum install -y yum-utils
yum-config-manager --add-repo  https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

sysctl --system
setenforce 0
yum install -y nfs-utils docker-ce
sed -i 's/--selinux-enabled --log-driver=journald --signature-verification=false/--selinux-enabled=false --graph \/docker --insecure-registry dockerhub.daline.com.cn/' /etc/sysconfig/docker
systemctl disable --now firewalld
systemctl enable --now docker
yum install -y kubelet-1.21.2 kubeadm-1.21.2 kubectl-1.21.2 --disableexcludes=kubernetes
systemctl enable --now kubelet

docker pull dockerhub.daline.com.cn/k8s.gcr.io/kube-apiserver:v1.21.2
docker pull dockerhub.daline.com.cn/k8s.gcr.io/kube-scheduler:v1.21.2
docker pull dockerhub.daline.com.cn/k8s.gcr.io/kube-proxy:v1.21.2
docker pull dockerhub.daline.com.cn/k8s.gcr.io/kube-controller-manager:v1.21.2
docker pull dockerhub.daline.com.cn/k8s.gcr.io/pause:3.4.1
docker pull dockerhub.daline.com.cn/docker.io/coredns/coredns:1.8.0
docker pull dockerhub.daline.com.cn/k8s.gcr.io/coredns/coredns:v1.8.0
docker pull dockerhub.daline.com.cn/k8s.gcr.io/etcd:3.4.13-0
docker pull dockerhub.daline.com.cn/flannel/flannel:v0.24.4
docker pull dockerhub.daline.com.cn/flannel/flannel-cni-plugin:v1.4.0-flannel1
docker tag dockerhub.daline.com.cn/k8s.gcr.io/kube-apiserver:v1.21.2 k8s.gcr.io/kube-apiserver:v1.21.2
docker tag dockerhub.daline.com.cn/k8s.gcr.io/kube-scheduler:v1.21.2 k8s.gcr.io/kube-scheduler:v1.21.2
docker tag dockerhub.daline.com.cn/k8s.gcr.io/kube-proxy:v1.21.2 k8s.gcr.io/kube-proxy:v1.21.2
docker tag dockerhub.daline.com.cn/k8s.gcr.io/kube-controller-manager:v1.21.2 k8s.gcr.io/kube-controller-manager:v1.21.2
docker tag dockerhub.daline.com.cn/k8s.gcr.io/pause:3.4.1 k8s.gcr.io/pause:3.4.1
docker tag dockerhub.daline.com.cn/docker.io/coredns/coredns:1.8.0 docker.io/coredns/coredns:1.8.0
docker tag dockerhub.daline.com.cn/k8s.gcr.io/coredns/coredns:v1.8.0 k8s.gcr.io/coredns/coredns:v1.8.0
docker tag dockerhub.daline.com.cn/k8s.gcr.io/etcd:3.4.13-0 k8s.gcr.io/etcd:3.4.13-0
docker tag dockerhub.daline.com.cn/flannel/flannel:v0.24.4 flannel/flannel:v0.24.4
docker tag dockerhub.daline.com.cn/flannel/flannel-cni-plugin:v1.4.0-flannel1 flannel/flannel-cni-plugin:v1.4.0-flannel1
docker rmi dockerhub.daline.com.cn/k8s.gcr.io/kube-apiserver:v1.21.2
docker rmi dockerhub.daline.com.cn/k8s.gcr.io/kube-scheduler:v1.21.2
docker rmi dockerhub.daline.com.cn/k8s.gcr.io/kube-proxy:v1.21.2
docker rmi dockerhub.daline.com.cn/k8s.gcr.io/kube-controller-manager:v1.21.2
docker rmi dockerhub.daline.com.cn/k8s.gcr.io/pause:3.4.1
docker rmi dockerhub.daline.com.cn/docker.io/coredns/coredns:1.8.0
docker rmi dockerhub.daline.com.cn/k8s.gcr.io/coredns/coredns:v1.8.0
docker rmi dockerhub.daline.com.cn/k8s.gcr.io/etcd:3.4.13-0
docker rmi dockerhub.daline.com.cn/flannel/flannel:v0.24.4
docker rmi dockerhub.daline.com.cn/flannel/flannel-cni-plugin:v1.4.0-flannel1

kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version=v1.21.2
export KUBECONFIG=/etc/kubernetes/admin.conf
kubectl apply -f k8s_flannel.yaml
kubectl taint nodes --all node-role.kubernetes.io/master-

# /etc/kubernetes/manifests/kube-apiserver.yaml  --service-node-port-range=1-65535
# kubectl apply -f k8s_ingress_nginx.yaml
