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.

    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?