Nowadays, I am learning advance golang, along with that knowledge, I am trying to understand kubernetes in more depth. I found client-go as goto thing to explore & learn things. I am also putting respective client-go code links wherever needed.

What’s client-go ?

Simple, golang client library for talking to kubernetes cluster

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 ""
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
config, err := clientcmd.BuildConfigFromFlags("", "")
import ""
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 :)