使用阿里云源快速安装kubectl-1.18.8,编辑脚本auto-kubelet.sh
mkdir -p /opt/backup/repo/ mv /etc/yum.repos.d/*.repo /opt/backup/repo/ curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum install -y yum-utils device-mapper-persistent-data lvm2 nfs-utils conntrack-tools yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo cat </etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF rpm --import https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg rpm --import https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg yum makecache fast yum install -y nmap unzip wget vim lsof xz net-tools yum-utils iptables-services ntpdate ntp-doc psmisc deltarpm yum-plugin-ovl etcd bash-completion yum install -y yum-utils device-mapper-persistent-data lvm2 socat yum install -y docker-ce-18.09.8 docker-ce-cli-18.09.8 systemctl enable docker systemctl stop docker mkdir -p /etc/docker if [[ -f /etc/docker/daemon.json ]] ; then cp /etc/docker/daemon.json /etc/docker/daemon.json.bak1 fi echo -e ' { "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ], "registry-mirrors": ["https://4ux5p520.mirror.aliyuncs.com"], "insecure-registries":["harbor.io", "k8s.gcr.io", "gcr.io", "quay.io"], "exec-opts": ["native.cgroupdriver=systemd"], "data-root": "/data/docker", "log-driver": "json-file", "log-opts": { "max-size": "100m" } } ' > /etc/docker/daemon.json systemctl daemon-reload systemctl restart docker yum install -y kubectl-1.18.8-0.x86_64 kubeadm-1.18.8-0 kubelet-1.18.8-0 systemctl enable kubelet service kubelet restart echo "ok"
使用方法
bash auto-kubelet.sh