kuberent 客户端演示错误有什么问题



下载kubernetes SDK源代码

git clone https://github.com/kubernetes/client-go.git kubernet-client

,然后
cd kubernet-client/examples/in-cluster-client-configuration/和类型go run main.go,有错误

➜  in-cluster-client-configuration git:(master) go run main.go
# net
/usr/local/Cellar/go/1.18.2/libexec/src/net/dial.go:351:11: d.DialContext undefined (type *Dialer has no field or method DialContext)
/usr/local/Cellar/go/1.18.2/libexec/src/net/dial.go:372:18: invalid character U+2013 '–' in identifier
/usr/local/Cellar/go/1.18.2/libexec/src/net/lookup_unix.go:70:14: d.DialContext undefined (type Dialer has no field or method DialContext)
➜  in-cluster-client-configuration git:(master) pwd
go_sourcecode/kubernet-client/examples/in-cluster-client-configuration

go版本

➜  in-cluster-client-configuration git:(master) go version
go version go1.18.2 darwin/amd64

怎么了?

一步一步的过程已经写在markdown文件(https://github.com/kubernetes/client-go/tree/master/examples/in-cluster-client-configuration)中,为什么您不遵循它呢?

由于这是一个集群内示例,因此必须从kubernetes集群内部运行。go run main.go不起作用。要运行此命令,

  1. 生成二进制文件:go build -o ./app .
  2. 建立一个映像:docker build -t YOUR_DOCKER_ID/controller:in-cluster .
  3. 将它推送到docker hub:docker push IMAGE或者将这个映像加载到集群中。对于类簇:kind load docker-image IMAGE
  4. kubectl create clusterrolebinding default-view --clusterrole=view --serviceaccount=default:default
  5. 然后运行kubectl run --rm -i demo --image=IMAGE

相关内容

  • 没有找到相关文章

最新更新