client-go/examples
astraw99 a9a86ad864 unify worker num to workers
Kubernetes-commit: e6df935fd30c56a8ece0da6152c60fc725d942b7
2021-08-09 10:48:53 +08:00
..
create-update-delete-deployment automated refactor 2020-03-01 09:24:42 -08:00
dynamic-create-update-delete-deployment client-go dynamic context 2020-03-06 01:27:11 -05:00
fake-client fix the fake client example: how to handle a race between the fake client and informer 2020-10-26 22:50:32 -07:00
in-cluster-client-configuration Revert "Merge pull request #982 from sprutner/patch-1" 2021-06-22 13:41:22 +05:30
leader-election switch over k/k to use klog v2 2020-04-17 15:25:06 -04:00
out-of-cluster-client-configuration Update client-go out of cluster example 2020-08-12 17:55:26 -06:00
workqueue unify worker num to workers 2021-08-09 10:48:53 +08:00
README.md Update client-go example README.md (fix typo) 2019-05-09 19:30:43 +05:30

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"
import _ "k8s.io/client-go/plugin/pkg/client/auth/openstack"

Configuration

Basics

Advanced Concepts

  • Work queues: Create a hotloop-free controller with the rate-limited workqueue and the informer framework.
  • Custom Resource Definition (successor of TPR): 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