mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-13 05:41:35 +00:00
This change makes us use the generic workqueue throughout the project in order to improve type safety and readability of the code. Kubernetes-commit: 6d0ac8c561a7ac66c21e4ee7bd1976c2ecedbf32
client-go Examples
This directory contains examples that cover various use cases and functionality for client-go.
Auth plugins
Client configuration is typically loaded from kubeconfig files containing server and credential configuration. Several plugins for obtaining credentials from external sources are available, but are not loaded by default. To enable these plugins in your program, import them in your main package.
You can load all auth plugins:
import _ "k8s.io/client-go/plugin/pkg/client/auth"
Or you can load specific auth plugins:
import _ "k8s.io/client-go/plugin/pkg/client/auth/azure"
import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
import _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
Configuration
- Authenticate in cluster: Configure a client while running inside the Kubernetes cluster.
- Authenticate out of cluster: Configure a client to access a Kubernetes cluster from outside.
Basics
- Managing resources with API: Create, get, update, delete a Deployment resource.
Advanced Concepts
- Work queues: Create a hotloop-free controller with the rate-limited workqueue and the informer framework.
- Custom Resource Definition (CRD): Register a custom resource type with the API, create/update/query this custom type, and write a controller that drives the cluster state based on the changes to the custom resources.
- Leader election: Demonstrates the use of the leader election package, which can be used to implement HA controllers.
Testing
- Fake Client: Use a fake client in tests.