#master上执行(10.0.0.101):# 在运行 kubeadm init 之前先执行 kubeadm config images pull 来测试与 gcr.io 的连接,kubeadm config images pull尝试是否可以拉取镜像,如果你的服务器再国内,由于某些原因,是无法访问"k8s.gcr.io", "gcr.io", "quay.io"[root@k8s-master ~]#kubeadm config images list#查看kubeadm config 依赖的images有哪些#执行结果如下k8s.gcr.io/kube-apiserver:v1.23.8k8s.gcr.io/kube-controller-manager:v1.23.8k8s.gcr.io/kube-scheduler:v1.23.8k8s.gcr.io/kube-proxy:v1.23.8k8s.gcr.io/pause:3.6k8s.gcr.io/etcd:3.5.1-0k8s.gcr.io/coredns/coredns:v1.8.6#从国内镜像拉取[root@master ~]#docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.23.8[root@master ~]#docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.23.8[root@master ~]#docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.23.8[root@master ~]#docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.23.8[root@master ~]#docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6[root@master ~]#docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.1-0[root@master ~]#docker pull coredns/coredns:1.8.6#或者拉取最新版 , 一条命令如下:[root@k8s-master ~]#kubeadm config images pull --image-repository=registry.aliyuncs.com/google_containers#拉取镜像
#master上执行(10.0.0.101):#将拉取下来的images重命名为kubeadm config所需的镜像名字#注意版本号有的是带v的 , 有的不带的v[root@master ~]#docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.23.8 k8s.gcr.io/kube-apiserver:v1.23.8[root@master ~]#docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.23.8 k8s.gcr.io/kube-controller-manager:v1.23.8[root@master ~]#docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.23.8 k8s.gcr.io/kube-scheduler:v1.23.8[root@master ~]#docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.23.8 k8s.gcr.io/kube-proxy:v1.23.8[root@master ~]#docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6 k8s.gcr.io/pause:3.6[root@master ~]#docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.1-0 k8s.gcr.io/etcd:3.5.1-0[root@master ~]#docker tag coredns/coredns:1.8.6 k8s.gcr.io/coredns/coredns:v1.8.6
#master上执行(10.0.0.101):#初始化[root@master ~]#kubeadm init --config kubeadm-config.yaml#如果提示以下信息,安装成功 , 如果安装失败,请卸载kubectl、kubeadm、kubelet 然后再重新执行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/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo 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 10.0.0.101:6443 --token abcdef.0123456789abcdef \ --discovery-token-ca-cert-hash sha256:415922bb8c4fd6768756559cdabc18bacc8661c86ebd411be9e6cd1036041c09 #记住上边的node加入集群的命令,如果忘记,可以使用如下命令获?。?kubeadm token create --print-join-command
文章插图
4、部署node节点
#所有node节点执行:#请确保基础环境已经部署好(时间同步,防火墙,解析 , swap,内核参数)[root@node ~]#apt-get install -y ca-certificates curl software-properties-common apt-transport-https curl[root@node ~]#apt-get update && apt-get install -y apt-transport-https[root@node ~]#curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -[root@node ~]# cat <<EOF >/etc/apt/sources.list.d/kubernetes.listdeb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial mainEOF[root@node ~]#apt update[root@node ~]#apt install -y kubelet=1.23.1-00 kubeadm=1.23.1-00 kubectl=1.23.1-00[root@node2 ~]#apt-mark hold kubelet kubeadm kubectl
# 所有node节点执行:# 加入集群(master节点安装完成后的提示命令)[root@node ~]#kubeadm join 10.0.0.101:6443 --token abcdef.0123456789abcdef \> --discovery-token-ca-cert-hash sha256:415922bb8c4fd6768756559cdabc18bacc8661c86ebd411be9e6cd1036041c09#提示以下信息,表示加入集群成功......This node has joined the cluster:* Certificate signing request was sent to apiserver and a response was received.* The Kubelet was informed of the new secure connection details.Run 'kubectl get nodes' on the control-plane to see this node join the cluster.# 如果此处报错,则需要执行kubeadm reset重启
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 含源码 【YOLOv5】手把手教你使用LabVIEW ONNX Runtime部署 TensorRT加速,实现YOLOv5实时物体识别
- 云原生之旅 - 6)不能错过的一款 Kubernetes 应用编排管理神器 Kustomize
- 云原生之旅 - 5)Kubernetes时代的包管理工具 Helm
- 云原生之旅 - 4)基础设施即代码 使用 Terraform 创建 Kubernetes
- 二 Istio:在Kubernetes(k8s)集群上安装部署istio1.14
- .NET6打包部署到Windows Service
- docker swarm快速部署redis分布式集群
- 7 步保障 Kubernetes 集群安全
- 使用 etcdadm 快速、弹性部署 etcd 集群
- Cenots7 离线安装部署PostgreSQL