3.Kubeadm方式安装
#配置阿里云K8S YUM源: cat <<EOF > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF #运行 yum install 命令安装kubeadm 和 相关工具: yum install -y kubeadm-1.14.0-0 kubelet-1.14.0-0 kubectl-1.14.0-0 --disableexcludes=kubernetes #运行下面的命令 安装并启动 Docker服务 以及 启动kubelet服务 ; 设置以上两项服务为开机启动: yum -y install docker && systemctl start docker && systemctl enable docker systemctl start kubelet && systemctl enable kubelet #导出默认文件: kubeadm config print init-defaults > init.default.yaml #修改 init.default.yaml 另存为 :init-config.yaml #以下内容需要修改: apiVersion: kubeadm.k8s.io/v1beta1 kind: InitConfiguration imageRepository: docker.io/dustise kubernetesVersion: v1.14.0 networking: podSubnet: "192.168.0.0/16" mv init.default.yaml init-config.yaml #优化Docker镜像: echo '{"registry-mirrors":["https://registry.docker-cn.com"]}' > /etc/docker/daemon.json #下载所需镜像: kubeadm config images pull --config
主节点docker pull脚本:
#下载镜像 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-controller-manager-amd64:v1.11.0 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-proxy-amd64:v1.11.0 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-apiserver-amd64:v1.11.0 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-scheduler-amd64:v1.11.0 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/coredns:1.1.3 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/etcd-amd64:3.2.18 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/pause:3.1 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-node:v3.1.3 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-cni:v3.1.3 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-typha:v0.7.4 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/kubernetes-dashboard-amd64:v1.8.3 #打上新标签 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-apiserver-amd64:v1.11.0 k8s.gcr.io/kube-apiserver-amd64:v1.11.0 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-controller-manager-amd64:v1.11.0 k8s.gcr.io/kube-controller-manager-amd64:v1.11.0 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-scheduler-amd64:v1.11.0 k8s.gcr.io/kube-scheduler-amd64:v1.11.0 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-proxy-amd64:v1.11.0 k8s.gcr.io/kube-proxy-amd64:v1.11.0 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/pause:3.1 k8s.gcr.io/pause:3.1 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/etcd-amd64:3.2.18 k8s.gcr.io/etcd-amd64:3.2.18 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/coredns:1.1.3 k8s.gcr.io/coredns:1.1.3 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-node:v3.1.3 quay.io/calico-node:v3.1.3 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-cni:v3.1.3 quay.io/calico-cni:v3.1.3 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-typha:v0.7.4 quay.io/calico-typha:v0.7.4 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/kubernetes-dashboard-amd64:v1.8.3 k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.3 #移除老旧标签 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-apiserver-amd64:v1.11.0 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-controller-manager-amd64:v1.11.0 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-scheduler-amd64:v1.11.0 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-proxy-amd64:v1.11.0 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/pause:3.1 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/etcd-amd64:3.2.18 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/coredns:1.1.3 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-cni:v3.1.3 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-typha:v0.7.4 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-node:v3.1.3 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/kubernetes-dashboard-amd64:v1.8.3
在备节点执行的命令:
docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-node:v3.1.3 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-typha:v0.7.4 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/kubernetes-dashboard-amd64:v1.8.3 docker pull registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-proxy-amd64:v1.11.0 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-node:v3.1.3 quay.io/calico-node:v3.1.3 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-typha:v0.7.4 quay.io/calico-typha:v0.7.4 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/kubernetes-dashboard-amd64:v1.8.3 k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.3 docker tag registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-proxy-amd64:v1.11.0 k8s.gcr.io/kube-proxy-amd64:v1.11.0 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/kube-proxy-amd64:v1.11.0 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-typha:v0.7.4 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/calico-node:v3.1.3 docker rmi registry.cn-hangzhou.aliyuncs.com/liuyi01/kubernetes-dashboard-amd64:v1.8.3