k8s上部署jenkins,jenkins搭建k8s集群
jenkins部署在k8s上,并且搭建8s集群,每个任务启动一个从节点执行,执行完释放。配置方式如下:jenkins -> 配置:测试连接,没过,一般是没有权限。可以赋cluster-admin权限--serviceaccount={namespace}:defaultkubectl create clusterrolebinding devops-permissive-binding --
jenkins部署在k8s上,并且搭建8s集群,每个任务启动一个从节点执行,执行完释放。
配置方式如下:
jenkins -> 配置:
测试连接,没过,一般是没有权限。可以赋cluster-admin权限
--serviceaccount={namespace}:default
kubectl create clusterrolebinding devops-permissive-binding --clusterrole=cluster-admin --serviceaccount=devops:default
报错为:
Error testing connection https://kubernetes.default.svc.cluster.local: Failure executing: GET at: https://kubernetes.default.svc.cluster.local/api/v1/namespaces/defualt/pods. Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. pods is forbidden: User "system:serviceaccount:infra:default" cannot list resource "pods" in API group "" in the namespace "defualt".
也可以参考如下连接:
Jenkins集成k8s报错:Error testing connection https://kubernetes.default.svc.cluster.local: Failure
以下错误是从节点没有权限创建pod造成,解决方法同测试连接一样,赋权就行,或者直接给cluster-admin权限:
2021-10-12 07:24:32.295+0000 [id=31] INFO hudson.slaves.NodeProvisioner#lambda$update$6: slave-6n6gq provisioning successfully completed. We have now 2 computer(s)
Disconnected computer slave-6n6gq
2021-10-12 07:24:32.326+0000 [id=554] WARNING o.c.j.p.k.KubernetesSlave#_terminate: Slave pod slave-6n6gq was not deleted due to retention policy On Failure.
2021-10-12 07:24:32.326+0000 [id=554] INFO o.c.j.p.k.KubernetesSlave#_terminate: Disconnected computer slave-6n6gq
2021-10-12 07:24:42.263+0000 [id=35] INFO o.c.j.p.k.KubernetesCloud#provision: Excess workload after pending Kubernetes agents: 1
2021-10-12 07:24:42.263+0000 [id=35] INFO o.c.j.p.k.KubernetesCloud#provision: Template for label null: slave
2021-10-12 07:24:52.272+0000 [id=554] WARNING o.c.j.p.k.KubernetesLauncher#launch: Error in provisioning; agent=KubernetesSlave name: slave-scj1d, template=PodTemplate{inheritFrom='', name='slave', namespace='devops', hostNetwork=false, slaveConnectTimeout=180, label='jenkins-slave', nodeSelector='', nodeUsageMode=NORMAL, workspaceVolume=EmptyDirWorkspaceVolume [memory=false], volumes=[HostPathVolume [mountPath=/var/run/docker.sock, hostPath=/var/run/docker.sock], org.csanchez.jenkins.plugins.kubernetes.volumes.PersistentVolumeClaim@a77c69f], containers=[ContainerTemplate{name='jnlp', image='10.110.147.181:89/jenkins/slave:v4.3.4.13', workingDir='/home/jenkins/agent', command='', args='${computer.jnlpmac} ${computer.name}', ttyEnabled=true, resourceRequestCpu='', resourceRequestMemory='', resourceLimitCpu='', resourceLimitMemory='', envVars=[KeyValueEnvVar [getValue()=http://ui.devops.svc.cluster.local:80, getKey()=JENKINS_URL], KeyValueEnvVar [getValue()=/etc/kubernetes/ssl, getKey()=KUBE_CONFIG]], livenessProbe=org.csanchez.jenkins.plugins.kubernetes.ContainerLivenessProbe@5e7fa1ad}]}
java.lang.NullPointerException
at org.csanchez.jenkins.plugins.kubernetes.PodUtils.cancelQueueItemFor(PodUtils.java:76)
at org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher.launch(KubernetesLauncher.java:138)
at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:294)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
2021-10-12 07:24:52.272+0000 [id=554] INFO o.c.j.p.k.KubernetesSlave#_terminate: Terminating Kubernetes instance for agent slave-scj1d
更多推荐
所有评论(0)