简体   繁体   中英

Kubernetes configuration: Specify different service account

I develop a .NET API and I want to deploy it in a Kubernetes pod. I'm using InClusterConfig():

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

I follow this issue ( Accessing kubernetes service from C# docker ) and I understand that InClusterConfig uses the default service account of the namespace where you are deploying the pod.

Is it possible to specify that the configuration is taken from another service account than default? Are there other methods to retrieve configuration from a Kubernetes pod?

The Pod will use the ServiceAccount specified in the Pod-manifest, if not specified the default ServiceAccount in the namespace will be used.

You can specify the ServiceAccount for a Pod with the serviceAccountName: -field:

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

Also see Configure Service Accounts for Pods

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM