* Add warning handler callback function in shortcut expander Currently, errors in client-go are propagated back to the callers via function returns. However, there is no elegant way for just warning users. For example, when user wants to get a resource with it's short name format and if there are multiple resources belonging to this short name, we need to warn user about this ambugity which one is picked and which ones are discarded. Not only to overcome this particular case mentioned above, but also propose a way for the possible warnings in the future, this commit adds a warningHandler callback function in shortcutExpander. * Add warningPrinter functionality in ConfigFlags ConfigFlags has neither warning user in a standardized format functionality nor passing warning callback functions to other upper level libraries such as client-go. This commit adds an ability that user can set warningPrinters according to their IOStreams and this warningPrinters will be used to raise possible warnings happening not only in cli-runtime but also in client-go. * Pass warning callback function in ConfigFlags to shortcutExpander This commit passes warning callback function to print possible warnings happened in shortcut expander to warn user in a standardized format. * Add integration test for CRDs having ambiguous short names This commit adds integration test to assure that warning message related to this ambiguity is printed when resources are being retrieved via their short name representations in cases where multiple resources have same short names. This integration test also ensures that the logic behind which resource will be selected hasn't been changed which may cause disperancies in clusters. * Remove defaultConfigFlag global variable * Move default config flags initialization into function * Skip warning for versions of same group/resource * Run update-vendor * Warn only once when there are multiple versions registered for ambiguous resource * Apply gocritic review * Add multi-resource multi-version ambiguity unit test Kubernetes-commit: a504aed54d028dbc8ea2508142c94d309f5f1ec6 |
||
---|---|---|
.github | ||
applyconfigurations | ||
discovery | ||
dynamic | ||
examples | ||
informers | ||
kubernetes | ||
kubernetes_test | ||
listers | ||
metadata | ||
openapi | ||
openapi3 | ||
pkg | ||
plugin/pkg/client/auth | ||
rest | ||
restmapper | ||
scale | ||
testing | ||
third_party/forked/golang | ||
tools | ||
transport | ||
util | ||
CHANGELOG.md | ||
code-of-conduct.md | ||
CONTRIBUTING.md | ||
doc.go | ||
go.mod | ||
go.sum | ||
INSTALL.md | ||
LICENSE | ||
OWNERS | ||
README.md | ||
SECURITY_CONTACTS |
client-go
Go clients for talking to a kubernetes cluster.
We recommend using the v0.x.y
tags for Kubernetes releases >= v1.17.0
and
kubernetes-1.x.y
tags for Kubernetes releases < v1.17.0
.
The fastest way to add this library to a project is to run go get k8s.io/client-go@latest
with go1.16+.
See INSTALL.md for detailed installation instructions and troubleshooting.
Table of Contents
- What's included
- Versioning
- Kubernetes tags
- How to get it
- How to use it
- Dependency management
- Contributing code
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
plugin/pkg/client/auth
packages contain optional authentication plugins for obtaining credentials from external sources. - The
transport
package is used to set up auth and start a connection. - The
tools/cache
package is useful for writing controllers.
Versioning
-
For each
v1.x.y
Kubernetes release, the major version (first digit) would remain0
. -
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.
Branches and tags.
We will create a new branch and tag for each increment in the 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 HEAD of the master branch in client-go will track the HEAD of the master branch in the main Kubernetes repo.
Compatibility: your code <-> client-go
The v0.x.y
tags indicate that go APIs may change in incompatible ways in
different versions.
See INSTALL.md for guidelines on requiring a specific version of client-go.
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.15 | Kubernetes 1.16 | Kubernetes 1.17 | Kubernetes 1.18 | Kubernetes 1.19 | Kubernetes 1.20 | |
---|---|---|---|---|---|---|
kubernetes-1.15.0 |
✓ | +- | +- | +- | +- | +- |
kubernetes-1.16.0 |
+- | ✓ | +- | +- | +- | +- |
kubernetes-1.17.0 /v0.17.0 |
+- | +- | ✓ | +- | +- | +- |
kubernetes-1.18.0 /v0.18.0 |
+- | +- | +- | ✓ | +- | +- |
kubernetes-1.19.0 /v0.19.0 |
+- | +- | +- | +- | ✓ | +- |
kubernetes-1.20.0 /v0.20.0 |
+- | +- | +- | +- | +- | ✓ |
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 |
---|---|---|
release-1.4 |
Kubernetes main repo, 1.4 branch | = - |
release-1.5 |
Kubernetes main repo, 1.5 branch | = - |
release-2.0 |
Kubernetes main repo, 1.5 branch | = - |
release-3.0 |
Kubernetes main repo, 1.6 branch | = - |
release-4.0 |
Kubernetes main repo, 1.7 branch | = - |
release-5.0 |
Kubernetes main repo, 1.8 branch | = - |
release-6.0 |
Kubernetes main repo, 1.9 branch | = - |
release-7.0 |
Kubernetes main repo, 1.10 branch | = - |
release-8.0 |
Kubernetes main repo, 1.11 branch | =- |
release-9.0 |
Kubernetes main repo, 1.12 branch | =- |
release-10.0 |
Kubernetes main repo, 1.13 branch | =- |
release-11.0 |
Kubernetes main repo, 1.14 branch | =- |
release-12.0 |
Kubernetes main repo, 1.15 branch | =- |
release-13.0 |
Kubernetes main repo, 1.16 branch | =- |
release-14.0 |
Kubernetes main repo, 1.17 branch | ✓ |
release-1.18 |
Kubernetes main repo, 1.18 branch | ✓ |
release-1.19 |
Kubernetes main repo, 1.19 branch | ✓ |
release-1.20 |
Kubernetes main repo, 1.20 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
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 v1.8.0
, when syncing the code from the staging area,
we also sync the Kubernetes version tags to client-go, prefixed with
kubernetes-
. From Kubernetes v1.17.0
, we also create matching semver
v0.x.y
tags for each v1.x.y
Kubernetes release.
For example, if you check out the kubernetes-1.17.0
or the v0.17.0
tag in
client-go, the code you get is exactly the same as if you check out the v1.17.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
To get the latest version, use go1.16+ and fetch using the go get
command. For example:
go get k8s.io/client-go@latest
To get a specific version, use go1.11+ and fetch the desired version using the go get
command. For example:
go get k8s.io/client-go@v0.20.4
See INSTALL.md for detailed instructions and troubleshooting.
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
For details on how to correctly use a dependency management for installing client-go, please see INSTALL.md.
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.