yum install wget
)。systemctl stop firewalld
。systemctl disable firewalld
。sed -i '/selinux/s/enforcing/disabled/' /etc/selinux/config
。setenforce 0
。swapoff -a
。sed -ri 's/.*swap.*/#&/' /etc/fstab
。hostnamectl set-hostname 主机名
,如三台主机分别设置为:
hostnamectl set-hostname master
。hostnamectl set-hostname node1
。hostnamectl set-hostname node2
。hostname
。cat >> /etc/hosts << EOF 192.168.200.132 master 192.168.200.133 node1 192.168.200.134 node2 EOF
。cat > /etc/sysctl.d/k8s.conf << EOF net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF
。sysctl --system
。yum install ntpdate -y
。ntpdate time.windows.com
。systemctl start docker
)。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
。yum install -y kubelet-1.18.0 kubeadm-1.18.0 kubectl-1.18.0
。systemctl enable kubelet
。kubeadm init \ --apiserver-advertise-address=192.168.200.132 \ --image-repository registry.aliyuncs.com/google_containers \ --kubernetes-version v1.18.0 \ --service-cidr=10.96.0.0/12 \ --pod-network-cidr=10.244.0.0/16
。docker images
查看镜像,此时所需镜像应已安装完成。看到initialized successfully
说明 master 节点上的 k8s 集群搭建成功。mkdir -p $HOME/.kube
。sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
。sudo chown $(id -u):$(id -g) $HOME/.kube/config
。kubeadm join 192.168.200.132:6443 --token pahgrt.7gn13u88wz4f89an \ --discovery-token-ca-cert-hash sha256:7f73daa421d7564a6f813985a03f860350a923967d05cd955f8223d56200eb5b
。kubectl get nodes
查看工作节点。kubectl apply -f https://docs.projectcalico.org/v3.10/manifests/calico.yaml
。kubectl get pods -n kube-system
查看运行状态。kubectl get nodes
查看集群中的工作节点,处于开机状态的 master 节点和部分 node 节点应为 ready 状态,关闭状态的 node 节点为 NoReady 状态。Kubeadm 搭建 k8s 集群步骤:
kubeadm init
命令部署集群。kubeadm join
命令将 node 节点添加至集群。本文作者:han
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!