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"
linkTitle: "Configuration"
weight: 2
date: 2021-01-18
date: 2021-01-25
description: >
How to configure Jenkins with Operator
---
@ -19,18 +19,29 @@ First you have to prepare pipelines and job definition in your GitHub repository
```
cicd/
├── jobs
│   └── build.jenkins
│   └── k8s.jenkins
└── 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
pipelineJob('build-jenkins-operator') {
displayName('Build jenkins-operator')
pipelineJob('k8s-e2e') {
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 {
cpsScm {
@ -43,59 +54,31 @@ pipelineJob('build-jenkins-operator') {
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
def label = "build-jenkins-operator-${UUID.randomUUID().toString()}"
def label = "k8s-${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),
containerTemplate(name: 'alpine', image: 'alpine:3.11', ttyEnabled: true, command: 'cat'),
],
) {
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'
}
stage('Run shell') {
container('alpine') {
sh 'echo "hello world"'
}
}
}

View File

@ -2,7 +2,7 @@
title: "Configure backup and restore"
linkTitle: "Configure backup and restore"
weight: 10
date: 2021-01-18
date: 2021-01-25
description: >
Prevent loss of job history
---
@ -48,7 +48,7 @@ spec:
fsGroup: 1000
containers:
- name: jenkins-master
image: jenkins/jenkins:lts
image: jenkins/jenkins:2.263.2-lts-alpine
- name: backup # container responsible for the backup and restore
env:
- name: BACKUP_DIR
@ -57,7 +57,7 @@ spec:
value: /jenkins-home
- name: BACKUP_COUNT
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
volumeMounts:
- mountPath: /jenkins-home # Jenkins home volume
@ -74,6 +74,10 @@ spec:
exec:
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
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
makeBackupBeforePodDeletion: true # make a backup before pod deletion
restore:

View File

@ -2,7 +2,7 @@
title: "Customization"
linkTitle: "Customization"
weight: 3
date: 2021-01-18
date: 2021-01-25
description: >
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.
Pre-installed plugins:
* configuration-as-code v1.38
* git v4.2.2
* configuration-as-code v1.46
* git v4.5.0
* job-dsl v1.77
* kubernetes-credentials-provider v0.13
* kubernetes v1.25.2
* kubernetes-credentials-provider v0.15
* kubernetes v1.28.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/).
@ -37,7 +37,7 @@ spec:
master:
plugins:
- name: simple-theme-plugin
version: 0.5.1
version: "0.6"
```
Under `spec.master.basePlugins` you can find plugins for a valid **Jenkins Operator**:
@ -51,19 +51,19 @@ spec:
master:
basePlugins:
- name: kubernetes
version: 1.18.3
version: "1.28.6"
- name: workflow-job
version: "2.34"
version: "2.40"
- name: workflow-aggregator
version: "2.6"
- name: git
version: 3.12.0
version: "4.5.0"
- name: job-dsl
version: "1.76"
version: "1.77"
- name: configuration-as-code
version: "1.29"
version: "1.46"
- name: kubernetes-credentials-provider
version: 0.12.1
version: "0.15"
```
You can change their versions.

View File

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