skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. If you really want to use the configmap values you can mount it to your pod as shown here.(same for secret)
    https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/
    Then these would be available to your pod as env variables.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search