kubernetes - Multimaster k8s 集群在一个主节点关闭后无响应
问题描述
我有一个 3 节点 K8s 集群,其中所有节点都配置为 Master 和 worker。我设置了一个观察者通知者,以便在删除节点时通知我的客户。
var sharedInformer = informers.NewSharedInformerFactory(kcv.kubeClient.K8sClient, 0)
// Add watcher for the Node.
kcv.nodeInformer = sharedInformer.Core().V1().Nodes().Informer()
kcv.nodeInformerChan = make(chan struct{})
// Node informer state change handler
kcv.nodeInformer.AddEventHandler(cache.ResourceEventHandlerFuncs {
// When a new node gets created
AddFunc: func(obj interface{}) {
kcv.handleAddNode(obj)
},
// When a node gets deleted
DeleteFunc: func(obj interface{}) {
kcv.handleDeleteNode(obj)
},
})
// Start the shared informer.
kcv.sharedInformerChan = make(chan struct{})
sharedInformer.Start(kcv.sharedInformerChan)
// Start the resource (node, pod and namespace) specific informers
kcv.nodeInformer.Run(kcv.nodeInformerChan)
kcv.podInformer.Run(kcv.podInformerChan)
kcv.nsInformer.Run(kcv.nsInformerChan)
现在,我看到了三种不同的行为。
- 当我“关闭”其中一个主虚拟机时,我没有看到任何通知发送到客户端。我期待通过上述代码收到通知。
- 在主 VM 确实关闭并尝试运行“kubectl get pods -n myns”后,我没有看到任何 pod 列表,并且它抛出以下错误。
kubectl get pods -n myns
Error from server (Timeout): the server was unable to return a response in the time allotted, but may still be processing the request (get pods)
- 当我恢复之前关闭的主虚拟机时,集群恢复正常工作。我能够列出所有三个主节点的 pod。
kubectl 版本信息:
kubectl version
Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.7", GitCommit:"6f482974b76db3f1e0f5d24605a9d1d38fad9a2b", GitTreeState:"clean", BuildDate:"2019-03-25T02:41:57Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.7", GitCommit:"6f482974b76db3f1e0f5d24605a9d1d38fad9a2b", GitTreeState:"clean", BuildDate:"2019-03-25T02:41:57Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}
码头工人版本:
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Server: Docker Engine - Community
Engine:
Version: 19.03.1
API version: 1.40 (minimum version 1.12)
Go version: go1.12.5
集群信息:
kubectl cluster-info
Kubernetes master is running at https://10.30.8.92:6443
coredns is running at https://10.30.8.92:6443/api/v1/namespaces/kube-system/services/coredns:dns/proxy
kubernetes-dashboard is running at https://10.30.8.92:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
解决方案
推荐阅读
- twilio - 使用 Twilio 函数发起出站电话会议
- c++ - 继承`sameFunctionName
()` 来自 2 个模板类 ==> 模棱两可 - java - 无法解析 JDABuilder 中的符号“createDefault”
- c++ - C++ std::swap - 它交换数据还是数据指针?
- jupyter-notebook - 从外部驱动器(Windows)运行 Jupyter Notebook?
- php - ECHO 无法正确显示文本
- javascript - 如何更新 google-maps-react 方向路线?
- php - 如何在 PHP 代码中捕获单选按钮组中的 onchange 或 onclick 事件?
- python-3.x - 根据一列过滤行,然后检查另一列的值是否在 Python 的特定列表中
- c++ - 除非通过开发人员命令提示符打开 vscode,否则无法识别 VSCode Microsoft C++ 构建工具?