简体   繁体   English

如何从运行在同一集群上的节点内的容器化应用程序访问 Kubernetes 集群?

[英]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.

相关问题 如何使用集群内反向代理自动确定在Kubernetes中运行的ASP.NET Core应用程序的KnownNetworks? - How to automatically determine KnownNetworks for ASP.NET Core application running in Kubernetes with an in-cluster reverse proxy? 如何升级在 Windows 故障转移群集上运行的通用应用程序 - How to upgrade a generic application running on a windows failover cluster 在 C# 应用程序中获取集群 azure kubernetes 服务 (AKS) 运行状况/可用性 - Get cluster azure kubernetes service (AKS) health/availability in C# application 当计算节点上的运行作业失败时,如何使计算节点在Microsoft HPC群集中脱机? - How to make a computational node offline in Microsoft HPC cluster when the running job on the computational node fails? 如何确定故障转移群集中的活动节点 - How to determine the active node in a failover cluster 如何在部署在不同群集节点上的两个相同参与者之间保持状态? (akka.net) - How do I persist states between two same actors deployed on different cluster node? (akka.net) 如何从客户端应用程序访问Windows服务上托管的Web服务? - How to access a Web Service hosted on a Windows Service from a client application? 在 Visual Studio 中为 5 节点群集调试 Azure Service Fabric 应用程序 - Debugging Azure Service Fabric Application in Visual Studio for 5 node cluster 从Windows服务和控制台应用程序访问相同的运行代码? - Access the same running code from a Windows Service and a console application? Ignite 集群在 Kube.netes 中运行,但应用程序在它之外 - Ignite cluster runs within Kubernetes, but applications are outside of it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM