client-go

module
v8.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2018 License: Apache-2.0

README

client-go

Go clients for talking to a kubernetes cluster.

We currently recommend using the v7.0.0 tag. See INSTALL.md for detailed installation instructions. go get k8s.io/client-go/... works, but will give you head and 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.
Versioning

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.4 Kubernetes 1.5 Kubernetes 1.6 Kubernetes 1.7 Kubernetes 1.8 Kubernetes 1.9 Kubernetes 1.10
client-go 1.4 - - - - - -
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 HEAD +- +- +- +- +- + +

Key:

  • 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 HEAD Kubernetes main repo, master branch

Key:

  • 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

As of April 2018, client-go 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.

Directories

Path Synopsis
Package dynamic provides a client interface to arbitrary Kubernetes APIs that exposes common high level operations and exposes common metadata.
Package dynamic provides a client interface to arbitrary Kubernetes APIs that exposes common high level operations and exposes common metadata.
Package transport provides a round tripper capable of caching HTTP responses.
Package transport provides a round tripper capable of caching HTTP responses.
examples
create-update-delete-deployment
Note: the example only works with the code within the same release/branch.
Note: the example only works with the code within the same release/branch.
in-cluster-client-configuration
Note: the example only works with the code within the same release/branch.
Note: the example only works with the code within the same release/branch.
out-of-cluster-client-configuration
Note: the example only works with the code within the same release/branch.
Note: the example only works with the code within the same release/branch.
This package has the automatically generated clientset.
This package has the automatically generated clientset.
fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
typed/admissionregistration/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/admissionregistration/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/admissionregistration/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/admissionregistration/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/apps/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/apps/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/apps/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/apps/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/apps/v1beta2
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/apps/v1beta2/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/authentication/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/authentication/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/authentication/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/authentication/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/authorization/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/authorization/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/authorization/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/authorization/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/autoscaling/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/autoscaling/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/autoscaling/v2beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/autoscaling/v2beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/batch/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/batch/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/batch/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/batch/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/batch/v2alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/batch/v2alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/certificates/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/certificates/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/core/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/core/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/events/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/events/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/extensions/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/extensions/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/networking/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/networking/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/policy/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/policy/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/rbac/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/rbac/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/rbac/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/rbac/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/rbac/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/rbac/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/scheduling/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/scheduling/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/scheduling/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/scheduling/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/settings/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/settings/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/storage/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/storage/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/storage/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/storage/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/storage/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/storage/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
listers
pkg
apis/clientauthentication
+k8s:deepcopy-gen=package +groupName=client.authentication.k8s.io
+k8s:deepcopy-gen=package +groupName=client.authentication.k8s.io
apis/clientauthentication/install
Package install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
Package install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
apis/clientauthentication/v1alpha1
+groupName=client.authentication.k8s.io
+groupName=client.authentication.k8s.io
apis/clientauthentication/v1beta1
+groupName=client.authentication.k8s.io
+groupName=client.authentication.k8s.io
version
Package version supplies version information collected at build time to kubernetes components.
Package version supplies version information collected at build time to kubernetes components.
plugin
fake
This is made a separate package and should only be imported by tests, because it imports testapi
This is made a separate package and should only be imported by tests, because it imports testapi
Package scale provides a polymorphic scale client capable of fetching and updating Scale for any resource which implements the `scale` subresource, as long as that subresource operates on a version of scale convertable to autoscaling.Scale.
Package scale provides a polymorphic scale client capable of fetching and updating Scale for any resource which implements the `scale` subresource, as long as that subresource operates on a version of scale convertable to autoscaling.Scale.
fake
Package fake provides a fake client interface to arbitrary Kubernetes APIs that exposes common high level operations and exposes common metadata.
Package fake provides a fake client interface to arbitrary Kubernetes APIs that exposes common high level operations and exposes common metadata.
scheme
Package scheme contains a runtime.Scheme to be used for serializing and deserializing different versions of Scale, and for converting in between them.
Package scheme contains a runtime.Scheme to be used for serializing and deserializing different versions of Scale, and for converting in between them.
scheme/appsint
Package appsint contains the necessary scaffolding of the internal version of extensions as required by conversion logic.
Package appsint contains the necessary scaffolding of the internal version of extensions as required by conversion logic.
scheme/extensionsint
Package extensionsint contains the necessary scaffolding of the internal version of extensions as required by conversion logic.
Package extensionsint contains the necessary scaffolding of the internal version of extensions as required by conversion logic.
third_party
forked/golang/template
This package is copied from Go library text/template.
This package is copied from Go library text/template.
tools
auth
Package auth defines a file format for holding authentication information needed by clients of Kubernetes.
Package auth defines a file format for holding authentication information needed by clients of Kubernetes.
bootstrap/token/api
Package api (k8s.io/client-go/tools/bootstrap/token/api) contains constants and types needed for bootstrap tokens as maintained by the BootstrapSigner and TokenCleaner controllers (in k8s.io/kubernetes/pkg/controller/bootstrap)
Package api (k8s.io/client-go/tools/bootstrap/token/api) contains constants and types needed for bootstrap tokens as maintained by the BootstrapSigner and TokenCleaner controllers (in k8s.io/kubernetes/pkg/controller/bootstrap)
cache
Package cache is a client-side caching mechanism.
Package cache is a client-side caching mechanism.
clientcmd
Package clientcmd provides one stop shopping for building a working client from a fixed config, from a .kubeconfig file, from command line flags, or from any merged combination.
Package clientcmd provides one stop shopping for building a working client from a fixed config, from a .kubeconfig file, from command line flags, or from any merged combination.
clientcmd/api
+k8s:deepcopy-gen=package
+k8s:deepcopy-gen=package
clientcmd/api/v1
+k8s:deepcopy-gen=package
+k8s:deepcopy-gen=package
leaderelection
Package leaderelection implements leader election of a set of endpoints.
Package leaderelection implements leader election of a set of endpoints.
metrics
Package metrics provides abstractions for registering which metrics to record.
Package metrics provides abstractions for registering which metrics to record.
portforward
Package portforward adds support for SSH-like port forwarding from the client's local host to remote containers.
Package portforward adds support for SSH-like port forwarding from the client's local host to remote containers.
record
Package record has all client logic for recording and reporting events.
Package record has all client logic for recording and reporting events.
remotecommand
Package remotecommand adds support for executing commands in containers, with support for separate stdin, stdout, and stderr streams, as well as TTY.
Package remotecommand adds support for executing commands in containers, with support for separate stdin, stdout, and stderr streams, as well as TTY.
util
cert/triple
Package triple generates key-certificate pairs for the triple (CA, Server, Client).
Package triple generates key-certificate pairs for the triple (CA, Server, Client).
connrotation
Package connrotation implements a connection dialer that tracks and can close all created connections.
Package connrotation implements a connection dialer that tracks and can close all created connections.
jsonpath
package jsonpath is a template engine using jsonpath syntax, which can be seen at http://goessner.net/articles/JsonPath/.
package jsonpath is a template engine using jsonpath syntax, which can be seen at http://goessner.net/articles/JsonPath/.
workqueue
Package workqueue provides a simple queue that supports the following features:
Package workqueue provides a simple queue that supports the following features:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL