skip to Main Content

I am new to K8s. I am trying to create Jenkins pod and the agent in K8s environment. Installed all plugins also configured the kubernetes plugins.
I successfully created the Jenkins Pod and the agent also build the sample job but the issue is
when the server restarts all my installed plugins and the configurations all got removed. Again it start from the scratch asking Admin password and start installing the plugins. So how to fix this issue please advice.

I have given all my Yaml files below

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

2

Answers


  1. Based on the information you provided, you might want to double check the basics like the indentation of your sections as they might be the cause of your issue. Look at the ‘volumes’ and ‘volumeMounts’ section if the format is correct. Also check ‘jenkins-pv-claim’ as it should be defined in your jenkins namespace. Hope this helps your case.

    Login or Signup to reply.
  2. seems that the path for jenkins-data is not correct, and you are storing the data in Ephemeral Storage. jenkins searches for the data in /var/jenkins_home.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search