Updated guide to 0.5.0 (#501)

- updated versions of plugins and images in the guide
- added 'get-latest' to backup docs
This commit is contained in:
SylwiaBrant 2021-02-02 12:26:26 +01:00 committed by GitHub
parent 5f45777554
commit 4410ad6b88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 138 deletions

View File

@ -1,31 +0,0 @@
#!/usr/bin/env groovy
pipelineJob('build-jenkins-operator') {
displayName('Build jenkins-operator')
logRotator {
numToKeep(10)
daysToKeep(30)
}
configure { project ->
project / 'properties' / 'org.jenkinsci.plugins.workflow.job.properties.DurabilityHintJobProperty' {
hint('PERFORMANCE_OPTIMIZED')
}
}
definition {
cpsScm {
scm {
git {
remote {
url('https://github.com/jenkinsci/kubernetes-operator.git')
credentials('jenkins-operator')
}
branches('*/master')
}
}
scriptPath('cicd/pipelines/build.jenkins')
}
}
}

View File

@ -1,48 +0,0 @@
#!/usr/bin/env groovy
def label = "build-jenkins-operator-${UUID.randomUUID().toString()}"
def home = "/home/jenkins"
def workspace = "${home}/workspace/build-jenkins-operator"
def workdir = "${workspace}/src/github.com/jenkinsci/kubernetes-operator/"
podTemplate(label: label,
containers: [
containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:alpine'),
containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true),
],
envVars: [
envVar(key: 'GOPATH', value: workspace),
],
) {
node(label) {
dir(workdir) {
stage('Init') {
timeout(time: 3, unit: 'MINUTES') {
checkout scm
}
container('go') {
sh 'apk --no-cache --update add make git gcc libc-dev'
}
}
stage('Dep') {
container('go') {
sh 'make dep'
}
}
stage('Test') {
container('go') {
sh 'make test'
}
}
stage('Build') {
container('go') {
sh 'make build'
}
}
}
}
}

View File

@ -2,7 +2,7 @@
title: "Configuration" title: "Configuration"
linkTitle: "Configuration" linkTitle: "Configuration"
weight: 2 weight: 2
date: 2021-01-18 date: 2021-01-25
description: > description: >
How to configure Jenkins with Operator How to configure Jenkins with Operator
--- ---
@ -19,18 +19,29 @@ First you have to prepare pipelines and job definition in your GitHub repository
``` ```
cicd/ cicd/
├── jobs ├── jobs
│   └── build.jenkins │   └── k8s.jenkins
└── pipelines └── pipelines
└── build.jenkins └── k8s.jenkins
``` ```
**`cicd/jobs/build.jenkins`** is a job definition: **`cicd/jobs/k8s.jenkins`** is a job definition:
``` ```
#!/usr/bin/env groovy #!/usr/bin/env groovy
pipelineJob('build-jenkins-operator') { pipelineJob('k8s-e2e') {
displayName('Build jenkins-operator') displayName('Kubernetes Plugin E2E Test')
logRotator {
numToKeep(10)
daysToKeep(30)
}
configure { project ->
project / 'properties' / 'org.jenkinsci.plugins.workflow.job.properties.DurabilityHintJobProperty' {
hint('PERFORMANCE_OPTIMIZED')
}
}
definition { definition {
cpsScm { cpsScm {
@ -43,59 +54,31 @@ pipelineJob('build-jenkins-operator') {
branches('*/master') branches('*/master')
} }
} }
scriptPath('cicd/pipelines/build.jenkins') scriptPath('cicd/pipelines/k8s.jenkins')
} }
} }
} }
``` ```
**`cicd/pipelines/build.jenkins`** is an actual Jenkins pipeline: **`cicd/pipelines/k8s.jenkins`** is an actual Jenkins pipeline:
``` ```
#!/usr/bin/env groovy #!/usr/bin/env groovy
def label = "build-jenkins-operator-${UUID.randomUUID().toString()}" def label = "k8s-${UUID.randomUUID().toString()}"
def home = "/home/jenkins" def home = "/home/jenkins"
def workspace = "${home}/workspace/build-jenkins-operator" def workspace = "${home}/workspace/build-jenkins-operator"
def workdir = "${workspace}/src/github.com/jenkinsci/kubernetes-operator/" def workdir = "${workspace}/src/github.com/jenkinsci/kubernetes-operator/"
podTemplate(label: label, podTemplate(label: label,
containers: [ containers: [
containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:alpine'), containerTemplate(name: 'alpine', image: 'alpine:3.11', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true),
],
envVars: [
envVar(key: 'GOPATH', value: workspace),
], ],
) { ) {
node(label) { node(label) {
dir(workdir) { stage('Run shell') {
stage('Init') { container('alpine') {
timeout(time: 3, unit: 'MINUTES') { sh 'echo "hello world"'
checkout scm
}
container('go') {
sh 'apk --no-cache --update add make git gcc libc-dev'
}
}
stage('Dep') {
container('go') {
sh 'make dep'
}
}
stage('Test') {
container('go') {
sh 'make test'
}
}
stage('Build') {
container('go') {
sh 'make build'
}
} }
} }
} }

View File

@ -2,7 +2,7 @@
title: "Configure backup and restore" title: "Configure backup and restore"
linkTitle: "Configure backup and restore" linkTitle: "Configure backup and restore"
weight: 10 weight: 10
date: 2021-01-18 date: 2021-01-25
description: > description: >
Prevent loss of job history Prevent loss of job history
--- ---
@ -48,7 +48,7 @@ spec:
fsGroup: 1000 fsGroup: 1000
containers: containers:
- name: jenkins-master - name: jenkins-master
image: jenkins/jenkins:lts image: jenkins/jenkins:2.263.2-lts-alpine
- name: backup # container responsible for the backup and restore - name: backup # container responsible for the backup and restore
env: env:
- name: BACKUP_DIR - name: BACKUP_DIR
@ -57,7 +57,7 @@ spec:
value: /jenkins-home value: /jenkins-home
- name: BACKUP_COUNT - name: BACKUP_COUNT
value: "3" # keep only the 2 most recent backups value: "3" # keep only the 2 most recent backups
image: virtuslab/jenkins-operator-backup-pvc:v0.0.8 # look at backup/pvc directory image: virtuslab/jenkins-operator-backup-pvc:v0.1.0 # look at backup/pvc directory
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
volumeMounts: volumeMounts:
- mountPath: /jenkins-home # Jenkins home volume - mountPath: /jenkins-home # Jenkins home volume
@ -74,6 +74,10 @@ spec:
exec: exec:
command: command:
- /home/user/bin/backup.sh # this command is invoked on "backup" container to make backup, for example /home/user/bin/backup.sh <backup_number>, <backup_number> is passed by operator - /home/user/bin/backup.sh # this command is invoked on "backup" container to make backup, for example /home/user/bin/backup.sh <backup_number>, <backup_number> is passed by operator
getLatestAction:
exec:
command:
- /home/user/bin/get-latest.sh # this command is invoked on "backup" container to get last backup number before pod deletion. If you don't omit it in CR, you can lose data
interval: 30 # how often make backup in seconds interval: 30 # how often make backup in seconds
makeBackupBeforePodDeletion: true # make a backup before pod deletion makeBackupBeforePodDeletion: true # make a backup before pod deletion
restore: restore:

View File

@ -2,7 +2,7 @@
title: "Customization" title: "Customization"
linkTitle: "Customization" linkTitle: "Customization"
weight: 3 weight: 3
date: 2021-01-18 date: 2021-01-25
description: > description: >
How to customize Jenkins How to customize Jenkins
--- ---
@ -13,13 +13,13 @@ Plugin's configuration is applied as groovy scripts or the [configuration as cod
Any plugin working for Jenkins can be installed by the Jenkins Operator. Any plugin working for Jenkins can be installed by the Jenkins Operator.
Pre-installed plugins: Pre-installed plugins:
* configuration-as-code v1.38 * configuration-as-code v1.46
* git v4.2.2 * git v4.5.0
* job-dsl v1.77 * job-dsl v1.77
* kubernetes-credentials-provider v0.13 * kubernetes-credentials-provider v0.15
* kubernetes v1.25.2 * kubernetes v1.28.6
* workflow-aggregator v2.6 * workflow-aggregator v2.6
* workflow-job v2.38 * workflow-job v2.40
Rest of the plugins can be found in [plugins repository](https://plugins.jenkins.io/). Rest of the plugins can be found in [plugins repository](https://plugins.jenkins.io/).
@ -37,7 +37,7 @@ spec:
master: master:
plugins: plugins:
- name: simple-theme-plugin - name: simple-theme-plugin
version: 0.5.1 version: "0.6"
``` ```
Under `spec.master.basePlugins` you can find plugins for a valid **Jenkins Operator**: Under `spec.master.basePlugins` you can find plugins for a valid **Jenkins Operator**:
@ -51,19 +51,19 @@ spec:
master: master:
basePlugins: basePlugins:
- name: kubernetes - name: kubernetes
version: 1.18.3 version: "1.28.6"
- name: workflow-job - name: workflow-job
version: "2.34" version: "2.40"
- name: workflow-aggregator - name: workflow-aggregator
version: "2.6" version: "2.6"
- name: git - name: git
version: 3.12.0 version: "4.5.0"
- name: job-dsl - name: job-dsl
version: "1.76" version: "1.77"
- name: configuration-as-code - name: configuration-as-code
version: "1.29" version: "1.46"
- name: kubernetes-credentials-provider - name: kubernetes-credentials-provider
version: 0.12.1 version: "0.15"
``` ```
You can change their versions. You can change their versions.

View File

@ -2,7 +2,7 @@
title: "Deploy Jenkins" title: "Deploy Jenkins"
linkTitle: "Deploy Jenkins" linkTitle: "Deploy Jenkins"
weight: 1 weight: 1
date: 2021-01-18 date: 2021-01-25
description: > description: >
Deploy production ready Jenkins Operator manifest Deploy production ready Jenkins Operator manifest
--- ---
@ -19,7 +19,7 @@ spec:
master: master:
containers: containers:
- name: jenkins-master - name: jenkins-master
image: jenkins/jenkins:lts image: jenkins/jenkins:2.263.2-lts-alpine
imagePullPolicy: Always imagePullPolicy: Always
livenessProbe: livenessProbe:
failureThreshold: 12 failureThreshold: 12