kubernetes Kubectl错误:memcache.go:265]无法获取当前服务器API组列表:得到

mlnl4t2r  于 2023-10-17  发布在  Kubernetes
关注(0)|答案(4)|浏览(1241)

我的Kubernetes群集目前遇到了问题,需要一些帮助。直到今天,一切都很顺利。但是,在我的Ubuntu系统上执行了一次更新之后,我无法建立从我的工作环境到kubernetes集群的连接。
在执行kubectl get pods命令时,我遇到以下错误消息:
E0805 09:59:45.750534 234576 memcache.go:265] couldn’t get current server API group list: Get "http://localhost:3334/api?timeout=32s": EOF
以下是我的集群设置的详细信息:Kubernetes 1.27,裸机,主机系统为Ubuntu 20.04
我将非常感谢任何关于解决这个问题的指导或见解。

63lcw9qa

63lcw9qa1#

这是一个身份验证问题-API确保kubeconfig存在并纠正执行的用户命令。
这通常在引导集群时观察到,并且忘记在下面运行。

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
hl0ma9xz

hl0ma9xz2#

尝试

kubectl get nodes -v=10

并查找错误。

qco9c6ql

qco9c6ql3#

  • 我也遇到了同样的错误,这是因为kubectl找不到要连接的集群信息。
E0929 09:47:46.255639   47147 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
 E0929 09:47:46.256923   47147 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
 E0929 09:47:46.258847   47147 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
 E0929 09:47:46.260367   47147 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
 E0929 09:47:46.262189   47147 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
  • 使用kubectl config view测试,它应该返回空配置

kubectl config view apiVersion:v1群集:空上下文:null当前上下文:“”kind:配置首选项:{}用户:空
解决方案:

  • 手动配置集群或安装minikube,它将使用任何hypervisor或docker配置单个集群节点N.B:需要有一个虚拟机管理程序,例如:已安装VirtualBox或Docker
  • 按照minikube安装并启动minkube https://minikube.sigs.k8s.io/docs/start/
* minikube v1.31.2 on Darwin 12.6.8
    * Automatically selected the docker driver. Other choices: hyperkit, virtualbox, ssh
    * Using Docker Desktop driver with root privileges
    * Starting control plane node minikube in cluster minikube
    * Pulling base image ...
    * Downloading Kubernetes v1.27.4 preload ...
        > preloaded-images-k8s-v18-v1...:  393.21 MiB / 393.21 MiB  100.00% 2.96 Mi
        > gcr.io/k8s-minikube/kicbase...:  447.62 MiB / 447.62 MiB  100.00% 2.96 Mi
    * Creating docker container (CPUs=2, Memory=1986MB) ...
    * Preparing Kubernetes v1.27.4 on Docker 24.0.4 ...
      - Generating certificates and keys ...
      - Booting up control plane ...
      - Configuring RBAC rules ...
    * Configuring bridge CNI (Container Networking Interface) ...
    * Verifying Kubernetes components...
      - Using image gcr.io/k8s-minikube/storage-provisioner:v5
    * Enabled addons: storage-provisioner, default-storageclass
    * Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
    rako@Karims-MacBook-Air TestBeds & Apps % minikube status
    minikube
    type: Control Plane
    host: Running
    kubelet: Running
    apiserver: Running
    kubeconfig: Configured```
  • 再次测试,环境详细信息应该返回一些信息,而不是像以前一样为空
```kubectl config view 
  apiVersion: v1
  clusters:
  - cluster:
      certificate-authority: /Users/rako/.minikube/ca.crt
      extensions:
      - extension:
          last-update: Fri, 29 Sep 2023 10:13:33 CEST
          provider: minikube.sigs.k8s.io
          version: v1.31.2
        name: cluster_info
      server: https://127.0.0.1:64784
    name: minikube
  contexts:
  - context:
      cluster: minikube
      extensions:
      - extension:
          last-update: Fri, 29 Sep 2023 10:13:33 CEST
          provider: minikube.sigs.k8s.io
          version: v1.31.2
        name: context_info
      namespace: default
      user: minikube
    name: minikube
  current-context: minikube
  kind: Config
  preferences: {}
  users:
  - name: minikube
    user:
      client-certificate: /Users/rako/.minikube/profiles/minikube/client.crt
      client-key: /Users/rako/.minikube/profiles/minikube/client.key```
atmip9wb

atmip9wb4#

我在重新启动我的节点后遇到了这个错误。我注意到我的containerd被禁用使用sudo systemctl status containerd
为了解决这个问题,我重新启动了容器sudo systemctl restart containerd

相关问题