duanhun3273 2016-09-07 18:04
浏览 396

K8s Go客户端库在go get上找不到包

We wrote some Go code to talk to our Kubernetes cluster and fetch the IP of a Service exposed. We do it like so:

(import "gopkg.in/kubernetes/kubernetes.v1/pkg/client/restclient")
(import kubectl "gopkg.in/kubernetes/kubernetes.v1/pkg/client/unversioned")

 svc, err := c.Services(k8sNS).Get(svcName)
 if err != nil {
   panic(l.Errorf("Could not retrieve svc details. %s", err.Error()))
 }
 svcIP := svc.Status.LoadBalancer.Ingress[0].IP

go get works fine, and our script executes when we do go run ... and everybody is happy. Now, as of yesterday (from the time this question is posted) on the same script - go get fails. The error is like so:

[09.07.2016 10:56 AM]$ go get
package k8s.io/kubernetes/pkg/apis/authentication.k8s.io/install: cannot find package "k8s.io/kubernetes/pkg/apis/authentication.k8s.io/install" in any of:
        /usr/local/go/src/k8s.io/kubernetes/pkg/apis/authentication.k8s.io/install (from $GOROOT)
        /home/ckotha/godir/src/k8s.io/kubernetes/pkg/apis/authentication.k8s.io/install (from $GOPATH)

We have not specifically used authentication package in our code. Are we importing kubernetes libraries correctly? is there another way to do this ?

ls on $GOPATH/k8s.io/kubernetes/pkg/apis/ and found this:

:~/godir/src/k8s.io/kubernetes/pkg/apis
[09.07.2016 10:53 AM]$ ls
abac  apps  authentication  authorization  autoscaling  batch  certificates  componentconfig  extensions  imagepolicy  OWNERS  policy  rbac  storage
  • 写回答

1条回答 默认 最新

  • duanhanzi8328 2016-09-07 19:38
    关注

    It looks like a package you imported has changed.

    You can update existing repositories:

    go get -u
    

    The -u flag instructs get to use the network to update the named packages and their dependencies. By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages.

    You do use gopkg.io to pin the version to v1, but I think you want to be more specific, eg, v1.3.6 (EDIT: this won't work because gopkg.in doesn't permit package selectors more specific than the major version.).

    Alternatively, a good way to ensure code stays the same is to compile your binary and execute that, instead of using go run.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?