Rainbond/vendor/k8s.io/client-go/examples
2019-11-25 16:14:32 +08:00
..
create-update-delete-deployment upgrade client-go to 1.16.3 2019-11-25 16:14:32 +08:00
dynamic-create-update-delete-deployment upgrade client-go to 1.16.3 2019-11-25 16:14:32 +08:00
fake-client upgrade client-go to 1.16.3 2019-11-25 16:14:32 +08:00
in-cluster-client-configuration upgrade client-go to 1.16.3 2019-11-25 16:14:32 +08:00
leader-election upgrade client-go to 1.16.3 2019-11-25 16:14:32 +08:00
out-of-cluster-client-configuration upgrade client-go to 1.16.3 2019-11-25 16:14:32 +08:00
workqueue upgrade client-go to 1.16.3 2019-11-25 16:14:32 +08:00
README.md upgrade client-go to 1.16.3 2019-11-25 16:14:32 +08:00

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