jenkins operator v0.4.0 部署在 kubernetes 上,但我们无法保留我们的工作和管道
jenkins operator v0.4.0 deployed on kubernetes but we can't persiste our jobs and pipelines
我们使用 jenkins 操作符在 kubernetes 上安装 jenkins 时遇到问题,因此我们无法保留创建的作业,因为在重新启动 pods 后我们丢失了作业,这些是我们用于启动它的配置:
apiVersion: jenkins.io/v1alpha2
kind: Jenkins
metadata:
name: jenkins
namespace: integration
spec:
configurationAsCode:
configurations:
groovyScripts:
configurations:
backup:
containerName: backup
action:
exec:
command:
- /home/user/bin/backup.sh
interval: 30
makeBackupBeforePodDeletion: true
restore:
containerName: backup
action:
exec:
command:
- /home/user/bin/restore.sh
master:
basePlugins:
- name: kubernetes
version: 1.25.2
- name: workflow-job
version: "2.39"
- name: workflow-aggregator
version: "2.6"
- name: git
version: 4.2.2
- name: job-dsl
version: "1.77"
- name: configuration-as-code
version: "1.38"
- name: kubernetes-credentials-provider
version: "0.13"
plugins:
- name: maven-plugin
version: "3.8"
- name: ansible
version: "1.1"
- name: bitbucket
version: 1.1.27
- name: bitbucket-build-status-notifier
version: 1.4.2
- name: docker-plugin
version: 1.2.1
- name: generic-webhook-trigger
version: "1.72"
- name: github-pullrequest
version: 0.2.8
- name: job-import-plugin
version: "3.4"
- name: msbuild
version: "1.29"
- name: nexus-artifact-uploader
version: "2.13"
- name: pipeline-npm
version: 0.9.2
- name: pipeline-utility-steps
version: 2.6.1
- name: pollscm
version: 1.3.1
- name: postbuild-task
version: "1.9"
- name: ranorex-integration
version: 1.0.2
- name: sidebar-link
version: 1.11.0
- name: sonarqube-generic-coverage
version: "1.0"
- name: sonar
version: "2.13"
- name: simple-theme-plugin
version: "0.6"
priorityClassName:
disableCSRFProtection: false
containers:
- name: jenkins-master
image: jenkins/jenkins:lts
imagePullPolicy: Always
livenessProbe:
failureThreshold: 12
httpGet:
path: /login
port: http
scheme: HTTP
initialDelaySeconds: 80
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
failureThreshold: 3
httpGet:
path: /login
port: http
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
cpu: 1500m
memory: 3Gi
requests:
cpu: 1
memory: 500Mi
- name: backup
image: virtuslab/jenkins-operator-backup-pvc:v0.0.8
imagePullPolicy: IfNotPresent
env:
- name: BACKUP_DIR
value: /backup
- name: JENKINS_HOME
value: /jenkins-home
- name: BACKUP_COUNT
value: "3"
volumeMounts:
- mountPath: /jenkins-home
name: jenkins-home
- mountPath: /backup
name: backup
volumes:
- name: backup
persistentVolumeClaim:
claimName: jenkins-backup
- name: jenkins-home
persistentVolumeClaim:
claimName: jenkins-home
securityContext:
fsGroup: 1000
runAsUser: 1000
seedJobs:
- description: Jenkins Operator repository
id: jenkins-operator
repositoryBranch: master
repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git
targets: cicd/jobs/*.jenkins
操作员有两个脚本备份和恢复,我们看到的是我们的预配置作业被保留,但新创建的作业(使用 GUI)却没有。关于这个问题的任何想法?或者 jenkins 操作员不允许持久性?
Because of Jenkins Operator’s architecture, the configuration of Jenkins should be done using ConfigurationAsCode or GroovyScripts and jobs should be defined as SeedJobs. It means that there is no point in backing up any job configuration up. Therefore, the backup script makes a copy of jobs history only.
所以是的,这是预期的行为,您应该创建新的工作作为 SeedJobs,而不是在 GUI 中。
我们使用 jenkins 操作符在 kubernetes 上安装 jenkins 时遇到问题,因此我们无法保留创建的作业,因为在重新启动 pods 后我们丢失了作业,这些是我们用于启动它的配置:
apiVersion: jenkins.io/v1alpha2
kind: Jenkins
metadata:
name: jenkins
namespace: integration
spec:
configurationAsCode:
configurations:
groovyScripts:
configurations:
backup:
containerName: backup
action:
exec:
command:
- /home/user/bin/backup.sh
interval: 30
makeBackupBeforePodDeletion: true
restore:
containerName: backup
action:
exec:
command:
- /home/user/bin/restore.sh
master:
basePlugins:
- name: kubernetes
version: 1.25.2
- name: workflow-job
version: "2.39"
- name: workflow-aggregator
version: "2.6"
- name: git
version: 4.2.2
- name: job-dsl
version: "1.77"
- name: configuration-as-code
version: "1.38"
- name: kubernetes-credentials-provider
version: "0.13"
plugins:
- name: maven-plugin
version: "3.8"
- name: ansible
version: "1.1"
- name: bitbucket
version: 1.1.27
- name: bitbucket-build-status-notifier
version: 1.4.2
- name: docker-plugin
version: 1.2.1
- name: generic-webhook-trigger
version: "1.72"
- name: github-pullrequest
version: 0.2.8
- name: job-import-plugin
version: "3.4"
- name: msbuild
version: "1.29"
- name: nexus-artifact-uploader
version: "2.13"
- name: pipeline-npm
version: 0.9.2
- name: pipeline-utility-steps
version: 2.6.1
- name: pollscm
version: 1.3.1
- name: postbuild-task
version: "1.9"
- name: ranorex-integration
version: 1.0.2
- name: sidebar-link
version: 1.11.0
- name: sonarqube-generic-coverage
version: "1.0"
- name: sonar
version: "2.13"
- name: simple-theme-plugin
version: "0.6"
priorityClassName:
disableCSRFProtection: false
containers:
- name: jenkins-master
image: jenkins/jenkins:lts
imagePullPolicy: Always
livenessProbe:
failureThreshold: 12
httpGet:
path: /login
port: http
scheme: HTTP
initialDelaySeconds: 80
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
failureThreshold: 3
httpGet:
path: /login
port: http
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
cpu: 1500m
memory: 3Gi
requests:
cpu: 1
memory: 500Mi
- name: backup
image: virtuslab/jenkins-operator-backup-pvc:v0.0.8
imagePullPolicy: IfNotPresent
env:
- name: BACKUP_DIR
value: /backup
- name: JENKINS_HOME
value: /jenkins-home
- name: BACKUP_COUNT
value: "3"
volumeMounts:
- mountPath: /jenkins-home
name: jenkins-home
- mountPath: /backup
name: backup
volumes:
- name: backup
persistentVolumeClaim:
claimName: jenkins-backup
- name: jenkins-home
persistentVolumeClaim:
claimName: jenkins-home
securityContext:
fsGroup: 1000
runAsUser: 1000
seedJobs:
- description: Jenkins Operator repository
id: jenkins-operator
repositoryBranch: master
repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git
targets: cicd/jobs/*.jenkins
操作员有两个脚本备份和恢复,我们看到的是我们的预配置作业被保留,但新创建的作业(使用 GUI)却没有。关于这个问题的任何想法?或者 jenkins 操作员不允许持久性?
Because of Jenkins Operator’s architecture, the configuration of Jenkins should be done using ConfigurationAsCode or GroovyScripts and jobs should be defined as SeedJobs. It means that there is no point in backing up any job configuration up. Therefore, the backup script makes a copy of jobs history only.
所以是的,这是预期的行为,您应该创建新的工作作为 SeedJobs,而不是在 GUI 中。