我是K8s的新手。我正在尝试在K8s环境中创建Jenkins Pod和代理。安装了所有插件并配置了Kubernetes插件。我成功地创建了Jenkins Pod,代理也构建了示例作业,但问题是当服务器重新启动我安装的所有插件时,所有配置都被删除了。再次从头开始询问管理员密码并开始安装插件。那么怎么做呢要解决这个问题,请咨询。
我已经给了我所有的Yaml文件下面
Volume.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: jenkins-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
apiVersion: v1
kind: PersistentVolume
metadata:
name: jenkins-pv-volume
labels:
type: local
spec:
storageClassName: jenkins-storage
claimRef:
name: jenkins-pv-claim
namespace: jenkins
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /mnt/jenkins-vol
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: jenkins-pv-claim
namespace: jenkins
spec:
storageClassName: jenkins-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---------
字符串
Deployment.Yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins
namespace: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: jenkins-server
template:
metadata:
labels:
app: jenkins-server
spec:
securityContext:
fsGroup: 1000
runAsUser: 1000
serviceAccountName: jenkins-admin
containers:
- name: jenkins
image: jenkins/jenkins:lts
resources:
limits:
memory: "3Gi"
cpu: "1500m"
requests:
memory: "500Mi"
cpu: "500m"
ports:
- name: httpport
containerPort: 8080
- name: jnlpport
containerPort: 50000
livenessProbe:
httpGet:
path: "/login"
port: 8080
initialDelaySeconds: 90
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 5
readinessProbe:
httpGet:
path: "/login"
port: 8080
initialDelaySeconds: 300
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
volumeMounts:
- name: jenkins-data
mountPath: /opt/containerd_workspace/containerd/
io.containerd.snapshotter.v1.overlayfs/snapshots/284/fs/var/jenkins_home
volumes:
- name: jenkins-data
persistentVolumeClaim:
claimName: jenkins-pv-claim
型
3条答案
按热度按时间cuxqih211#
根据您提供的信息,您可能需要仔细检查基本内容,例如节的缩进,因为它们可能是导致问题的原因。查看“volumes”和“volumeMounts”节,如果格式正确。还检查“jenkins-pv-claim”,因为它应该在您的jenkins命名空间中定义。希望这对您的情况有所帮助。
r55awzrz2#
jenkins-data
的路径似乎不正确,您正在将数据存储在Ephemeral Storage中。jenkins将在/var/jenkins_home
中搜索数据。mrwjdhj33#
我看到你正在使用本地存储作为存储jenkins数据的持久卷。确保jenkins pod始终绑定到同一个主机。验证persistentVolumeReclaimPolicy设置为“Retain”,以避免pod重新启动时删除数据。