Status: 403 - events is forbidden: User “system:serviceaccount:kube-ops:jenkins“ cannot watch resour

报错
Exec Failure: HTTP 403, Status: 403 - events is forbidden: User "system:serviceaccount:kube-ops:jenkins" cannot watch resource "events" in API group "" in the namespace "kube-ops"
java.net.ProtocolException: Expected HTTP 101 response but was '403 Forbidden'
	at okhttp3.internal.ws.RealWebSocket.checkResponse(RealWebSocket.java:229)
	at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:196)
	at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
	at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

Oct 25, 2021 10:58:27 AM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher eventWatch
Cannot watch events on kube-ops/jenkins-slave-c91gs-1zjnj
Also:   java.lang.Throwable: waiting here
	at io.fabric8.kubernetes.client.utils.Utils.waitUntilReady(Utils.java:151)
	at io.fabric8.kubernetes.client.dsl.internal.WebSocketClientRunner.waitUntilReady(WebSocketClientRunner.java:50)
	at io.fabric8.kubernetes.client.dsl.internal.AbstractWatchManager.waitUntilReady(AbstractWatchManager.java:164)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.watch(BaseOperation.java:822)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.watch(BaseOperation.java:795)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.watch(BaseOperation.java:86)
	at org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher.eventWatch(KubernetesLauncher.java:268)
	at org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher.launch(KubernetesLauncher.java:167)
	at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:293)
	at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
	at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:80)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
报错背景

K8S中启用的Jenkins主节点配置K8S插件动态生成Jenkins-Slave的时候,执行构建任务的时候报这个错。

解决

需要在该Jenkins容器的role的resources中添加一个events
Status: 403 - events is forbidden: User “system:serviceaccount:kube-ops:jenkins“ cannot watch resour_第1张图片

你可能感兴趣的:(bug处理,jenkins,k8s)