Search code examples
c#dockerkubernetes

How to get access to kubernetes cluster from containerized application running inside node hosted on same cluster?


I am using kubernetes client library for c#. This method should ideally provide me with k8s config of the cluster it is running inside

var k8sConfig = KubernetesClientConfiguration.InClusterConfig();

Inside docker container when this run it gives

k8s.Autorest.HttpOperationException: Operation returned an invalid status code 'Forbidden'

Expected behaviour is to get cluster inside application so as to use its configmaps and secrets. Is there any other method to do this or are there any pre-requisites to use this method?

Please note: I am using token login from web UI for cluster dashboard


Solution

  • https://github.com/kubernetes-client/csharp/discussions/891

    I asked over github too, which was answered by moderators. And this is what we need to do here. Keep "clusterrolbinding" concept in mind.