Kubernetes

Kubernetes - vSphere 雲提供商

  • July 7, 2021

我正在關注這個文件https://cloud-provider-vsphere.sigs.k8s.io/tutorials/kubernetes-on-vsphere-with-kubeadm.html

我正在使用負載均衡器作為我的 ControlPlaneEndpoint,現在我想將一個新的主節點加入到集群中並傳遞雲提供商標誌,通過下面的方法可以加入工作人員但是我不能這樣做一個新的大師。

kubectl -n kube-public get configmap cluster-info -o jsonpath='{.data.kubeconfig}' > discovery.yaml

# tee /etc/kubernetes/kubeadminitworker.yaml >/dev/null <<EOF
apiVersion: kubeadm.k8s.io/v1beta1
caCertPath: /etc/kubernetes/pki/ca.crt
discovery:
 file:
   kubeConfigPath: /etc/kubernetes/discovery.yaml
 timeout: 5m0s
 tlsBootstrapToken: y7yaev.9dvwxx6ny4ef8vlq
kind: JoinConfiguration
nodeRegistration:
 criSocket: /var/run/dockershim.sock
 kubeletExtraArgs:
   cloud-provider: external
EOF

第一個控制平面是通過以下方式創建的:

kubeadm init --config kubeadminit.yaml

apiVersion: kubeadm.k8s.io/v1beta2
bootstrapTokens:
- groups:
 - system:bootstrappers:kubeadm:default-node-token
 token: y7yaev.9dvwxx6ny4ef8vlq
 ttl: 0s
 usages:
 - signing
 - authentication
kind: InitConfiguration
localAPIEndpoint:
 advertiseAddress: 10.20.121.22
 bindPort: 6443
nodeRegistration:
 criSocket: /run/containerd/containerd.sock
 kubeletExtraArgs:
   cloud-provider: external
 name: cjblvk8smst1
 taints:
 - effect: NoSchedule
   key: node-role.kubernetes.io/master
---
apiServer:
 timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controlPlaneEndpoint: kubeproxy:6443
controllerManager: {}
dns:
 type: CoreDNS
etcd:
 local:
   dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.20.5
networking:
 dnsDomain: cluster.local
 podSubnet: 10.244.0.0/16
 serviceSubnet: 10.96.0.0/12
scheduler: {}

我嘗試通過以下方式加入第二個主節點,但是它作為工作節點連接:

kubeadm join --config kubeadminitSecondmaster.yaml

apiVersion: kubeadm.k8s.io/v1beta2
caCertPath: /etc/kubernetes/pki/ca.crt
discovery:
 file:
   kubeConfigPath: /etc/kubernetes/discovery.yaml
 timeout: 5m0s
 tlsBootstrapToken: y7yaev.9dvwxx6ny4ef8vlq
kind: JoinConfiguration
nodeRegistration:
 criSocket: /run/containerd/containerd.sock
 kubeletExtraArgs:
   cloud-provider: external
 name: kubemst2
 taints:
- effect: NoSchedule
   key: node-role.kubernetes.io/master
---
apiServer:
 timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controlPlaneEndpoint: kubesproxy:6443
controllerManager: {}
dns:
 type: CoreDNS
etcd:
 local:
   dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.20.5
networking:
 dnsDomain: cluster.local
 podSubnet: 10.244.0.0/16
 serviceSubnet: 10.96.0.0/12
scheduler: {}

集群資訊:

  • Kubernetes 版本:1.20.5
  • 正在使用的雲:裸機 - vSphere
  • 安裝方式:kubeadm
  • 主機作業系統:Centos 7.9
  • CNI 和版本:Weave 0.3.0
  • CRI 和版本:Containerd 1.4.4

謝謝

以這種方式更新集群解決了我的一個問題:

kubeadm upgrade apply --config kubeadm-config.yaml --ignore-preflight-errors all --upload-certs --force --v=5

文件:

apiServer:
 extraArgs:
   cloud-config: /etc/kubernetes/vsphere.conf
   cloud-provider: vsphere
   authorization-mode: Node,RBAC
 extraVolumes:
 - hostPath: /etc/kubernetes/vsphere.conf
   mountPath: /etc/kubernetes/vsphere.conf
   name: cloud
 timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controlPlaneEndpoint: k8s-proxy:6443
controllerManager:
 extraArgs:
   cloud-config: /etc/kubernetes/vsphere.conf
   cloud-provider: vsphere
 extraVolumes:
 - hostPath: /etc/kubernetes/vsphere.conf
   mountPath: /etc/kubernetes/vsphere.conf
   name: cloud
dns:
 type: CoreDNS
etcd:
 local:
   dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.20.6
networking:
 dnsDomain: cluster.local
 serviceSubnet: 10.96.0.0/12
scheduler: {}

您的kubeadm join命令缺少--control-plane參數。

kubeadm join --control-plane --config kubeadminitSecondmaster.yaml

如果沒有參數,節點將成為工作人員。

引用自:https://serverfault.com/questions/1060197