clientgo

package module
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 0 Imported by: 4

README

⚠️ This is an automatically published staged repository for Kubernetes.
Contributions, including issues and pull requests, should be made to the main Kubernetes repository: https://github.com/kubernetes/kubernetes.
This repository is read-only for importing, and not used for direct contributions.
See CONTRIBUTING.md for more details.

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.29 Kubernetes 1.30 Kubernetes 1.31 Kubernetes 1.32 Kubernetes 1.33 Kubernetes 1.34
kubernetes-1.29.0/v0.29.0 +- +- +- +- +-
kubernetes-1.30.0/v0.30.0 +- +- +- +- +-
kubernetes-1.31.0/v0.31.0 +- +- +- +- +-
kubernetes-1.32.0/v0.32.0 +- +- +- +- +-
kubernetes-1.33.0/v0.33.0 +- +- +- +- +-
kubernetes-1.34.0/v0.34.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.25 Kubernetes main repo, 1.25 branch =-
release-1.26 Kubernetes main repo, 1.26 branch =-
release-1.27 Kubernetes main repo, 1.27 branch =-
release-1.28 Kubernetes main repo, 1.28 branch =-
release-1.29 Kubernetes main repo, 1.29 branch =-
release-1.30 Kubernetes main repo, 1.30 branch =-
release-1.31 Kubernetes main repo, 1.31 branch =
release-1.32 Kubernetes main repo, 1.32 branch
release-1.33 Kubernetes main repo, 1.33 branch
release-1.34 Kubernetes main repo, 1.34 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.

Documentation

Overview

Package clientgo is the official Go client for the Kubernetes API. It provides a standard set of clients and tools for building applications, controllers, and operators that communicate with a Kubernetes cluster.

Key Packages

  • kubernetes: Contains the typed Clientset for interacting with built-in, versioned API objects (e.g., Pods, Deployments). This is the most common starting point.

  • dynamic: Provides a dynamic client that can perform operations on any Kubernetes object, including Custom Resources (CRs). It is essential for building controllers that work with CRDs.

  • discovery: Used to discover the API groups, versions, and resources supported by a Kubernetes cluster.

  • tools/cache: The foundation of the controller pattern. This package provides efficient caching and synchronization mechanisms (Informers and Listers) for building controllers.

  • tools/clientcmd: Provides methods for loading client configuration from kubeconfig files. This is essential for out-of-cluster applications and CLI tools.

  • rest: Provides a lower-level RESTClient that manages the details of communicating with the Kubernetes API server. It is useful for advanced use cases that require fine-grained control over requests, such as working with non-standard REST verbs.

Connecting to the API

There are two primary ways to configure a client to connect to the API server:

  1. In-Cluster Configuration: For applications running inside a Kubernetes pod, the `rest.InClusterConfig()` function provides a straightforward way to configure the client. It automatically uses the pod's service account for authentication and is the recommended approach for controllers and operators.

  2. Out-of-Cluster Configuration: For local development or command-line tools, the `clientcmd` package is used to load configuration from a kubeconfig file.

The `rest.Config` object allows for fine-grained control over client-side performance and reliability. Key settings include:

  • QPS: The maximum number of queries per second to the API server.
  • Burst: The maximum number of queries that can be issued in a single burst.
  • Timeout: The timeout for individual requests.

Interacting with API Objects

Once configured, a client can be used to interact with objects in the cluster.

  • The Typed Clientset (`kubernetes` package) provides a strongly typed interface for working with built-in Kubernetes objects.

  • The Dynamic Client (`dynamic` package) can work with any object, including Custom Resources, using `unstructured.Unstructured` types.

  • For Custom Resources (CRDs), the `k8s.io/code-generator` repository contains the tools to generate typed clients, informers, and listers. The `sample-controller` is the canonical example of this pattern.

  • Server-Side Apply is a patching strategy that allows multiple actors to share management of an object by tracking field ownership. This prevents actors from inadvertently overwriting each other's changes and provides a mechanism for resolving conflicts. The `applyconfigurations` package provides the necessary tools for this declarative approach.

Handling API Errors

Robust error handling is essential when interacting with the API. The `k8s.io/apimachinery/pkg/api/errors` package provides functions to inspect errors and check for common conditions, such as whether a resource was not found or already exists. This allows controllers to implement robust, idempotent reconciliation logic.

Building Controllers

The controller pattern is central to Kubernetes. A controller observes the state of the cluster and works to bring it to the desired state.

  • The `tools/cache` package provides the building blocks for this pattern. Informers watch the API server and maintain a local cache, Listers provide read-only access to the cache, and Workqueues decouple event detection from processing.

  • In a high-availability deployment where multiple instances of a controller are running, leader election (`tools/leaderelection`) is used to ensure that only one instance is active at a time.

  • Client-side feature gates allow for enabling or disabling experimental features in `client-go`. They can be configured via the `rest.Config` object.

Example (HandlingAPIErrors)
package main

import (
	"fmt"

	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/runtime/schema"
)

func main() {
	// This example demonstrates how to handle common API errors.
	// Create a NotFound error to simulate a failed API request.
	err := errors.NewNotFound(schema.GroupResource{Group: "v1", Resource: "pods"}, "my-pod")

	// The errors.IsNotFound() function checks if an error is a NotFound error.
	if errors.IsNotFound(err) {
		fmt.Println("Pod not found")
	}

	// The errors package provides functions for other common API errors, such as:
	// - errors.IsAlreadyExists(err)
	// - errors.IsConflict(err)
	// - errors.IsServerTimeout(err)

}
Output:
Pod not found
Example (InClusterConfiguration)
package main

import (
	"context"
	"fmt"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/rest"
)

func main() {
	// This example demonstrates how to create a clientset for an application
	// running inside a Kubernetes cluster. It uses the pod's service account
	// for authentication.

	// rest.InClusterConfig() returns a configuration object that can be used to
	// create a clientset. It is the recommended way to configure a client for
	// in-cluster applications.
	config, err := rest.InClusterConfig()
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// Create the clientset.
	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// Use the clientset to interact with the API.

	pods, err := clientset.CoreV1().Pods("default").List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	fmt.Printf("There are %d pods in the default namespace\n", len(pods.Items))
}
Example (LeaderElection)
package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"os/signal"
	"path/filepath"
	"syscall"
	"time"

	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/clientcmd"
	"k8s.io/client-go/tools/leaderelection"
	"k8s.io/client-go/tools/leaderelection/resourcelock"
)

func main() {
	// This example demonstrates the leader election pattern. A controller running
	// multiple replicas uses leader election to ensure that only one replica is
	// active at a time.

	// Configure the client (out-of-cluster for this example).
	var kubeconfig string
	if home := os.Getenv("HOME"); home != "" {
		kubeconfig = filepath.Join(home, ".kube", "config")
	}
	config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
	if err != nil {
		fmt.Printf("Error building kubeconfig: %s\n", err.Error())
		return
	}
	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		fmt.Printf("Error building clientset: %s\n", err.Error())
		return
	}

	// The unique name of the controller writing to the Lease object.
	id := "my-controller"

	// The namespace and name of the Lease object.
	leaseNamespace := "default"
	leaseName := "my-controller-lease"

	// Create a context that can be cancelled to stop the leader election.
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	// Set up a signal handler to cancel the context on termination.
	sigCh := make(chan os.Signal, 1)
	signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
	go func() {
		<-sigCh
		log.Println("Received termination signal, shutting down...")
		cancel()
	}()

	// Create the lock object.
	lock, err := resourcelock.New(resourcelock.LeasesResourceLock,
		leaseNamespace,
		leaseName,
		clientset.CoreV1(),
		clientset.CoordinationV1(),
		resourcelock.ResourceLockConfig{
			Identity: id,
		})
	if err != nil {
		fmt.Printf("Error creating lock: %v\n", err)
		return
	}

	// Create the leader elector.
	elector, err := leaderelection.NewLeaderElector(leaderelection.LeaderElectionConfig{
		Lock:          lock,
		LeaseDuration: 15 * time.Second,
		RenewDeadline: 10 * time.Second,
		RetryPeriod:   2 * time.Second,
		Callbacks: leaderelection.LeaderCallbacks{
			OnStartedLeading: func(ctx context.Context) {
				// This function is called when the controller becomes the leader.
				// You would start your controller's main logic here.
				log.Println("Became leader, starting controller.")
				// This is a simple placeholder for the controller's work.
				for {
					select {
					case <-time.After(5 * time.Second):
						log.Println("Doing controller work...")
					case <-ctx.Done():
						log.Println("Controller stopped.")
						return
					}
				}
			},
			OnStoppedLeading: func() {
				// This function is called when the controller loses leadership.
				// You should stop any active work and gracefully shut down.
				log.Printf("Lost leadership, shutting down.")
			},
			OnNewLeader: func(identity string) {
				// This function is called when a new leader is elected.
				if identity != id {
					log.Printf("New leader elected: %s", identity)
				}
			},
		},
	})
	if err != nil {
		fmt.Printf("Error creating leader elector: %v\n", err)
		return
	}

	// Start the leader election loop.
	elector.Run(ctx)
}
Example (OutOfClusterConfiguration)
package main

import (
	"context"
	"fmt"
	"os"
	"path/filepath"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/clientcmd"
)

func main() {
	// This example demonstrates how to create a clientset for an application
	// running outside of a Kubernetes cluster, using a kubeconfig file. This is
	// the standard approach for local development and command-line tools.

	// The default location for the kubeconfig file is in the user's home directory.
	var kubeconfig string
	if home := os.Getenv("HOME"); home != "" {
		kubeconfig = filepath.Join(home, ".kube", "config")
	}

	// Create the client configuration from the kubeconfig file.
	config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// Configure client-side rate limiting.
	config.QPS = 50
	config.Burst = 100

	// A clientset contains clients for all the API groups and versions supported
	// by the cluster.
	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// Use the clientset to interact with the API.

	pods, err := clientset.CoreV1().Pods("default").List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	fmt.Printf("There are %d pods in the default namespace\n", len(pods.Items))
}
Example (ServerSideApply)
package main

import (
	"context"
	"fmt"
	"os"
	"path/filepath"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

	appsv1ac "k8s.io/client-go/applyconfigurations/apps/v1"

	corev1ac "k8s.io/client-go/applyconfigurations/core/v1"

	metav1ac "k8s.io/client-go/applyconfigurations/meta/v1"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/clientcmd"
)

func main() {
	// This example demonstrates how to use Server-Side Apply to declaratively
	// manage a Deployment object. Server-Side Apply is the recommended approach
	// for controllers and operators to manage objects.

	// Configure the client (out-of-cluster for this example).
	var kubeconfig string
	if home := os.Getenv("HOME"); home != "" {
		kubeconfig = filepath.Join(home, ".kube", "config")
	}
	config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}
	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// Define the desired state of the Deployment using the applyconfigurations package.
	// This provides a typed, structured way to build the patch.
	deploymentName := "my-app"
	replicas := int32(2)
	image := "nginx:1.14.2"

	// The FieldManager is a required field that identifies the controller managing
	// this object's state.
	fieldManager := "my-controller"

	// Build the apply configuration.
	deploymentApplyConfig := appsv1ac.Deployment(deploymentName, "default").
		WithSpec(appsv1ac.DeploymentSpec().
			WithReplicas(replicas).
			WithSelector(metav1ac.LabelSelector().WithMatchLabels(map[string]string{"app": "my-app"})).
			WithTemplate(corev1ac.PodTemplateSpec().
				WithLabels(map[string]string{"app": "my-app"}).
				WithSpec(corev1ac.PodSpec().
					WithContainers(corev1ac.Container().
						WithName("nginx").
						WithImage(image),
					),
				),
			),
		)

	// Perform the Server-Side Apply patch. The PatchType must be types.ApplyPatchType.
	// The context, name, apply configuration, and patch options are required.
	result, err := clientset.AppsV1().Deployments("default").Apply(
		context.TODO(),
		deploymentApplyConfig,
		metav1.ApplyOptions{FieldManager: fieldManager},
	)

	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	fmt.Printf("Deployment %q applied successfully.\n", result.Name)
}
Example (UsingDynamicClient)
package main

import (
	"context"
	"fmt"
	"os"
	"path/filepath"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"k8s.io/client-go/dynamic"
	"k8s.io/client-go/tools/clientcmd"
)

func main() {
	// This example demonstrates how to create and use a dynamic client to work
	// with Custom Resources or other objects without needing their Go type
	// definitions.

	// Configure the client (out-of-cluster for this example).
	var kubeconfig string
	if home := os.Getenv("HOME"); home != "" {
		kubeconfig = filepath.Join(home, ".kube", "config")
	}
	config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// Create a dynamic client.
	dynamicClient, err := dynamic.NewForConfig(config)
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// Define the GroupVersionResource for the object you want to access.
	// For Pods, this is {Group: "", Version: "v1", Resource: "pods"}.
	gvr := schema.GroupVersionResource{Version: "v1", Resource: "pods"}

	// Use the dynamic client to list all pods in the "default" namespace.
	// The result is an UnstructuredList.
	list, err := dynamicClient.Resource(gvr).Namespace("default").List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// Iterate over the list and print the name of each pod.
	for _, item := range list.Items {
		name, found, err := unstructured.NestedString(item.Object, "metadata", "name")
		if err != nil || !found {
			fmt.Printf("Could not find name for pod: %v\n", err)
			continue
		}
		fmt.Printf("Pod Name: %s\n", name)
	}
}
Example (UsingInformers)
package main

import (
	"fmt"
	"log"
	"os"
	"os/signal"
	"path/filepath"
	"syscall"
	"time"

	"k8s.io/client-go/informers"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/cache"
	"k8s.io/client-go/tools/clientcmd"
)

func main() {
	// This example demonstrates the basic pattern for using an informer to watch
	// for changes to Pods. This is a conceptual example; a real controller would
	// have more robust logic and a workqueue.

	// Configure the client (out-of-cluster for this example).
	var kubeconfig string
	if home := os.Getenv("HOME"); home != "" {
		kubeconfig = filepath.Join(home, ".kube", "config")
	}
	config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}
	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// A SharedInformerFactory provides a shared cache for multiple informers,
	// which reduces memory and network overhead.
	factory := informers.NewSharedInformerFactory(clientset, 10*time.Minute)
	podInformer := factory.Core().V1().Pods().Informer()

	_, err = podInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: func(obj interface{}) {
			key, err := cache.MetaNamespaceKeyFunc(obj)
			if err == nil {
				log.Printf("Pod ADDED: %s", key)
			}
		},
		UpdateFunc: func(oldObj, newObj interface{}) {
			key, err := cache.MetaNamespaceKeyFunc(newObj)
			if err == nil {
				log.Printf("Pod UPDATED: %s", key)
			}
		},
		DeleteFunc: func(obj interface{}) {
			key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
			if err == nil {
				log.Printf("Pod DELETED: %s", key)
			}
		},
	})
	if err != nil {
		fmt.Printf("Error encountered: %v\n", err)
		return
	}

	// Graceful shutdown requires a two-channel pattern.
	//
	// The first channel, `sigCh`, is used by the `signal` package to send us
	// OS signals (e.g., Ctrl+C). This channel must be of type `chan os.Signal`.
	//
	// The second channel, `stopCh`, is used to tell the informer factory to
	// stop. The informer factory's `Start` method expects a channel of type
	// `<-chan struct{}`. It will stop when this channel is closed.
	//
	// The goroutine below is the "translator" that connects these two channels.
	// It waits for a signal on `sigCh`, and when it receives one, it closes
	// `stopCh`, which in turn tells the informer factory to shut down.
	sigCh := make(chan os.Signal, 1)
	signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
	stopCh := make(chan struct{})
	go func() {
		<-sigCh
		close(stopCh)
	}()

	// Start the informer.
	factory.Start(stopCh)

	// Wait for the initial cache sync.
	if !cache.WaitForCacheSync(stopCh, podInformer.HasSynced) {
		log.Println("Timed out waiting for caches to sync")
		return
	}

	log.Println("Informer has synced. Watching for Pod events...")

	// Wait for the stop signal.
	<-stopCh
	log.Println("Shutting down...")
}

Directories

Path Synopsis
Package applyconfigurations provides typesafe go representations of the apply configurations that are used to constructs Server-side Apply requests.
Package applyconfigurations provides typesafe go representations of the apply configurations that are used to constructs Server-side Apply requests.
Package discovery provides ways to discover server-supported API groups, versions and resources.
Package discovery provides ways to discover server-supported API groups, versions and resources.
examples
create-update-delete-deployment command
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.
dynamic-create-update-delete-deployment command
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.
fake-client
Package fakeclient contains examples on how to use fakeclient in tests.
Package fakeclient contains examples on how to use fakeclient in tests.
in-cluster-client-configuration command
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.
leader-election command
out-of-cluster-client-configuration command
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.
workqueue command
Package informers provides generated informers for Kubernetes APIs.
Package informers provides generated informers for Kubernetes APIs.
Package kubernetes holds packages which implement a clientset for Kubernetes APIs.
Package kubernetes holds packages which implement a clientset for Kubernetes APIs.
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/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/admissionregistration/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
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/apiserverinternal/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/apiserverinternal/v1alpha1/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/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/authentication/v1alpha1/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/v2
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/autoscaling/v2/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/certificates/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/certificates/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/certificates/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/certificates/v1alpha1/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/coordination/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/coordination/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/coordination/v1alpha2
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/coordination/v1alpha2/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/coordination/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/coordination/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/discovery/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/discovery/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/discovery/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/discovery/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/events/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/events/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/flowcontrol/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/flowcontrol/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/flowcontrol/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/flowcontrol/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/flowcontrol/v1beta2
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/flowcontrol/v1beta2/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/flowcontrol/v1beta3
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/flowcontrol/v1beta3/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/networking/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/networking/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/node/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/node/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/node/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/node/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/node/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/node/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/policy/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/policy/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/resource/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/resource/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/resource/v1alpha3
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/resource/v1alpha3/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/resource/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/resource/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/resource/v1beta2
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/resource/v1beta2/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/scheduling/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/scheduling/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
typed/scheduling/v1alpha2
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/scheduling/v1alpha2/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/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.
typed/storagemigration/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
typed/storagemigration/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
Package listers provides generated listers for Kubernetes APIs.
Package listers provides generated listers for Kubernetes APIs.
pkg
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.
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.
Package testing provides a fake Kubernetes client suitable for use in unit tests.
Package testing provides a fake Kubernetes client suitable for use in unit tests.
third_party
forked/golang/template
This package is copied from Go library text/template.
This package is copied from Go library text/template.
forked/httpcache
Package httpcache provides a http.RoundTripper implementation that works as a mostly RFC-compliant cache for http responses.
Package httpcache provides a http.RoundTripper implementation that works as a mostly RFC-compliant cache for http responses.
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.
auth/exec
Package exec contains helper utilities for exec credential plugins.
Package exec contains helper utilities for exec credential plugins.
cache
Package cache is a client-side caching mechanism.
Package cache is a client-side caching mechanism.
cache/synctrack
Package synctrack contains utilities for helping controllers track whether they are "synced" or not, that is, whether they have processed all items from the informer's initial list.
Package synctrack contains utilities for helping controllers track whether they are "synced" or not, that is, whether they have processed all items from the informer's initial list.
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.
events
Package events has all client logic for recording and reporting "k8s.io/api/events/v1".Event events.
Package events has all client logic for recording and reporting "k8s.io/api/events/v1".Event events.
internal/events
Package internal is needed to break an import cycle: record.EventRecorderAdapter needs this interface definition to implement it, but event.NewEventBroadcasterAdapter needs record.NewBroadcaster.
Package internal is needed to break an import cycle: record.EventRecorderAdapter needs this interface definition to implement it, but event.NewEventBroadcasterAdapter needs record.NewBroadcaster.
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 "k8s.io/api/core/v1".Event events.
Package record has all client logic for recording and reporting "k8s.io/api/core/v1".Event 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
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/.
keyutil
Package keyutil contains utilities for managing public/private key pairs.
Package keyutil contains utilities for managing public/private key pairs.
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