yum install -y nfs-utils docker
sed -i 's/--selinux-enabled --log-driver=journald --signature-verification=false/--selinux-enabled=false --graph /docker --insecure-registry dockerhub.daline.com.cn:5000/' /etc/sysconfig/docker
systemctl disable --now firewalld
systemctl enable --now docker

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
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
yum install -y kubelet-1.21.2 kubeadm-1.21.2 kubectl-1.21.2 --disableexcludes=kubernetes
sed -i '/- --secure-port=6443/a\    - --service-node-port-range=1-65535' /etc/kubernetes/manifests/kube-apiserver.yaml

docker pull dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-apiserver:v1.21.2
docker pull dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-scheduler:v1.21.2
docker pull dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-proxy:v1.21.2
docker pull dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-controller-manager:v1.21.2
docker pull dockerhub.daline.com.cn:5000/quay.io/tigera/operator:v1.17.4
docker pull dockerhub.daline.com.cn:5000/docker.io/calico/node:v3.19.1
docker pull dockerhub.daline.com.cn:5000/docker.io/calico/pod2daemon-flexvol:v3.19.1
docker pull dockerhub.daline.com.cn:5000/docker.io/calico/cni:v3.19.1
docker pull dockerhub.daline.com.cn:5000/docker.io/calico/kube-controllers:v3.19.1
docker pull dockerhub.daline.com.cn:5000/docker.io/calico/typha:v3.19.1
docker pull dockerhub.daline.com.cn:5000/k8s.gcr.io/pause:3.4.1
docker pull dockerhub.daline.com.cn:5000/docker.io/coredns/coredns:1.8.0
docker pull dockerhub.daline.com.cn:5000/k8s.gcr.io/coredns/coredns:v1.8.0
docker pull dockerhub.daline.com.cn:5000/k8s.gcr.io/etcd:3.4.13-0
docker tag dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-apiserver:v1.21.2 k8s.gcr.io/kube-apiserver:v1.21.2
docker tag dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-scheduler:v1.21.2 k8s.gcr.io/kube-scheduler:v1.21.2
docker tag dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-proxy:v1.21.2 k8s.gcr.io/kube-proxy:v1.21.2
docker tag dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-controller-manager:v1.21.2 k8s.gcr.io/kube-controller-manager:v1.21.2
docker tag dockerhub.daline.com.cn:5000/quay.io/tigera/operator:v1.17.4 quay.io/tigera/operator:v1.17.4
docker tag dockerhub.daline.com.cn:5000/docker.io/calico/node:v3.19.1 docker.io/calico/node:v3.19.1
docker tag dockerhub.daline.com.cn:5000/docker.io/calico/pod2daemon-flexvol:v3.19.1 docker.io/calico/pod2daemon-flexvol:v3.19.1
docker tag dockerhub.daline.com.cn:5000/docker.io/calico/cni:v3.19.1 docker.io/calico/cni:v3.19.1
docker tag dockerhub.daline.com.cn:5000/docker.io/calico/kube-controllers:v3.19.1 docker.io/calico/kube-controllers:v3.19.1
docker tag dockerhub.daline.com.cn:5000/docker.io/calico/typha:v3.19.1 docker.io/calico/typha:v3.19.1
docker tag dockerhub.daline.com.cn:5000/k8s.gcr.io/pause:3.4.1 k8s.gcr.io/pause:3.4.1
docker tag dockerhub.daline.com.cn:5000/docker.io/coredns/coredns:1.8.0 docker.io/coredns/coredns:1.8.0
docker tag dockerhub.daline.com.cn:5000/k8s.gcr.io/coredns/coredns:v1.8.0 k8s.gcr.io/coredns/coredns:v1.8.0
docker tag dockerhub.daline.com.cn:5000/k8s.gcr.io/etcd:3.4.13-0 k8s.gcr.io/etcd:3.4.13-0
docker rmi dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-apiserver:v1.21.2
docker rmi dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-scheduler:v1.21.2
docker rmi dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-proxy:v1.21.2
docker rmi dockerhub.daline.com.cn:5000/k8s.gcr.io/kube-controller-manager:v1.21.2
docker rmi dockerhub.daline.com.cn:5000/quay.io/tigera/operator:v1.17.4
docker rmi dockerhub.daline.com.cn:5000/docker.io/calico/node:v3.19.1
docker rmi dockerhub.daline.com.cn:5000/docker.io/calico/pod2daemon-flexvol:v3.19.1
docker rmi dockerhub.daline.com.cn:5000/docker.io/calico/cni:v3.19.1
docker rmi dockerhub.daline.com.cn:5000/docker.io/calico/kube-controllers:v3.19.1
docker rmi dockerhub.daline.com.cn:5000/docker.io/calico/typha:v3.19.1
docker rmi dockerhub.daline.com.cn:5000/k8s.gcr.io/pause:3.4.1
docker rmi dockerhub.daline.com.cn:5000/docker.io/coredns/coredns:1.8.0
docker rmi dockerhub.daline.com.cn:5000/k8s.gcr.io/coredns/coredns:v1.8.0
docker rmi dockerhub.daline.com.cn:5000/k8s.gcr.io/etcd:3.4.13-0

kubeadm init --pod-network-cidr=192.168.0.0/16 --kubernetes-version=v1.21.2
export KUBECONFIG=/etc/kubernetes/admin.conf
export kubever=$(kubectl version | base64 | tr -d '\n')
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever"

#kubectl taint nodes --all node-role.kubernetes.io/master-