What is a Kubernetes client-go "clientset"?

Every resource type in Kubernetes (Pods, Deployments, Services and so on) is a member of an API group. These logically "group" the different types. Some examples of groups are

  • core
  • extensions
  • batch
  • apps
  • authentication
  • autoscaling

Groups also contain versions. Versions allow developers to introduce breaking changes to APIs, and manage them as they do. Some examples of versions inside a group

  • core/v1
  • extensions/v1beta
  • apps/v1beta1
  • batch/v1, batch/v2alpha1 (notice the two versions inside the same group)
  • authentication/v1, authentication/v1beta1
  • autoscaling/v1, autoscaling/v2alpha1

So the client documentation is saying that it's creating a different client for every group.


The description given by @Jose Armesto is correct, I would like to support it with a snippet.

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

var kubeconfig string

func init() {
   // kubeconfig file parsing
   flag.StringVar(&kubeconfig, "kubeconfig", "", "path to Kubernetes config file")
   flag.Parse()
}

func main() {
   // create the config object from kubeconfig
   config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)

   // create clientset (set of muliple clients) for each Group (e.g. Core), 
   // the Version (V1) of Group and Kind (e.g. Pods) so GVK.
   clientset, err := kubernetes.NewForConfig(config)

   // executes GET request to K8s API to get pods 'cart' from 'prepayment' namespace
   pod, err := clientset.CoreV1().Pods("prepayment").Get("cart", metav1.GetOptions{})
}

Tags:

Go

Kubernetes