Go client for Kubernetes.
Switch branches/tags
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.12.0-alpha.1 kubernetes-1.12.0-alpha.0 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.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.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 kubernetes-1.9.3-beta.0 kubernetes-1.9.2 kubernetes-1.9.2-beta.0 kubernetes-1.9.1 kubernetes-1.9.1-beta.0 kubernetes-1.9.0 kubernetes-1.9.0-beta.2 kubernetes-1.9.0-beta.1 kubernetes-1.9.0-beta.0 kubernetes-1.9.0-alpha.3 kubernetes-1.9.0-alpha.2 kubernetes-1.9.0-alpha.1 kubernetes-1.9.0-alpha.0 kubernetes-1.8.16-beta.0 kubernetes-1.8.15 kubernetes-1.8.15-beta.0 kubernetes-1.8.14 kubernetes-1.8.14-beta.0 kubernetes-1.8.13 kubernetes-1.8.13-beta.0 kubernetes-1.8.12 kubernetes-1.8.12-beta.0 kubernetes-1.8.11 kubernetes-1.8.11-beta.0 kubernetes-1.8.10 kubernetes-1.8.10-beta.0 kubernetes-1.8.9 kubernetes-1.8.9-beta.0
Nothing to show
Clone or download
k8s-publishing-bot Merge pull request #67024 from juanvallejo/jvallejo/add-cancel-req-di…

Automatic merge from submit-queue (batch tested with PRs 66958, 67024). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

add CancelRequest to discovery round-tripper

**Release note**:

Make discovery roundtripper implement the RequestCanceler interface

cc @deads2k

Kubernetes-commit: a945b5d9281ac5cba5e4a2976a0747592c0cff87
Latest commit bdfc4cf Aug 6, 2018
Failed to load latest commit information.
.github client-go: document README exception in .github/PULL_REQUEST_TEMPLATE.md May 29, 2018
Godeps Merge pull request #67024 from juanvallejo/jvallejo/add-cancel-req-di… Aug 6, 2018
deprecated-dynamic dry-run: Update DynamicClient to pass Create/Update options Aug 1, 2018
discovery add CancelRequest to discovery round-tripper Aug 6, 2018
dynamic dry-run: Update DynamicClient to pass Create/Update options Aug 1, 2018
examples client-go/examples/fake-client: add doc.go to fix go build warnings Jun 24, 2018
informers Update generated files Jun 29, 2018
kubernetes fix panic fake SAR client expansion Jul 31, 2018
listers Autogenerated stuff May 24, 2018
pkg generated: Avoid use of reflect.Call in conversion code paths Jul 3, 2018
plugin/pkg/client/auth Set connrotation dialer via restclient.Config.Dialer Jul 25, 2018
rest stop adding internal types to external schemes Aug 3, 2018
restmapper fill in normal restmapping info with the legacy guess Jul 16, 2018
scale make package name match all the import aliases Aug 1, 2018
testing add Patch support in fake kubeClient Apr 11, 2018
third_party/forked/golang/template sync: initially remove files BUILD */BUILD BUILD.bazel */BUILD.bazel Mar 15, 2018
tools client-go: update documentation for remotecommand.StreamOptions Jul 16, 2018
transport add logging to find offending transports Aug 2, 2018
util apiserver: use fixtures for self-signed certs in test server Jul 6, 2018
vendor Merge pull request #66648 from feiskyer/azure-sdk-update Aug 6, 2018
.travis.yml bump go version to 1.8.1 for travis Jun 13, 2017
CHANGELOG.md Add client-go 8.0.0 changelog Jun 19, 2018
CONTRIBUTING.md Document that changes to the README.md are done in this repo May 25, 2018
INSTALL.md Update README.md and INSTALL.md for v6.0.0 Dec 18, 2017
LICENSE published by bot Dec 11, 2016
OWNERS client-go: start fresh with owner file May 25, 2018
README.md Update README to reflect 8.0.0 release Jun 19, 2018
SECURITY_CONTACTS add PST to main SECURITY_CONTACTS as formality May 24, 2018
code-of-conduct.md Add code-of-conduct.md to staging repos Dec 20, 2017



Go clients for talking to a kubernetes cluster.

We currently recommend using the v8.0.0 tag. See INSTALL.md for detailed installation instructions. go get k8s.io/client-go/... works, but will build master, which doesn't handle the dependencies well.

BuildStatus Widget GoReport Widget GoDocWidget

Table of Contents

What's included

  • The kubernetes package contains the clientset to access Kubernetes API.
  • The discovery package is used to discover APIs supported by a Kubernetes API server.
  • The dynamic package contains a dynamic client that can perform generic operations on arbitrary Kubernetes API objects.
  • The transport package is used to set up auth and start a connection.
  • The tools/cache package is useful for writing controllers.


client-go follows semver. We will not make backwards-incompatible changes without incrementing the major version number. A change is backwards-incompatible either if it i) changes the public interfaces of client-go, or ii) makes client-go incompatible with otherwise supported versions of Kubernetes clusters.

Changes that add features in a backwards-compatible way will result in bumping the minor version (second digit) number.

Bugfixes will result in the patch version (third digit) changing. PRs that are cherry-picked into an older Kubernetes release branch will result in an update to the corresponding branch in client-go, with a corresponding new tag changing the patch version.

A consequence of this is that client-go version numbers will be unrelated to Kubernetes version numbers.

Branches and tags.

We will create a new branch and tag for each increment in the major version number or minor version number. We will create only a new tag for each increment in the patch version number. See semver for definitions of major, minor, and patch.

The master branch will track HEAD in the main Kubernetes repo and accumulate changes. Consider HEAD to have the version x.(y+1).0-alpha or (x+1).0.0-alpha (depending on whether it has accumulated a breaking change or not), where x and y are the current major and minor versions.

Compatibility: your code <-> client-go

client-go follows semver, so until the major version of client-go gets increased, your code will compile and will continue to work with explicitly supported versions of Kubernetes clusters. You must use a dependency management system and pin a specific major version of client-go to get this benefit, as HEAD follows the upstream Kubernetes repo.

Compatibility: client-go <-> Kubernetes clusters

Since Kubernetes is backwards compatible with clients, older client-go versions will work with many different Kubernetes cluster versions.

We will backport bugfixes--but not new features--into older versions of client-go.

Compatibility matrix

Kubernetes 1.5 Kubernetes 1.6 Kubernetes 1.7 Kubernetes 1.8 Kubernetes 1.9 Kubernetes 1.10 Kubernetes 1.11
client-go 1.5 - - - - - - -
client-go 2.0 +- +- +- +- +- +-
client-go 3.0 +- - +- +- +- +-
client-go 4.0 +- +- +- +- +- +-
client-go 5.0 +- +- +- +- +- +-
client-go 6.0 +- +- +- +- +- +-
client-go 7.0 +- +- +- +- +- +-
client-go 8.0 +- +- +- +- +- +-
client-go HEAD +- +- +- +- +- +- +-


  • Exactly the same features / API objects in both client-go and the Kubernetes version.
  • + client-go has features or API objects that may not be present in the Kubernetes cluster, either due to that client-go has additional new API, or that the server has removed old API. However, everything they have in common (i.e., most APIs) will work. Please note that alpha APIs may vanish or change significantly in a single release.
  • - The Kubernetes cluster has features the client-go library can't use, either due to the server has additional new API, or that client-go has removed old API. However, everything they share in common (i.e., most APIs) will work.

See the CHANGELOG for a detailed description of changes between client-go versions.

Branch Canonical source code location Maintenance status
client-go 1.4 Kubernetes main repo, 1.4 branch = -
client-go 1.5 Kubernetes main repo, 1.5 branch = -
client-go 2.0 Kubernetes main repo, 1.5 branch = -
client-go 3.0 Kubernetes main repo, 1.6 branch = -
client-go 4.0 Kubernetes main repo, 1.7 branch = -
client-go 5.0 Kubernetes main repo, 1.8 branch = -
client-go 6.0 Kubernetes main repo, 1.9 branch
client-go 7.0 Kubernetes main repo, 1.10 branch
client-go 8.0 Kubernetes main repo, 1.11 branch
client-go HEAD Kubernetes main repo, master branch


  • Changes in main Kubernetes repo are actively published to client-go by a bot
  • = Maintenance is manual, only severe security bugs will be patched.
  • - Deprecated; please upgrade.

Deprecation policy

We will maintain branches for at least six months after their first stable tag is cut. (E.g., the clock for the release-2.0 branch started ticking when we tagged v2.0.0, not when we made the first alpha.) This policy applies to every version greater than or equal to 2.0.

Why do the 1.4 and 1.5 branch contain top-level folder named after the version?

For the initial release of client-go, we thought it would be easiest to keep separate directories for each minor version. That soon proved to be a mistake. We are keeping the top-level folders in the 1.4 and 1.5 branches so that existing users won't be broken.

Kubernetes tags

This repository is still a mirror of k8s.io/kubernetes/staging/src/client-go, the code development is still done in the staging area. Since Kubernetes 1.8 release, when syncing the code from the staging area, we also sync the Kubernetes version tags to client-go, prefixed with "kubernetes-". For example, if you check out the kubernetes-v1.8.0 tag in client-go, the code you get is exactly the same as if you check out the v1.8.0 tag in kubernetes, and change directory to staging/src/k8s.io/client-go. The purpose is to let users quickly find matching commits among published repos, like sample-apiserver, apiextension-apiserver, etc. The Kubernetes version tag does NOT claim any backwards compatibility guarantees for client-go. Please check the semantic versions if you care about backwards compatibility.

How to get it

You can use go get k8s.io/client-go/... to get client-go, but you will get the unstable master branch and client-go's vendored dependencies will not be added to your $GOPATH. So we think most users will want to use a dependency management system. See INSTALL.md for detailed instructions.

How to use it

If your application runs in a Pod in the cluster, please refer to the in-cluster example, otherwise please refer to the out-of-cluster example.

Dependency management

If your application depends on a package that client-go depends on, and you let the Go compiler find the dependency in GOPATH, you will end up with duplicated dependencies: one copy from the GOPATH, and one from the vendor folder of client-go. This will cause unexpected runtime error like flag redefinition, since the go compiler ends up importing both packages separately, even if they are exactly the same thing. If this happens, you can either

  • run godep restore (godep) in the client-go/ folder, then remove the vendor folder of client-go. Then the packages in your GOPATH will be the only copy
  • or run godep save in your application folder to flatten all dependencies.

Contributing code

Please send pull requests against the client packages in the Kubernetes main repository. Changes in the staging area will be published to this repository every day.