client-go – k8s.io/client-go Index | Examples | Files | Directories

package clientgo

import "k8s.io/client-go"

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

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:

Interacting with API Objects

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

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.

Example (HandlingAPIErrors)

Code:play 

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)

Code:play 

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)

Code:play 

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)

Code:play 

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)

Code:play 

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)

Code:play 

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)

Code:play 

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...")
}

Index

Examples

Source Files

doc.go

Directories

PathSynopsis
applyconfigurationsPackage applyconfigurations provides typesafe go representations of the apply configurations that are used to constructs Server-side Apply requests.
applyconfigurations/admissionregistration
applyconfigurations/admissionregistration/v1
applyconfigurations/admissionregistration/v1alpha1
applyconfigurations/admissionregistration/v1beta1
applyconfigurations/apiserverinternal
applyconfigurations/apiserverinternal/v1alpha1
applyconfigurations/apps
applyconfigurations/apps/v1
applyconfigurations/apps/v1beta1
applyconfigurations/apps/v1beta2
applyconfigurations/autoscaling
applyconfigurations/autoscaling/v1
applyconfigurations/autoscaling/v2
applyconfigurations/autoscaling/v2beta1
applyconfigurations/autoscaling/v2beta2
applyconfigurations/batch
applyconfigurations/batch/v1
applyconfigurations/batch/v1beta1
applyconfigurations/certificates
applyconfigurations/certificates/v1
applyconfigurations/certificates/v1alpha1
applyconfigurations/certificates/v1beta1
applyconfigurations/coordination
applyconfigurations/coordination/v1
applyconfigurations/coordination/v1alpha2
applyconfigurations/coordination/v1beta1
applyconfigurations/core
applyconfigurations/core/v1
applyconfigurations/discovery
applyconfigurations/discovery/v1
applyconfigurations/discovery/v1beta1
applyconfigurations/events
applyconfigurations/events/v1
applyconfigurations/events/v1beta1
applyconfigurations/extensions
applyconfigurations/extensions/v1beta1
applyconfigurations/flowcontrol
applyconfigurations/flowcontrol/v1
applyconfigurations/flowcontrol/v1beta1
applyconfigurations/flowcontrol/v1beta2
applyconfigurations/flowcontrol/v1beta3
applyconfigurations/imagepolicy
applyconfigurations/imagepolicy/v1alpha1
applyconfigurations/internal
applyconfigurations/meta
applyconfigurations/meta/v1
applyconfigurations/networking
applyconfigurations/networking/v1
applyconfigurations/networking/v1beta1
applyconfigurations/node
applyconfigurations/node/v1
applyconfigurations/node/v1alpha1
applyconfigurations/node/v1beta1
applyconfigurations/policy
applyconfigurations/policy/v1
applyconfigurations/policy/v1beta1
applyconfigurations/rbac
applyconfigurations/rbac/v1
applyconfigurations/rbac/v1alpha1
applyconfigurations/rbac/v1beta1
applyconfigurations/resource
applyconfigurations/resource/v1
applyconfigurations/resource/v1alpha3
applyconfigurations/resource/v1beta1
applyconfigurations/resource/v1beta2
applyconfigurations/scheduling
applyconfigurations/scheduling/v1
applyconfigurations/scheduling/v1alpha1
applyconfigurations/scheduling/v1beta1
applyconfigurations/storage
applyconfigurations/storagemigration
applyconfigurations/storagemigration/v1beta1
applyconfigurations/storage/v1
applyconfigurations/storage/v1alpha1
applyconfigurations/storage/v1beta1
discoveryPackage discovery provides ways to discover server-supported API groups, versions and resources.
discovery/cached
discovery/cached/disk
discovery/cached/memory
discovery/fake
dynamic
dynamic/dynamicinformer
dynamic/dynamiclister
dynamic/fake
examples
examples/create-update-delete-deploymentNote: the example only works with the code within the same release/branch.
examples/dynamic-create-update-delete-deploymentNote: the example only works with the code within the same release/branch.
examples/fake-clientPackage fakeclient contains examples on how to use fakeclient in tests.
examples/in-cluster-client-configurationNote: the example only works with the code within the same release/branch.
examples/leader-election
examples/out-of-cluster-client-configurationNote: the example only works with the code within the same release/branch.
examples/workqueue
features
features/testing
gentype
informersPackage informers provides generated informers for Kubernetes APIs.
informers/admissionregistration
informers/admissionregistration/v1
informers/admissionregistration/v1alpha1
informers/admissionregistration/v1beta1
informers/apiserverinternal
informers/apiserverinternal/v1alpha1
informers/apps
informers/apps/v1
informers/apps/v1beta1
informers/apps/v1beta2
informers/autoscaling
informers/autoscaling/v1
informers/autoscaling/v2
informers/autoscaling/v2beta1
informers/autoscaling/v2beta2
informers/batch
informers/batch/v1
informers/batch/v1beta1
informers/certificates
informers/certificates/v1
informers/certificates/v1alpha1
informers/certificates/v1beta1
informers/coordination
informers/coordination/v1
informers/coordination/v1alpha2
informers/coordination/v1beta1
informers/core
informers/core/v1
informers/discovery
informers/discovery/v1
informers/discovery/v1beta1
informers/events
informers/events/v1
informers/events/v1beta1
informers/extensions
informers/extensions/v1beta1
informers/flowcontrol
informers/flowcontrol/v1
informers/flowcontrol/v1beta1
informers/flowcontrol/v1beta2
informers/flowcontrol/v1beta3
informers/internalinterfaces
informers/networking
informers/networking/v1
informers/networking/v1beta1
informers/node
informers/node/v1
informers/node/v1alpha1
informers/node/v1beta1
informers/policy
informers/policy/v1
informers/policy/v1beta1
informers/rbac
informers/rbac/v1
informers/rbac/v1alpha1
informers/rbac/v1beta1
informers/resource
informers/resource/v1
informers/resource/v1alpha3
informers/resource/v1beta1
informers/resource/v1beta2
informers/scheduling
informers/scheduling/v1
informers/scheduling/v1alpha1
informers/scheduling/v1beta1
informers/storage
informers/storagemigration
informers/storagemigration/v1beta1
informers/storage/v1
informers/storage/v1alpha1
informers/storage/v1beta1
kubernetesPackage kubernetes holds packages which implement a clientset for Kubernetes APIs.
kubernetes/fakeThis package has the automatically generated fake clientset.
kubernetes/schemeThis package contains the scheme of the automatically generated clientset.
kubernetes_test
kubernetes/typed
kubernetes/typed/admissionregistration
kubernetes/typed/admissionregistration/v1This package has the automatically generated typed clients.
kubernetes/typed/admissionregistration/v1alpha1This package has the automatically generated typed clients.
kubernetes/typed/admissionregistration/v1alpha1/fakePackage fake has the automatically generated clients.
kubernetes/typed/admissionregistration/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/admissionregistration/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/admissionregistration/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/apiserverinternal
kubernetes/typed/apiserverinternal/v1alpha1This package has the automatically generated typed clients.
kubernetes/typed/apiserverinternal/v1alpha1/fakePackage fake has the automatically generated clients.
kubernetes/typed/apps
kubernetes/typed/apps/v1This package has the automatically generated typed clients.
kubernetes/typed/apps/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/apps/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/apps/v1beta2This package has the automatically generated typed clients.
kubernetes/typed/apps/v1beta2/fakePackage fake has the automatically generated clients.
kubernetes/typed/apps/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/authentication
kubernetes/typed/authentication/v1This package has the automatically generated typed clients.
kubernetes/typed/authentication/v1alpha1This package has the automatically generated typed clients.
kubernetes/typed/authentication/v1alpha1/fakePackage fake has the automatically generated clients.
kubernetes/typed/authentication/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/authentication/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/authentication/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/authorization
kubernetes/typed/authorization/v1This package has the automatically generated typed clients.
kubernetes/typed/authorization/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/authorization/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/authorization/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/autoscaling
kubernetes/typed/autoscaling/v1This package has the automatically generated typed clients.
kubernetes/typed/autoscaling/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/autoscaling/v2This package has the automatically generated typed clients.
kubernetes/typed/autoscaling/v2beta1This package has the automatically generated typed clients.
kubernetes/typed/autoscaling/v2beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/autoscaling/v2beta2This package has the automatically generated typed clients.
kubernetes/typed/autoscaling/v2beta2/fakePackage fake has the automatically generated clients.
kubernetes/typed/autoscaling/v2/fakePackage fake has the automatically generated clients.
kubernetes/typed/batch
kubernetes/typed/batch/v1This package has the automatically generated typed clients.
kubernetes/typed/batch/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/batch/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/batch/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/certificates
kubernetes/typed/certificates/v1This package has the automatically generated typed clients.
kubernetes/typed/certificates/v1alpha1This package has the automatically generated typed clients.
kubernetes/typed/certificates/v1alpha1/fakePackage fake has the automatically generated clients.
kubernetes/typed/certificates/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/certificates/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/certificates/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/coordination
kubernetes/typed/coordination/v1This package has the automatically generated typed clients.
kubernetes/typed/coordination/v1alpha2This package has the automatically generated typed clients.
kubernetes/typed/coordination/v1alpha2/fakePackage fake has the automatically generated clients.
kubernetes/typed/coordination/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/coordination/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/coordination/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/core
kubernetes/typed/core/v1This package has the automatically generated typed clients.
kubernetes/typed/core/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/discovery
kubernetes/typed/discovery/v1This package has the automatically generated typed clients.
kubernetes/typed/discovery/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/discovery/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/discovery/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/events
kubernetes/typed/events/v1This package has the automatically generated typed clients.
kubernetes/typed/events/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/events/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/events/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/extensions
kubernetes/typed/extensions/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/extensions/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/flowcontrol
kubernetes/typed/flowcontrol/v1This package has the automatically generated typed clients.
kubernetes/typed/flowcontrol/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/flowcontrol/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/flowcontrol/v1beta2This package has the automatically generated typed clients.
kubernetes/typed/flowcontrol/v1beta2/fakePackage fake has the automatically generated clients.
kubernetes/typed/flowcontrol/v1beta3This package has the automatically generated typed clients.
kubernetes/typed/flowcontrol/v1beta3/fakePackage fake has the automatically generated clients.
kubernetes/typed/flowcontrol/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/networking
kubernetes/typed/networking/v1This package has the automatically generated typed clients.
kubernetes/typed/networking/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/networking/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/networking/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/node
kubernetes/typed/node/v1This package has the automatically generated typed clients.
kubernetes/typed/node/v1alpha1This package has the automatically generated typed clients.
kubernetes/typed/node/v1alpha1/fakePackage fake has the automatically generated clients.
kubernetes/typed/node/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/node/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/node/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/policy
kubernetes/typed/policy/v1This package has the automatically generated typed clients.
kubernetes/typed/policy/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/policy/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/policy/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/rbac
kubernetes/typed/rbac/v1This package has the automatically generated typed clients.
kubernetes/typed/rbac/v1alpha1This package has the automatically generated typed clients.
kubernetes/typed/rbac/v1alpha1/fakePackage fake has the automatically generated clients.
kubernetes/typed/rbac/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/rbac/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/rbac/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/resource
kubernetes/typed/resource/v1This package has the automatically generated typed clients.
kubernetes/typed/resource/v1alpha3This package has the automatically generated typed clients.
kubernetes/typed/resource/v1alpha3/fakePackage fake has the automatically generated clients.
kubernetes/typed/resource/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/resource/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/resource/v1beta2This package has the automatically generated typed clients.
kubernetes/typed/resource/v1beta2/fakePackage fake has the automatically generated clients.
kubernetes/typed/resource/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/scheduling
kubernetes/typed/scheduling/v1This package has the automatically generated typed clients.
kubernetes/typed/scheduling/v1alpha1This package has the automatically generated typed clients.
kubernetes/typed/scheduling/v1alpha1/fakePackage fake has the automatically generated clients.
kubernetes/typed/scheduling/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/scheduling/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/scheduling/v1/fakePackage fake has the automatically generated clients.
kubernetes/typed/storage
kubernetes/typed/storagemigration
kubernetes/typed/storagemigration/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/storagemigration/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/storage/v1This package has the automatically generated typed clients.
kubernetes/typed/storage/v1alpha1This package has the automatically generated typed clients.
kubernetes/typed/storage/v1alpha1/fakePackage fake has the automatically generated clients.
kubernetes/typed/storage/v1beta1This package has the automatically generated typed clients.
kubernetes/typed/storage/v1beta1/fakePackage fake has the automatically generated clients.
kubernetes/typed/storage/v1/fakePackage fake has the automatically generated clients.
listersPackage listers provides generated listers for Kubernetes APIs.
listers/admissionregistration
listers/admissionregistration/v1
listers/admissionregistration/v1alpha1
listers/admissionregistration/v1beta1
listers/apiserverinternal
listers/apiserverinternal/v1alpha1
listers/apps
listers/apps/v1
listers/apps/v1beta1
listers/apps/v1beta2
listers/autoscaling
listers/autoscaling/v1
listers/autoscaling/v2
listers/autoscaling/v2beta1
listers/autoscaling/v2beta2
listers/batch
listers/batch/v1
listers/batch/v1beta1
listers/certificates
listers/certificates/v1
listers/certificates/v1alpha1
listers/certificates/v1beta1
listers/coordination
listers/coordination/v1
listers/coordination/v1alpha2
listers/coordination/v1beta1
listers/core
listers/core/v1
listers/discovery
listers/discovery/v1
listers/discovery/v1beta1
listers/events
listers/events/v1
listers/events/v1beta1
listers/extensions
listers/extensions/v1beta1
listers/flowcontrol
listers/flowcontrol/v1
listers/flowcontrol/v1beta1
listers/flowcontrol/v1beta2
listers/flowcontrol/v1beta3
listers/imagepolicy
listers/imagepolicy/v1alpha1
listers/networking
listers/networking/v1
listers/networking/v1beta1
listers/node
listers/node/v1
listers/node/v1alpha1
listers/node/v1beta1
listers/policy
listers/policy/v1
listers/policy/v1beta1
listers/rbac
listers/rbac/v1
listers/rbac/v1alpha1
listers/rbac/v1beta1
listers/resource
listers/resource/v1
listers/resource/v1alpha3
listers/resource/v1beta1
listers/resource/v1beta2
listers/scheduling
listers/scheduling/v1
listers/scheduling/v1alpha1
listers/scheduling/v1beta1
listers/storage
listers/storagemigration
listers/storagemigration/v1beta1
listers/storage/v1
listers/storage/v1alpha1
listers/storage/v1beta1
metadata
metadata/fake
metadata/metadatainformer
metadata/metadatalister
openapi
openapi3
openapi/cached
openapi/openapitest
pkg
pkg/apis
pkg/apis/clientauthentication
pkg/apis/clientauthentication/installPackage install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
pkg/apis/clientauthentication/v1
pkg/apis/clientauthentication/v1beta1
pkg/versionPackage version supplies version information collected at build time to kubernetes components.
plugin
plugin/pkg
plugin/pkg/client
plugin/pkg/client/auth
plugin/pkg/client/auth/azure
plugin/pkg/client/auth/exec
plugin/pkg/client/auth/gcp
plugin/pkg/client/auth/oidc
rest
rest/fakeThis is made a separate package and should only be imported by tests, because it imports testapi
restmapper
rest/watch
scalePackage 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.
scale/fakePackage fake provides a fake client interface to arbitrary Kubernetes APIs that exposes common high level operations and exposes common metadata.
scale/schemePackage scheme contains a runtime.Scheme to be used for serializing and deserializing different versions of Scale, and for converting in between them.
scale/scheme/appsintPackage appsint contains the necessary scaffolding of the internal version of extensions as required by conversion logic.
scale/scheme/appsv1beta1
scale/scheme/appsv1beta2
scale/scheme/autoscalingv1
scale/scheme/extensionsintPackage extensionsint contains the necessary scaffolding of the internal version of extensions as required by conversion logic.
scale/scheme/extensionsv1beta1
testing
third_party
third_party/forked
third_party/forked/golang
third_party/forked/golang/templateThis package is copied from Go library text/template.
tools
tools/authPackage auth defines a file format for holding authentication information needed by clients of Kubernetes.
tools/auth/execPackage exec contains helper utilities for exec credential plugins.
tools/cachePackage cache is a client-side caching mechanism.
tools/cache/synctrackPackage 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.
tools/cache/testing
tools/clientcmdPackage 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.
tools/clientcmd/api
tools/clientcmd/api/latest
tools/clientcmd/api/v1
tools/eventsPackage events has all client logic for recording and reporting "k8s.io/api/events/v1".Event events.
tools/internal
tools/leaderelectionPackage leaderelection implements leader election of a set of endpoints.
tools/leaderelection/resourcelock
tools/metricsPackage metrics provides abstractions for registering which metrics to record.
tools/pager
tools/portforwardPackage portforward adds support for SSH-like port forwarding from the client's local host to remote containers.
tools/recordPackage record has all client logic for recording and reporting "k8s.io/api/core/v1".Event events.
tools/record/util
tools/reference
tools/remotecommandPackage remotecommand adds support for executing commands in containers, with support for separate stdin, stdout, and stderr streams, as well as TTY.
tools/watch
transport
transport/spdy
transport/websocket
util
util/apply
util/cert
util/certificate
util/certificate/csr
util/connrotationPackage connrotation implements a connection dialer that tracks and can close all created connections.
util/consistencydetector
util/csaupgrade
util/exec
util/flowcontrol
util/homedir
util/jsonpathpackage jsonpath is a template engine using jsonpath syntax, which can be seen at http://goessner.net/articles/JsonPath/.
util/keyutilPackage keyutil contains utilities for managing public/private key pairs.
util/retry
util/testing
util/watchlist
util/workqueuePackage workqueue provides a simple queue that supports the following features:
Version
v0.35.4
Published
Apr 15, 2026
Platform
linux/amd64
Last checked
23 minutes ago

Tools for package owners.