我創建了一個 K3d 集群。我已經在里面部署了一個 jenkins 2.319.1 控制器,以及 kubernetes 插件 1.31.1(以及 git、管道等)這個想法是在同一個集群中運行控制器和代理。為此,我配置了如下圖所示的云:[云配置][1] [1]:https://i.stack.imgur.com/u91Fr.png
(我已經用不同的組合嘗試了幾次嘗試讓代理連接到控制器。最后我一直使用 JNLP - 沒有 WEBSOCKET - 盡管無論如何,我要描述的超時對他們來說都是共同的)
配置云并能夠生成代理后,經過多次嘗試,我終于發現該作業在容器步驟內的執行中掛起(并且因超時而死)。默認的“jnlp”容器中的操作是可以的,但是當你做一些微不足道的事情時:sh 'ls -l'在另一個容器中,作業在 30 秒后終止,并顯示以下日志:
> .
.
.
.
readOnly: false
nodeSelector:
kubernetes.io/os: "linux"
restartPolicy: "Never"
volumes:
- emptyDir:
medium: ""
name: "workspace-volume"
Running on prueba-6-tj9w5-r0qt9-kcst4 in /home/jenkins/agent/workspace/Prueba
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Get a Maven project)
[Pipeline] sh
git config --global http.proxy http://10.11x.xx.xx:8080
[Pipeline] sh
git config --global https.proxy http://10.11x.xx.xx:8080
[Pipeline] git
The recommended git tool is: NONE
No credentials specified
Cloning the remote Git repository
Cloning repository https://github.com/jenkinsci/kubernetes-plugin.git
> git init /home/jenkins/agent/workspace/Prueba # timeout=10
Fetching upstream changes from https://github.com/jenkinsci/kubernetes-plugin.git
> git --version # timeout=10
> git --version # 'git version 2.30.2'
> git fetch --tags --force --progress -- https://github.com/jenkinsci/kubernetes-plugin.git refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
Checking out Revision a61114b275425489761f095e8a89b19cf2ab5c8e (refs/remotes/origin/master)
> git config remote.origin.url https://github.com/jenkinsci/kubernetes-plugin.git # timeout=10
> git config --add remote.origin.fetch refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git config core.sparsecheckout # timeout=10
> git checkout -f a61114b275425489761f095e8a89b19cf2ab5c8e # timeout=10
> git branch -a -v --no-abbrev # timeout=10
> git checkout -b master a61114b275425489761f095e8a89b19cf2ab5c8e # timeout=10
Commit message: "[maven-release-plugin] prepare for next development iteration"
First time build. Skipping changelog.
[Pipeline] container
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build a Maven project)
[Pipeline] sh
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
java.io.IOException: Timed out waiting for websocket connection. You should increase the value of system property org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator.websocketConnectionTimeout currently set at 60 seconds
at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.doLaunch(ContainerExecDecorator.java:457)
at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.launch(ContainerExecDecorator.java:344)
at hudson.Launcher$ProcStarter.start(Launcher.java:507)
.
.
.
我不知道云配置中的 websocket 訊息,這顯然是未選中的。正如我提到的,如果我檢查 websocket(以及清除隧道),我會得到相同的結果。
我不知道這是否與在 dockerized 集群中運行的 jenkins 有關。我在 windows 的 wsl2 和 rhel 7.9 中都安裝了相同的集群(k3d v4.4.7)。
使用的示例管道(最后一個是從 借來的):
> podTemplate(containers: [
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'golang', image: 'golang:1.8.0', ttyEnabled: true, command: 'cat')
]) {
node(POD_LABEL) {
env.http_proxy='http_proxy=http://10.11x.xx.xx:8080'
env.https_proxy='http_proxy=http://10.11x.xx.xx:8080'
stage('Get a Maven project') {
sh 'git config --global http.proxy http://10.11x.xx.xx:8080'
sh 'git config --global https.proxy http://10.11x.xx.xx:8080'
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container('maven') {
stage('Build a Maven project') {
sh 'mvn -B clean install'
}
}
}
stage('Get a Golang project') {
git url: 'https://github.com/hashicorp/terraform.git'
container('golang') {
stage('Build a Go project') {
sh """
mkdir -p /go/src/github.com/hashicorp
ln -s `pwd` /go/src/github.com/hashicorp/terraform
cd /go/src/github.com/hashicorp/terraform && make core-dev
"""
}
}
}
}
}
問候
uj5u.com熱心網友回復:
正如前面評論提到的帖子(Jenkins with Kubernetes Client Plugin - NoSuchMethodError)將 kubernetes 插件升級到 v1.31.2 解決了這個問題。已經打補丁和測驗了。
韓國
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/408045.html
標籤:
上一篇:詹金斯沒有運行任何作業
