前提条件:
helm version v3.1.0
kubernetst version v1.16.4
官方文档参考:https://hub.kubeapps.com/charts/jenkinsci/jenkins
1、添加helm repo仓库
$ helm repo add jenkinsci https://charts.jenkins.io/
$ helm pull jenkinsci/jenkins --version 3.2.0
jenkins-3.2.0.tgz
$ tar zxvf jenkins-3.2.0.tgz
2、修改values.yaml
#这里我只给出修改的参数,未修改的按照应用默认参数即可
adminPassword: jenkins123 #这里不设置也可以,根据部署完成后的提示获取临时秘钥即可
serviceType: NodePort
livenessProbe:
failureThreshold: 5
httpGet:
path: '{{ default "" .Values.controller.jenkinsUriPrefix }}/login'
port: http
periodSeconds: 10
timeoutSeconds: 5
# If Startup Probe is not supported on your Kubernetes cluster, you might want to use "initialDelaySeconds" instead.
# It delays the initial liveness probe while Jenkins is starting
initialDelaySeconds: 60 #需要放开这个参数,否则初始化会报错
readinessProbe:
failureThreshold: 3
httpGet:
path: '{{ default "" .Values.controller.jenkinsUriPrefix }}/login'
port: http
periodSeconds: 10
timeoutSeconds: 5
# If Startup Probe is not supported on your Kubernetes cluster, you might want to use "initialDelaySeconds" instead.
# It delays the initial readyness probe while Jenkins is starting
initialDelaySeconds: 60 #需要放开这个参数,否则初始化会报错
agentListenerServiceType: "NodePort"
installPlugins: #这里可以根据需求安装插件,建议安装完成后在安装插件,否则会导致pod长时间无法running
- kubernetes:1.29.0
- workflow-aggregator:2.6
- git:4.5.2
- configuration-as-code:1.47
- localization-zh-cn:1.0.24
nodeSelector: #如不需要固定到某台集群可不设置
jenkinssvc: "true"
persistence: #这里提前创建好了pvc,如果有动态pvc可不提前创建,只需配置storageClass
enabled: true
## A manually managed Persistent Volume and Claim
## Requires persistence.enabled: true
## If defined, PVC must be created manually before volume will be bound
existingClaim: jenkins-data #提前创建pvc需要配置existingClaim和storageClass两个参数
## jenkins data Persistent Volume Storage Class
## GKE, AWS & OpenStack)
##
storageClass: "jenkinsdata"
annotations: {}
accessMode: "ReadWriteOnce"
size: "8Gi"
volumes:
# - name: jenkins-home
# emptyDir: {}
mounts:
# - mountPath: /var/nothing
# name: jenkins-home
# readOnly: false
3、创建存储的yaml
$ cat jenkins-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: jenkins-data #pv的name
labels:
release: "stable"
spec:
capacity:
storage: 50Gi
accessModes:
- ReadWriteMany
storageClassName: jenkinsdata
persistentVolumeReclaimPolicy: Recycle
nfs:
path: "/data/jenkins"
server: 192.168.110.25
$ cat jenkins-pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: jenkins-data
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Gi
storageClassName: jenkinsdata
selector:
matchLabels:
release: "stable"
4、部署chart
helm install my-jenkins jenkins/
[root@magt-master jenkins]# kubectl get po,svc | grep jenkins
pod/default-jenkinsci-0 2/2 Running 0 6h35m
service/default-jenkinsci NodePort 10.97.91.96 <none> 8080:32146/TCP 6h35m
service/default-jenkinsci-agent NodePort 10.108.70.59 <none> 50000:32344/TCP 6h35m
5、访问地址:http://ip:32146