kubernetes节点部署(kubeadm方式)
一、安装kubeadm、kubelet、kubectl
yum remove -y kubeadm kubelet kubectl yum install -y kubeadm kubelet kubectl #启动docker服务 systemctl start docker.service systemctl enable docker.service #启动kubelet服务 systemctl enable kubelet.service
二、Master节点部署
设置HostName
hostnamectl set-hostname master
配置各个节点hosts
vi /etc/hosts 192.168.0.12 master 192.168.0.13 node1 192.168.0.14 node2
master节点部署命令
kubeadm init \ --image-repository registry.aliyuncs.com/google_containers \ --pod-network-cidr=10.244.0.0/16 \ --ignore-preflight-errors=cri \ --kubernetes-version=1.15.3
检查Master节点,是否是Ready状态
kubectl get node
三、Node节点部署
设置hostName
hostnamectl set-hostname node1
配置各个节点hosts
vi /etc/hosts 192.168.0.12 master 192.168.0.13 node1 192.168.0.14 node2
node节点加入集群
kubeadm token create --print-join-command
获取节点列表
kubectl get nodes
复制kube.config文件夹
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
四、集群初始化网络插件 Flannel
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml