<p>I've a huge pipeline with different developer groups with several permission levels.(<strong>For using Jenkins Kubernetes Plugin .</strong>) </p>

<p>For example <strong>QA</strong> teams and <strong>Developer</strong> teams has different service accounts at kubernetes cluster. </p>

<p>So I need create some connection with kubernetes clusters but every connection I change context of cluster with namespace name . </p>

<p>I want to use multiple namespaces at kubernetes context . 
That is my own kubernetes context file . </p>

<pre><code>- context:
cluster: minikube
namespace: user3
user: minikube
</code></pre>

<p>How I can handle this problem with kubernetes api call or in yaml files ? 
That is my example service account yaml file . </p>

<pre><code> apiVersion: v1
 kind: ServiceAccount
 metadata:
  name: dev
</code></pre>

<hr>

<pre><code> kind: Role
 apiVersion: rbac.authorization.k8s.io/v1beta1
 metadata:
   name: dev

 rules:
  - apiGroups: [""]
  resources: ["pods"]
 verbs: ["create","delete","get","list","patch","update","watch"]
 - apiGroups: [""]
 resources: ["pods/exec"]
   verbs: ["create","delete","get","list","patch","update","watch"]
 - apiGroups: [""]
  resources: ["pods/log"]
 verbs: ["get","list","watch"]
 - apiGroups: [""]
 resources: ["secrets"]
 verbs: ["get"]
</code></pre>

<hr>

<pre><code> apiVersion: rbac.authorization.k8s.io/v1beta1
 kind: RoleBinding
 metadata:
 name: dev

  roleRef:
  apiGroup: rbac.authorization.k8s.io
   kind: Role
  name: dev
subjects:
  - kind: ServiceAccount
    name: dev
</code></pre>

ColossusMark1
<p>If you want one jenkins to talk to kubernetes API with different service accounts you need to create multiple Jenkins "clouds" in configuration, each with different credentials. Then in your pipeline you set the "cloud" option to choose the right one</p>
