美文网首页DevOps
05-k8s集群安装-前置环境

05-k8s集群安装-前置环境

作者: 紫荆秋雪_文 | 来源:发表于2021-08-16 09:21 被阅读0次

一、安装docker

二、添加 yum 源

cat > /etc/yum.repos.d/kubernetes.repo << EOF
[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 
EOF

三、安装 kubeadm,kubelet 和 kubectl

#查看 kube
yum list|grep kube

#安装指定版本
yum install -y kubelet-1.17.3 kubeadm-1.17.3 kubectl-1.17.3

systemctl enable kubelet 
systemctl start kubelet

四、部署 Kubernetes Master

kubeadm init --apiserver-advertise-address=172.16.176.100 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.17.3 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16
image.png

4.1、在master上执行

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

4.2、在其他node节点上执行下面命令,是node节点被master管理

kubeadm join 172.16.176.100:6443 --token a73r6f.b8bup61g9uwy73y7 \
    --discovery-token-ca-cert-hash sha256:96579be94c5099d4d326d45812c7659d59870314837f6f574dbaee966966fb4f
image.png

4.3、token 过期怎么办

kubeadm token create --print-join-command
kubeadm token create --ttl 0 --print-join-command
kubeadm join --token y1eyw5.ylg568kvohfdsfco --discovery-token-ca-cert-hash sha256: 6c35e4f73f72afd89bf1c8c303ee55677d2cdb1342d67bb23c852aba2efc7c73

五、安装 Pod 网络插件(CNI)

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

5.1、安装网络插件后

image.png

相关文章

网友评论

    本文标题:05-k8s集群安装-前置环境

    本文链接:https://www.haomeiwen.com/subject/oxuubltx.html