• Stars
    star
    8,516
  • Rank 4,080 (Top 0.09 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Go client for Kubernetes.

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.

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 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 remain 0.

  • 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/[email protected]

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.

More Repositories

1

kubernetes

Production-Grade Container Scheduling and Management
Go
105,869
star
2

minikube

Run Kubernetes locally
Go
28,262
star
3

ingress-nginx

Ingress-NGINX Controller for Kubernetes
Go
16,503
star
4

kops

Kubernetes Operations (kOps) - Production Grade k8s Installation, Upgrades and Management
Go
15,486
star
5

dashboard

General-purpose web UI for Kubernetes clusters
Go
13,699
star
6

community

Kubernetes community content
Jupyter Notebook
11,570
star
7

kompose

Convert Compose to Kubernetes
Go
9,056
star
8

autoscaler

Autoscaling components for Kubernetes
Go
7,628
star
9

examples

Kubernetes application example tutorials
Shell
5,992
star
10

kube-state-metrics

Add-on agent to generate and expose cluster-level metrics.
Go
5,018
star
11

website

Kubernetes website and documentation repo:
HTML
4,237
star
12

test-infra

Test infrastructure for the Kubernetes project.
Go
3,775
star
13

kubeadm

Aggregator for issues filed against kubeadm
Go
3,632
star
14

enhancements

Enhancements tracking repo for Kubernetes
Go
3,220
star
15

sample-controller

Repository for sample controller. Complements sample-apiserver
Go
2,987
star
16

node-problem-detector

This is a place for various problem detectors running on the Kubernetes nodes.
Go
2,706
star
17

kubectl

Issue tracker and mirror of kubectl code
Go
2,653
star
18

git-sync

A sidecar app which clones a git repo and keeps it in sync with the upstream.
Shell
1,994
star
19

code-generator

Generators for kube-like API types
Go
1,596
star
20

ingress-gce

Ingress controller for Google Cloud
Go
1,248
star
21

dns

Kubernetes DNS service
Go
871
star
22

perf-tests

Performance tests and benchmarks
Go
849
star
23

apimachinery

Go
774
star
24

k8s.io

Code and configuration to manage Kubernetes project infrastructure, including various *.k8s.io sites
HCL
667
star
25

apiserver

Library for writing a Kubernetes-style API server.
Go
613
star
26

api

The canonical location of the Kubernetes API definition.
Go
609
star
27

cloud-provider-openstack

Go
582
star
28

gengo

gengo library for code generation.
Go
533
star
29

sig-release

Repo for SIG release
Shell
512
star
30

sample-apiserver

Reference implementation of an apiserver for a custom Kubernetes API.
Go
496
star
31

metrics

Kubernetes metrics-related API types and clients
Go
478
star
32

release

Release infrastructure for Kubernetes and related components
Go
470
star
33

design-proposals-archive

Archive of Kubernetes Design Proposals
Makefile
442
star
34

cri-api

Container Runtime Interface (CRI) – a plugin interface which enables kubelet to use a wide variety of container runtimes.
Go
357
star
35

cloud-provider-aws

Cloud provider for AWS
Go
350
star
36

cloud-provider-alibaba-cloud

CloudProvider for Alibaba Cloud
Go
345
star
37

registry.k8s.io

This project is the repo for registry.k8s.io, the production OCI registry service for Kubernetes' container image artifacts
Go
340
star
38

utils

Non-Kubernetes-specific utility libraries which are consumed by multiple projects.
Go
306
star
39

kube-openapi

Kubernetes OpenAPI spec generation & serving
Go
289
star
40

kubelet

kubelet component configs
Go
281
star
41

sample-cli-plugin

Sample kubectl plugin
Go
278
star
42

cli-runtime

Set of helpers for creating kubectl commands and plugins.
Go
270
star
43

kube-aggregator

Aggregator for Kubernetes-style API servers: dynamic registration, discovery summarization, secure proxy
Go
242
star
44

org

Meta configuration for Kubernetes Github Org
Go
232
star
45

apiextensions-apiserver

API server for API extensions like CustomResourceDefinitions
Go
223
star
46

cloud-provider-vsphere

Kubernetes Cloud Provider for vSphere https://cloud-provider-vsphere.sigs.k8s.io
Go
221
star
47

cloud-provider

cloud-provider defines the shared interfaces which Kubernetes cloud providers implement. These interfaces allow various controllers to integrate with any cloud provider in a pluggable fashion. Also serves as an issue tracker for SIG Cloud Provider.
Go
219
star
48

kubernetes-template-project

A template for starting new projects on the github.com/kubernetes organization
176
star
49

kube-proxy

kube-proxy component configs
Go
166
star
50

committee-security-response

Kubernetes Security Process and Security Committee docs
161
star
51

kube-scheduler

kube-scheduler component configs
Go
150
star
52

sig-security

Process documentation, non-code deliverables, and miscellaneous artifacts of Kubernetes SIG Security
Python
146
star
53

component-base

Shared code for kubernetes core components
Go
102
star
54

repo-infra

Kubernetes repository infrastucture tools
Starlark
95
star
55

cloud-provider-gcp

cloud-provider-gcp contains several projects used to run Kubernetes in Google Cloud
Go
95
star
56

pod-security-admission

Kubernetes Pod Security Standards implementation - https://github.com/kubernetes/enhancements/blob/master/keps/sig-auth/2579-psp-replacement/README.md
Go
94
star
57

kube-controller-manager

kube-controller-manager component configs
Go
81
star
58

publishing-bot

Code behind the robot to publish from staging to real repositories.
Go
79
star
59

steering

The Kubernetes Steering Committee
79
star
60

controller-manager

This repo is intended to contain common public library code for kube-controller-manager, cloud-controller-manager as well as any other controller managers which people build.
Go
61
star
61

contributor-site

Code for kubernetes.dev
HTML
58
star
62

mount-utils

Package mount defines an interface to mounting filesystems.
Go
50
star
63

legacy-cloud-providers

This repository hosts the legacy in-tree cloud providers. Out-of-tree cloud providers can consume packages in this repo to support legacy implementations of their Kubernetes cloud provider.
Go
49
star
64

cluster-bootstrap

Go
32
star
65

system-validators

A set of system-oriented validators for kubeadm preflight checks.
Go
32
star
66

dynamic-resource-allocation

Go
20
star
67

kms

Kubernetes KMS implementation
Go
18
star
68

cloud-provider-sample

Sample of how to build a cloud provider repo. This will build a Kubernetes image which deploys on bare metal. It uses the fake cloud provider. It consumes the K8s/K8s build artifact and adds to it the Cloud Controller Manager and CSI Daemon Set.
18
star
69

node-api

Go
15
star
70

component-helpers

High-level helpers for Kubernetes components
Go
14
star
71

cel-admission-webhook

Go
12
star
72

csi-translation-lib

Staging repo for CSI Migration/Translation libraries
Go
12
star
73

endpointslice

Go
7
star
74

sig-testing

Home for SIG Testing discussion and documents.
5
star
75

.github

Default files for all repos in the Kubernetes GitHub org
2
star