- 创建namespace
apiVersion: v1
kind: Namespace
metadata:
name: jenkins
- 创建pv以及pvc
kind: PersistentVolume
apiVersion: v1
metadata:
name: jenkins-pv-volume
namespace: jenkins
labels:
type: local
app: jenkins
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/home/ellis/k8s/Jenkins/jenkinsdata/"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: jenkins-pv-claim
namespace: jenkins
labels:
app: jenkins
spec:
storageClassName: ""
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
- 创建deployment以及service
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins
namespace: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins
image: jenkins/jenkins:lts
ports:
- name: http-port
containerPort: 8080
- name: jnlp-port
containerPort: 50000
volumeMounts:
- name: jenkins-vol
mountPath: /var/jenkins_vol
resources:
limits:
cpu: 500m
memory: 2Gi
requests:
cpu: 500m
memory: 2Gi
volumes:
- name: jenkins-vol
persistentVolumeClaim:
claimName: jenkins-pv-claim
---
apiVersion: v1
kind: Service
metadata:
name: jenkins
namespace: jenkins
spec:
type: NodePort
ports:
- port: 8080
targetPort: 8080
nodePort: 30000
selector:
app: jenkins
---
apiVersion: v1
kind: Service
metadata:
name: jenkins-jnlp
namespace: jenkins
spec:
type: ClusterIP
ports:
- port: 50000
targetPort: 50000
selector:
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节点
启动方式选择如下
跟着配置即可