kubernetes client-go依赖报错
2021-02-14 06:20
标签:watch ide main nts uil with ecif contain spec golang version:1.14 kubernetes client-go依赖报错 标签:watch ide main nts uil with ecif contain spec 原文地址:https://blog.51cto.com/qikexing/2499938
代码使用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
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