无法更新锁:无法在端点上完成操作

时间:2019-09-03 16:17:00

标签: kubernetes

我只是从二进制文件安装kubernetes控制器管理器:

cp -r /data/k8s/package/kubernetes/server/kubernetes/server/bin /usr/local/bin

使用以下命令启动kubernetes控制器管理器服务时:

/usr/local/bin/kube-controller-manager --address=127.0.0.1 --service-cluster-ip-range=10.254.0.0/16 --cluster-name=kubernetes --cluster-signing-cert-file=/etc/kubernetes/ssl/ca.pem --cluster-signing-key-file=/etc/kubernetes/ssl/ca-key.pem  --service-account-private-key-file=/etc/kubernetes/ssl/ca-key.pem --root-ca-file=/etc/kubernetes/ssl/ca.pem --leader-elect=true --master=http://172.19.104.231:8080

显示此日志:

    E0905 23:04:10.866049   21126 leaderelection.go:359] Failed to update lock: Operation cannot be fulfilled on endpoints "kube-controller-manager": StorageError: invalid object, Code: 4, Key: /registry/services/endpoints/kube-system/kube-controller-manager, ResourceVersion: 0, AdditionalErrorMsg: Precondition failed: UID in precondition: 0c84a2ba-80f5-11e9-b3ce-00163e086f0c, UID in object meta: eec95e0e-65a1-4941-be87-d70f5f2429d7
E0905 23:04:12.197416   21510 leaderelection.go:359] Failed to update lock: Operation cannot be fulfilled on endpoints "kube-scheduler": StorageError: invalid object, Code: 4, Key: /registry/services/endpoints/kube-system/kube-scheduler, ResourceVersion: 0, AdditionalErrorMsg: Precondition failed: UID in precondition: 121bc661-80f5-11e9-b3ce-00163e086f0c, UID in object meta: 49e84916-589a-4da5-b78a-761a1fe78285

该如何解决此错误?这是kubectl版本:

[root@iZuf63refzweg1d9dh94t8Z ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T09:23:26Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T09:15:22Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

1 个答案:

答案 0 :(得分:1)

首先,感谢您提供我要求的其他信息。但是,仍然不清楚如何以及其他配置方式。

但是我可以看到您决定经历“艰难的过程”。

前段时间,我成功地通过了广为人知的kelseyhightower/kubernetes-the-hard-way的集群创建过程。

您可以找到有关在k8s集群中配置各个部分的逐步说明。

看看Configure the Kubernetes Controller Manager文档下的Bootstrapping the Kubernetes Control Plane部分。

配置Kubernetes Controller Manager

kube-controller-manager kubeconfig移到适当位置:

sudo mv kube-controller-manager.kubeconfig /var/lib/kubernetes/

创建kube-controller-manager.service系统单位文件:

cat <<EOF | sudo tee /etc/systemd/system/kube-controller-manager.service
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/kubernetes/kubernetes

[Service]
ExecStart=/usr/local/bin/kube-controller-manager \\
  --address=0.0.0.0 \\
  --cluster-cidr=10.200.0.0/16 \\
  --cluster-name=kubernetes \\
  --cluster-signing-cert-file=/var/lib/kubernetes/ca.pem \\
  --cluster-signing-key-file=/var/lib/kubernetes/ca-key.pem \\
  --kubeconfig=/var/lib/kubernetes/kube-controller-manager.kubeconfig \\
  --leader-elect=true \\
  --root-ca-file=/var/lib/kubernetes/ca.pem \\
  --service-account-private-key-file=/var/lib/kubernetes/service-account-key.pem \\
  --service-cluster-ip-range=10.32.0.0/24 \\
  --use-service-account-credentials=true \\
  --v=2
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

但是同样,如果没有这个难题的其他重要部分,这部分将无法工作。 希望它能帮助您达到预期的效果