title: Kubernetes plugin with Jenkins fails
body: <p>I am trying to add Kubernetes as cloud to Jenkins server with the appropriate Kubernetes URL and other details. When i add the details and test the connection
  i get the following error</p>
  <blockquote>
  <p>Error connecting to <a href="https://192.168.X.XX:6443" rel="nofollow noreferrer">https://192.168.X.XX:6443</a>: Failure executing: GET at: <a href="https://192.168.X.XX:6443/api/v1/namespaces/default/pods" rel="nofollow noreferrer">https://192.168.X.XX:6443/api/v1/namespaces/default/pods</a>. Message: User &quot;system:anonymous&quot; cannot list pods in the namespace &quot;default&quot;..&quot;</p>
  </blockquote>
  <p>I tried to perform curl with --insecure option but the same following error is logged.</p>
  <blockquote>
  <p>Message: User &quot;system:anonymous&quot; cannot list pods in the namespace &quot;default&quot;..&quot;</p>
  </blockquote>
  <p>I tried to add jenkins and the user credentials to login to jenkins as clusteradminrole using the following kubectl command</p>
  <blockquote>
  <p>kubectl create rolebinding jenkins-admin-binding --clusterrole=admin --user=jenkins--namespace=default</p>
  </blockquote>
  <p>But still the same error.</p>
  <p>Anything is missing?</p>
  <p>EDIT 1: Have tried to do the following as suggested</p>
  <blockquote>
  <p>openssl genrsa -out jenkins.key 2048</p>
  <p>openssl req -new -key  jenkins.key -out jenkins.csr -subj &quot;/CN=jenkins/O=admin_jenkins&quot;</p>
  <p>openssl x509 -req -in jenkins.csr -CA /etc/kubernetes/pki/ca.crt -CAkey /etc/kubernetes/pki/ca.key -CAcreateserial -out jenkins.crt -days 500</p>
  <p>kubectl config set-credentials jenkins --client-certificate=/root/pods/admin_jenkins/.certs/jenkins.crt --client-key=/root/pods/admin_jenkins/.certs/jenkins.key</p>
  <p>kubectl config set-context jenkins-context --cluster=kubernetes --namespace=default --user=jenkins</p>
  <p>kubectl create -f role.yaml (Role file as described)</p>
  <p>kubectl create -f role-binding.yaml</p>
  </blockquote>
  <p>even after this</p>
  <pre><code>kubectl --context=jenkins-context get deployments 
  gives the following error
  &quot;Error from server (Forbidden): User &quot;jenkins&quot; cannot list deployments.extensions in the namespace &quot;default&quot;. (get deployments.extensions)&quot;
  </code></pre>
  <p>Update 2:</p>
  <pre><code>after following above steps 
  &quot;kubectl --context=jenkins-context get deployments&quot; was successful.
  
   i did the whole exercise after doing a kubeadm reset and it worked
  </code></pre>
  <p>But the problem still remains of integrating K8 with Jenkins when i am trying to add it as a cloud using its plugin.</p>