not able to get the client-go from k8s

11/10/2016

I have tried all the possible paths that I can think of, I am not able to put the base examples to work with kubernetes and Go lang. I am new to all the godeps, gilde, govendor thing, I will give myself that, but even then I have no idea how can I simply get this package which is referenced like this in the example file -

"k8s.io/client-go/1.4/kubernetes"
    "k8s.io/client-go/1.4/pkg/api"
    "k8s.io/client-go/1.4/tools/clientcmd"

And to be precise, this is what is written here - https://github.com/kubernetes/client-go/tree/release-1.5

How to get it

You can go get to get a release of client-go, e.g., go get k8s.io/client-go/1.4/... or go get k8s.io/client-go/1.4/kubernetes.

Now when I do this. This is the output -

warning: "k8s.io/client-go/1.4/..." matched no packages can't load package: package .: no buildable Go source files in /Users/shubhadeeproychowdhury/projects/go/src

Although it clones things in a directory called k8s under src in my GOPATH.

Finally in the same link they are talking about dependency management and things, where they refer to a directory 1.4 under the client-do directory. I can not see that directory anywhere in the cloned k8s directory.

I have been trying to install the basic packages and run the example codes for two days now, I can't. I really feel awkward and strange. Can any one please help me with a clear step by step instructions on how to get started?

Note - 1: I have several other Go projects and I have not used dependency management so far. I do not want to mess up my other projects in order to try to install and use this one. I am sure there is way.

Note - 2: I have found this link - Samples on kubernetes golang client But it does not explain to me how to get over the primary hurdle to get it in my Go workspace and run the example code.

Kubernetes people, if you are listening, please be a little bit more elaborate in your documentation if possible. I will be happy to lend a hand in that, it is just that I do not know how to take the frist step at this point of time.

Please help

-- SRC
client
go
kubernetes

2 Answers

4/7/2017

Do a glide get [package-name], assuming you already have a glide.yaml present. In your case glide get k8s.io/client-go/1.4/kubernetes should do the trick.

-- Chetan
Source: StackOverflow

11/10/2016

I had the same issue myself. Previously all I needed to do was go get k8s.io/client-go/1.4/kubernetes and I was good to go. Now that fails with:

package k8s.io/client-go/1.4/kubernetes: cannot find package "k8s.io/client-go/1.4/kubernetes" in any of:

While documentation mentions use of package management tools I did not want to use them as there is already vendor directory from Go itself. I was able to resolve the issue by doing this:

  1. Create vendor directory in your project root.
  2. In vendor directory create k8s.io directory. This is to fix references from the library to itself.
  3. In k8s.io directory do git clone https://github.com/kubernetes/client-go.git
  4. In client-go directory do git checkout v1.5.0 (or the version you want). Checkout is important as v1.4/v1.5 are only in specific commits. Master for example no longer have these.
  5. In your project import with k8s.io/client-go/1.5/kubernetes
-- Matthew
Source: StackOverflow