kubernetes client-go依赖报错

lpwlpw123 · · 1738 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

初次使用kubenetes client-go来学习遇到的问题。
代码使用github 练习:examples/out-of-cluster-client-configuration/main.go
使用go build -o app . 出现以下错误

# k8s.io/client-go/tools/clientcmd/api/v1
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\tools\clientcmd\api\v1\conversion.go:29:15: scheme.AddConversionFuncs undefined (type *runtime.Scheme has no field or method AddConversionFuncs)
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\tools\clientcmd\api\v1\conversion.go:31:12: s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\tools\clientcmd\api\v1\conversion.go:34:12: s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\tools\clientcmd\api\v1\conversion.go:37:12: s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\tools\clientcmd\api\v1\conversion.go:40:12: s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\tools\clientcmd\api\v1\conversion.go:43:12: s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\tools\clientcmd\api\v1\conversion.go:46:12: s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\tools\clientcmd\api\v1\conversion.go:49:12: s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\tools\clientcmd\api\v1\conversion.go:52:12: s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)
# k8s.io/client-go/rest
D:\software\gotest\pkg\mod\k8s.io\client-go@v11.0.0+incompatible\rest\request.go:598:31: not enough arguments in call to watch.NewStreamWatcher

golang version:1.14
client-go version: 1.18
修改go.mod 文件,替换k8s.io\client-go@v11.0.0+incompatible为k8s.io/client-go v0.18.2,然后在go build就可以了,github issue中解释如下:

Related issue is that go get k8s.io/client-go@latest resolves to v11.0.0+incompatible not v0.18.2. Should I break this off as a separate discussion?

Unfortunately, that is not possible to resolve. k8s.io/client-go had major versions tagged prior to the introduction of go modules. go modules require any major version X >= 2 rename the module to k8s.io/client-go/v<X>.

Go considers tags >= 2.x.x which contain a go.mod file with a module name that doesn't end with /v<X> invalid and won't include them when resolving @latest, so until the k8s.io/client-go module is renamed with version suffixes, go get must indicate specific versions (e.g. go get k8s.io/client-go@v0.18.2)

有疑问加站长微信联系(非本文作者)

本文来自:51CTO博客

感谢作者:lpwlpw123

查看原文:kubernetes client-go依赖报错

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1738 次点击  
加入收藏 微博
上一篇:golang之JWT实现
下一篇:golang 字符串
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传