【问题标题】:Kubernetes configuration: Specify different service accountKubernetes 配置:指定不同的服务帐户
【发布时间】:2021-07-17 17:47:43
【问题描述】:

我开发了一个 .NET API,我想将它部署在 Kubernetes pod 中。 我正在使用 InClusterConfig():

var config = KubernetesClientConfiguration.InClusterConfig();
_client = new Kubernetes(config);

我关注了这个问题 (Accessing kubernetes service from C# docker),并且我了解 InClusterConfig 使用您正在部署 pod 的命名空间的默认服务帐户。

是否可以指定配置来自另一个服务帐户而不是默认帐户? 还有其他方法可以从 Kubernetes pod 中检索配置吗?

【问题讨论】:

  • 我希望它使用 pod 规范中指定的服务帐户,而不一定是命名空间中的 default 服务帐户。

标签: .net kubernetes kubernetes-pod


【解决方案1】:

Pod 将使用 Pod-manifest 中指定的 ServiceAccount,如果未指定,则使用命名空间中的 default ServiceAccount。

您可以使用serviceAccountName:-字段为 Pod 指定 ServiceAccount:

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  serviceAccountName: my-service-account
  ...

另见Configure Service Accounts for Pods

【讨论】:

    猜你喜欢
    • 2015-11-14
    • 2019-11-08
    • 2021-05-02
    • 2020-12-23
    • 2019-03-13
    • 1970-01-01
    • 1970-01-01
    • 2018-07-23
    • 2020-05-20
    相关资源
    最近更新 更多