What’s client-go ?

Where’s client-go ?

In this Adventure, very first step is to see how to connect to API Server :)

Connecting to cluster using client-go

import "k8s.io/client-go/tools/clientcmd"
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
config, err := clientcmd.BuildConfigFromFlags("", "")
import "k8s.io/client-go/rest"
...
config,err := rest.InClusterConfig()

This method basically gets KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT environment variables (which are injected into every pod) and service token to generate the config.

it has fields like Host, APIPath, Username, Password, BearerToken, etc which are needed to talk to cluster

TGIF, Enough for Today :) Happy Weekend :) Stay Tuned :)