- 创建namespace
apiVersion: v1
kind: Namespace
metadata:name: jenkins
- 创建pv以及pvc
kind: PersistentVolume
apiVersion: v1
metadata:name: jenkins-pv-volumenamespace: jenkinslabels:type: localapp: jenkins
spec:#storageClassName: manualcapacity:storage: 5GiaccessModes:- ReadWriteManyhostPath:path: "/home/ellis/k8s/Jenkins/jenkinsdata/vol"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:name: jenkins-pv-claimnamespace: jenkinslabels:app: jenkins
spec:storageClassName: ""accessModes:- ReadWriteManyresources:requests:storage: 5Gi
---
kind: PersistentVolume
apiVersion: v1
metadata:name: jenkinshome-pv-volumenamespace: jenkinslabels:type: localapp: jenkins
spec:#storageClassName: manualcapacity:storage: 5GiaccessModes:- ReadWriteManyhostPath:path: "/home/ellis/k8s/Jenkins/jenkinsdata/home"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:name: jenkinshome-pv-claimnamespace: jenkinslabels:app: jenkins
spec:storageClassName: ""accessModes:- ReadWriteManyresources:requests:storage: 5Gi
- 创建deployment以及service
apiVersion: apps/v1
kind: Deployment
metadata:name: jenkinsnamespace: jenkins
spec:replicas: 1selector:matchLabels:app: jenkinstemplate:metadata:labels:app: jenkinsspec:containers:- name: jenkinsimage: jenkins/jenkins:ltsports:- name: http-portcontainerPort: 8080- name: jnlp-portcontainerPort: 50000env:- name: TZvalue: "Asia/Shanghai"volumeMounts:- name: jenkins-volmountPath: /var/jenkins_vol- name: jenkins-homemountPath: /var/jenkins_homeresources:limits:cpu: 500mmemory: 2Girequests:cpu: 500mmemory: 2Givolumes:- name: jenkins-volpersistentVolumeClaim:claimName: jenkins-pv-claim- name: jenkins-homepersistentVolumeClaim:claimName: jenkinshome-pv-claim
---
apiVersion: v1
kind: Service
metadata:name: jenkinsnamespace: jenkins
spec:type: NodePortports:- port: 8080targetPort: 8080nodePort: 30000selector:app: jenkins---apiVersion: v1
kind: Service
metadata:name: jenkins-jnlpnamespace: jenkins
spec:type: ClusterIPports:- port: 50000targetPort: 50000selector:app: jenkins
- 查看admin password
拉到最下面查找password
sudo kubectl logs pod/jenkins-d6fcdfdd6-hqqvd -n jenkins
- 访问http://ip:30000
- Windows安装java 21
- 下载zip
- 解压
- 添加JAVA_HOME环境变量,例如D:\java21sdk\jdk-21.0.1
- 添加PATH 例如 %JAVA_HOME%\bin;
- 配置添加Windows节点
启动方式选择如下
跟着配置即可