<p>I'm trying to connect Jenkins to a fresh K8S cluster via (Kubernetes plugin), however, I'm seeing the following error when I attempt to test. </p>

<p><a href="https://i.stack.imgur.com/gIukW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gIukW.png" alt="enter image description here"></a></p>

<p>Then I have tried to add a secret file to Jenkins credentials of my <code>~/.kube/config</code> I'm seeing this error. </p>

<p><a href="https://i.stack.imgur.com/oa5Mz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oa5Mz.png" alt="enter image description here"></a></p>

<p><code>k8s version is 1.15.4 and Jenkins 2.190.1</code></p>

<p>Any ideas?</p>

Deano
<p>You need to use "Secret text" type of credentials with service account token. Create service account as <a href="https://stackoverflow.com/users/6713869/rodrigo-loza">Rodrigo Loza</a> mentioned. Example creates namespace jenkins and service account with admin rights in it:</p>

<pre><code>kubectl create namespace jenkins &amp;&amp; kubectl create serviceaccount jenkins --namespace=jenkins &amp;&amp; kubectl describe secret $(kubectl describe serviceaccount jenkins --namespace=jenkins | grep Token | awk '{print $2}') --namespace=jenkins &amp;&amp; kubectl create rolebinding jenkins-admin-binding --clusterrole=admin --serviceaccount=jenkins:jenkins --namespace=jenkins
</code></pre>
