首页 > 解决方案 > 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)

现在,我看到了三种不同的行为。

 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)

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

标签: kubernetes

解决方案


推荐阅读