Switch branches/tags
v9.0.0 v9.0.0-invalid v8.0.0 v7.0.0 v6.0.0 v5.0.1 v5.0.0 v4.0.0 v4.0.0-beta.0 v3.0.0 v3.0.0-beta.0 v2.0.0 v2.0.0-alpha.1 v2.0.0-alpha.0 v1.5.1 v1.5.0 v1.4.0 kubernetes-1.13.0-alpha.1 kubernetes-1.13.0-alpha.0 kubernetes-1.12.2-beta.0 kubernetes-1.12.1 kubernetes-1.12.1-beta.0 kubernetes-1.12.1-beta.0-invalid kubernetes-1.12.0 kubernetes-1.12.0-rc.2 kubernetes-1.12.0-rc.2-invalid kubernetes-1.12.0-rc.1 kubernetes-1.12.0-rc.1-invalid kubernetes-1.12.0-invalid kubernetes-1.12.0-beta.2 kubernetes-1.12.0-beta.2-invalid kubernetes-1.12.0-beta.1 kubernetes-1.12.0-beta.0 kubernetes-1.12.0-alpha.1 kubernetes-1.12.0-alpha.0 kubernetes-1.11.4-beta.0 kubernetes-1.11.3 kubernetes-1.11.3-beta.0 kubernetes-1.11.2 kubernetes-1.11.2-beta.0 kubernetes-1.11.1 kubernetes-1.11.1-beta.0 kubernetes-1.11.0 kubernetes-1.11.0-rc.3 kubernetes-1.11.0-rc.2 kubernetes-1.11.0-rc.1 kubernetes-1.11.0-beta.2 kubernetes-1.11.0-beta.1 kubernetes-1.11.0-beta.0 kubernetes-1.11.0-alpha.2 kubernetes-1.11.0-alpha.1 kubernetes-1.11.0-alpha.0 kubernetes-1.10.10-beta.0 kubernetes-1.10.9 kubernetes-1.10.9-beta.0 kubernetes-1.10.8 kubernetes-1.10.8-beta.0 kubernetes-1.10.7 kubernetes-1.10.7-beta.0 kubernetes-1.10.6 kubernetes-1.10.6-beta.0 kubernetes-1.10.5 kubernetes-1.10.5-beta.0 kubernetes-1.10.4 kubernetes-1.10.4-beta.0 kubernetes-1.10.3 kubernetes-1.10.3-beta.0 kubernetes-1.10.2 kubernetes-1.10.2-beta.0 kubernetes-1.10.1 kubernetes-1.10.1-beta.0 kubernetes-1.10.0 kubernetes-1.10.0-rc.1 kubernetes-1.10.0-beta.4 kubernetes-1.10.0-beta.3 kubernetes-1.10.0-beta.2 kubernetes-1.10.0-beta.1 kubernetes-1.10.0-beta.0 kubernetes-1.10.0-alpha.3 kubernetes-1.10.0-alpha.2 kubernetes-1.10.0-alpha.1 kubernetes-1.10.0-alpha.0 kubernetes-1.9.12-beta.0 kubernetes-1.9.11 kubernetes-1.9.11-beta.0 kubernetes-1.9.10 kubernetes-1.9.10-beta.0 kubernetes-1.9.9 kubernetes-1.9.9-beta.0 kubernetes-1.9.8 kubernetes-1.9.8-beta.0 kubernetes-1.9.7 kubernetes-1.9.7-beta.0 kubernetes-1.9.6 kubernetes-1.9.6-beta.0 kubernetes-1.9.5 kubernetes-1.9.5-beta.0 kubernetes-1.9.4 kubernetes-1.9.4-beta.0 kubernetes-1.9.3
Nothing to show
Find file Copy path
163 lines (124 sloc) 6.27 KB

Installing client-go

For the casual user

If you want to write a simple script, don't care about a reproducible client library install, don't mind getting head (which may be less stable than a particular release), then simply:

$ go get

This will install in your $GOPATH. includes most of its own dependencies in its path, except for and glog. go get will recursively download these excluded repos to your $GOPATH, if they don't already exist. If preexisted in $GOPATH, you also need to:

$ go get -u

because the head of client-go is only guaranteed to work with the head of apimachinery.

We excluded and glog from to prevent go get users from hitting issues like #19 and #83. If your project share other dependencies with client-go, and you hit issues similar to #19 or #83, then you'll need to look down at the next section.

Note: the official go policy is that libraries should not vendor their dependencies. This is unworkable for us, since our dependencies change and HEAD on every dependency has not necessarily been tested with client-go. In fact, HEAD from all dependencies may not even compile with client-go!

Dependency management for the serious (or reluctant) user

Reasons why you might need to use a dependency management system:

  • You use a dependency that client-go also uses, and don't want two copies of the dependency compiled into your application. For some dependencies with singletons or global inits (e.g. glog) this wouldn't even compile...
  • You want to lock in a particular version (so you don't have to change your code every time we change a public interface).
  • You want your install to be reproducible. For example, for your CI system or for new team members.

There are three tools you could in theory use for this. Instructions for each follows.


godep is an older dependency management tool, which is used by the main Kubernetes repo and client-go to manage dependencies.

Before proceeding with the below instructions, you should ensure that your $GOPATH is empty except for containing your own package and its dependencies, and you have a copy of godep somewhere in your $PATH.

To install client-go and place its dependencies in your $GOPATH:

go get
cd $GOPATH/src/
git checkout v9.0.0 # replace v9.0.0 with the required version
# cd 1.5 # only necessary with 1.5 and 1.4 clients.
godep restore ./...

At this point, client-go's dependencies have been placed in your $GOPATH, but if you were to build, client-go would still see its own copy of its dependencies in its vendor directory. You have two options at this point.

If you would like to keep dependencies in your own project's vendor directory, then you can continue like this:

cd $GOPATH/src/<my-pkg>
godep save ./...

Alternatively, if you want to build using the dependencies in your $GOPATH, then rm -rf vendor/ to remove client-go's copy of its dependencies.


Glide is another popular dependency management tool for Go. Glide will manage your /vendor directory, but unlike godep, will not use or modify your $GOPATH (there's no equivalent of godep restore or godep save).

Generally, it's best to avoid Glide's many subcommands, favoring modifying Glide's manifest file (glide.yaml) directly, then running glide update --strip-vendor. First create a glide.yaml file at the root of your project:

package: ( your project's import path ) # e.g.
- package:
  version: v9.0.0 # replace v9.0.0 with the required version

Second, add a Go file that imports client-go somewhere in your project, otherwise client-go's dependencies will not be added to your project's vendor/. Then run the following command in the same directory as glide.yaml:

glide update --strip-vendor

This can also be abbreviated as:

glide up -v

At this point, should be added to your project's vendor/. client-go's dependencies should be flattened and be added to your project's vendor/ as well.

Glide will detect the versions of dependencies client-go specified in client-go's Godep.json file, and automatically set the versions of these imports in your /vendor directory. It will also record the detected version of all dependencies in the glide.lock file.

Projects that require a different version of a dependency than client-go requests can override the version manually in glide.yaml. For example:

package: ( your project's import path ) # e.g.
- package:
  version: v9.0.0 # replace v9.0.0 with the required version
# Use a newer version of go-spew even though client-go wants an old one.
- package:
  version: v1.1.0

After modifying, run glide up -v again to re-populate your /vendor directory.

Optionally, Glide users can also use glide-vc after running glide up -v to remove unused files from /vendor.

Dep (Not supported yet!)

dep is an up-and-coming dependency management tool, which has the goal of being accepted as part of the standard go toolchain. However, client-go does NOT work well with dep yet. To support dep, we need to fix at least two issues:

  1. publish native Gopkg.toml in client-go and other repos, like;
  2. find a way to express transitive constraints (see

As a workaround, which may or may not be worthwhile, you can specify all client-go dependencies manually as override in Gopkg.toml with the versions listed in Godeps.json, and manually update them when you upgrade client-go version.

We are actively working on the two issues blocking using dep. For the meantime, we recommend using glide or godeps.