Kubernetes – 安装主节点4 – 初始化Kubernetes主节点

kubeadm init 初始化主节点

运行下面的命令来初始化kubernetes主节点:

kubeadm init --image-repository registry.aliyuncs.com/google_containers

由于gcr.io服务器被墙,所以这里我们指定阿里云镜像库。

输出:

...

Your Kubernetes control-plane has initialized successfully!

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

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.31.174:6443 --token wzhn5s.lh9ahv8y4f59ie2t \
    --discovery-token-ca-cert-hash sha256:7bf1f8c25fcef4aec3f55e463ac89cf42de43dccacf5fab940a597f0975af492

从输出中可以看到,kubernetes主节点已经成功初始化。

设置作为根用户来使用集群

接着,执行输出中提示的命令,设置作为根用户来使用集群。

[root@qikegu-centos5 ~]# mkdir -p $HOME/.kube
[root@qikegu-centos5 ~]# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@qikegu-centos5 ~]# sudo chown $(id -u):$(id -g) $HOME/.kube/config

添加工作节点命令

另外记住输出中,提示的另一条命令,在后续添加从节点时需要使用:

kubeadm join 192.168.31.174:6443 --token wzhn5s.lh9ahv8y4f59ie2t \
    --discovery-token-ca-cert-hash sha256:7bf1f8c25fcef4aec3f55e463ac89cf42de43dccacf5fab940a597f0975af492


浙ICP备17015664号 浙公网安备 33011002012336号 联系我们 网站地图  
@2019 qikegu.com 版权所有,禁止转载