<p>I'm trying to access the current-context of the current cluster, currently I'm getting rest.Config using:</p>
<pre><code>config, err := rest.InClusterConfig()
if err != nil {
    panic(err.Error())
}
</code></pre>
<p>How can I extract the CurrentContext from that config?</p>

Sara Taha
<p>Context applies only to the Kubernetes client-side, that is, to the place from where you run the kubectl command. Pods running in a Kubernetes cluster have no concept of context.</p>
<p>On your local machine, the context is set in the .kubeconfig file. In the cluster, you need to read from InClusterConfig, and provide all the required details, which would otherwise have been saved in your local context.</p>
<p>Example code for getting a Kubernetes clientSet inside cluster:</p>
<pre><code>func GetK8sClient() *kubernetes.Clientset {
    config, err := rest.InClusterConfig()
    if err != nil {
        panic(err.Error())
    }
    // creates the clientset
    clientset, err := kubernetes.NewForConfig(config)
    if err != nil {
        panic(err.Error())
    }

    return clientset
}
</code></pre>
