Jenkins Kubernetes Serviceaccount Cannot list Pods

10/2/2017

After creating a Service Account for Jenkins with the commands:

kubectl -n jenkins create sa jenkins

kubectl create clusterrolebinding jenkins --clusterrole cluster-admin --serviceaccount=jenkins:jenkins

and adding the certificate in Jenkins (Manage Jenkins --> Configure System --> Add Cloud) I get the error message

Error connecting to https://169.46.7.238:21769: 
Failure executing: GET at: 
https://169.46.7.238:21769/api/v1/namespaces/jenkins/pods. 
Message: Forbidden!Configured service account doesn't have access. 
Service account may have been revoked. 
User "system:serviceaccount:jenkins:default" cannot list pods in the namespace "jenkins"..

It seems like Jenkins tries to use the defaultServiceaccount.

How can this be fixed?

-- trahloff
jenkins
kubernetes

1 Answer

10/2/2017

Just in case, could you try creating the service account system:serviceaccount:jenkins:default instead of jenkins?

-- Javier Salmeron
Source: StackOverflow