准备工作完成后,就可以运行kubeadm init 命令设置master节点了
root@master01:/app# kubeadm init --image-repository registry.aliyuncs.com/google_containers --pod-network-cidr=192.168.0.0/16设置项阐明:
--apiserver-advertise-address k8s 中服务apiserver的摆设地点,如果不填写,默认是本机
--image-repository 拉取的 docker 镜像源,因为初始化的时间kubeadm会去拉 k8s 的许多组件来举行摆设,以是须要指定国内镜像源,下否则会拉取不到镜像
--pod-network-cidr k8s 接纳的节点网络,因为我们将要使用flannel作为 k8s 的网络,以是这里填192.168.0.0/16就好
--kubernetes-version: 这个是用来指定你要摆设的 k8s 版本的,一样寻常不消填,不外如果初始化过程中出现了因为版本不对导致的安装错误的话,可以用这个参数手动指定
安装成功后,可看到如下的提示信息
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/configAlternatively, if you are the root user, you can run: export KUBECONFIG=/etc/kubernetes/admin.confYou 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.130.239:6443 --token 6k1i68.aml4dfgyfqwcezkp \ --discovery-token-ca-cert-hash sha256:85eedec31c61177648373d4c7a8a547aa0e0a0816fe91601a99352c84d9545f04.设置 kubectl 工具