Create local storage

Since this is a test cluster, we can directly use local volume storage here;

Since the user running in the jenkins server here is jenkins, and the uid of jenkins is 1000, we need to grant /opt/jenkins_agent/ and /opt/jenkins_maven/ permissions to jenkins in advance on node1

1
2
chown 1000.1000 -R /opt/jenkins_agent -R
chown 1000.1000 -R /opt/jenkins_maven/ -R

Local storage: agent-pv-pvc.yaml

1
2
3
4
5
6
7
8
9
apiVersion: v1
kind: PersistentVolume
metadata:
name: jenkins-agent-pv
spec:
storageClassName: local # Local PV
capacity:
storage: 30Gi
volumeMode: Filesystem accessModes: - ReadWriteOnce local: path: /opt/jenkins_agent nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - node01 --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: jenkins-agent-pvc namespace: kube-ops spec: storageName: local accessModes: - Read WriteOnce resources: requests: storage: 30Gi ```Local storage: maven-pv-pvc.yaml ```yaml apiVersion: v1 kind: PersistentVolume metadata: name: jenkins-maven-pv spec: storageClassName: local # Local PV capacity: storage: 30Gi volumeMode: Filesystem accessModes: - ReadWriteOnce local: path: /opt/jenkins_maven nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - node01 --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: jenkins-maven-pvc namespace: kube-ops spec : storageClassName: local accessModes: - ReadWriteOnce resources: requests: storage: 30Gi ```` ## Create PV and PVC resources ````shell # kubectl apply -f agent-pv-pvc.yaml persistentvolume/jenkins-agent-pv created persistentvolumeclaim/jenkins-agent-pvc created # kubectl apply -f maven-pv-pvc.yaml persistentvolume/jenkins-maven-pv created persistentvolumeclaim/jenkins-maven-pvc created ````