[英]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#.我正在为 c# 使用 kubernetes 客户端库。 This method should ideally provide me with k8s config of the cluster it is running inside
理想情况下,此方法应该为我提供它在其中运行的集群的 k8s 配置
var k8sConfig = KubernetesClientConfiguration.InClusterConfig();
Inside docker container when this run it gives在 docker 容器内运行时它给出
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请注意:我在集群仪表板中使用 Web UI 的令牌登录
如果你真的想使用 configmap 值,你可以将它挂载到你的 pod 中,如下所示。(秘密相同) https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/然后这些将作为环境变量提供给您的 pod。
https://github.com/kubernetes-client/csharp/discussions/891 https://github.com/kubernetes-client/csharp/discussions/891
I asked over github too, which was answered by moderators.我也在github上问过,版主都回答了。 And this is what we need to do here.
这就是我们需要在这里做的。 Keep "clusterrolbinding" concept in mind.
牢记“集群绑定”概念。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.