Kubernetes客户端Go找不到模块

问题描述

我正在尝试连接到minikubehere's the code for the same上托管的本地Kubernetes集群,现在当我执行go run minikube.go时,出现一个错误:

../../../pkg/mod/k8s.io/client-go@v11.0.0+incompatible/kubernetes/scheme/register.go:26:2: module k8s.io/api@latest found (v0.19.0),but does not contain package k8s.io/api/auditregistration/v1alpha1`.

现在,我尝试使用go get手动安装软件包,然后发现该软件包不存在。 我如何使其工作并解决此问题? 万一有人想看到我的go.mod file

解决方法

始终在go.mod文件中指定所有三个k8s.io / ...组件的匹配版本

require (
    ...
    k8s.io/api v0.19.0
    k8s.io/apimachinery v0.19.0
    k8s.io/client-go v0.19.0
    ...
)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...