部署Kubernetes Master
在172.16.10.11(Master)执行。
kubeadm init
--apiserver-advertise-address=172.16.10.11
--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
--ignore-preflight-errors=all
由于默认拉取镜像地址k8s.gcr.io国内无法访问,这里指定阿里云镜像仓库地址。
或者使用配置文件引导:
# vim kubeadm.conf
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: v1.18.0
imageRepository: registry.aliyuncs.com/google_containers
networking:
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12
# kubeadm init --config kubeadm.conf --ignore-preflight-errors=all
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
把node节点加入集群
把下面命令复制到node1和node2上面执行
kubeadm join 172.16.10.11:6443 --token 9neow7.n8nignhkvrfnljca
--discovery-token-ca-cert-hash sha256:395522c4985bc296352c74632057d3ddd2d5cf75eed1266e11e780be2ea7fd31
Master节点查看
kubectl get node
NAME STATUS ROLES AGE VERSION
k8s-master NotReady master 7m21s v1.18.0
k8s-node1 NotReady <none> 18s v1.18.0
k8s-node2 NotReady <none> 6s v1.18.0