Kubernetes-Help Needed-FailedMount 3m38s

10/15/2018

I have created a Jenkins cluster on Kubernetes (Master + 2 workers) with local volumes on the Master node.

I created a persistent vol of 2GB and the claim is 1 GB.

I created a deployment with the image: jenkins/jenkins:lts and volume mount from /var/jenkins_home to PVC: claimname

I have already copied the data on local folder which is Persistent Volume but I am not able to see my jobs on jenkins server.

kubectl describe pod dep-jenkins-8648454f65-4v8tb
Events:
 Type     Reason       Age                      From                     Message
 ----     ------       ----                     ----                     -------
 Warning  FailedMount  3m38s (x149 over 4h50m)  kubelet, kube-worker001  MountVolume.SetUp failed for volume "default-token-424m4" : secret "default-token-424m4" not found

What is the correct way to mount a local directory in a POD so that I can transfer my Jenkins data to newly created Jenkins server on Kubernetes?

-- user271418
devops
docker
jenkins
kubernetes

1 Answer

10/15/2018

Looks like the Warning in your pod description is related to mounting a secret and not mounting any PV. To set up your JENKINS_HOME as a persistent volume you would do something like this:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: jenkins
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      containers:
        - name: jenkins
          image: my-jenkins-image
          env:
            - name: JAVA_OPTS
              value: -Djenkins.install.runSetupWizard=false
          ports:
            - name: http-port
              containerPort: 8080
            - name: jnlp-port
              containerPort: 50000
          volumeMounts:
            - name: jenkins-home
              mountPath: /var/jenkins_home
      volumes:
      - name: jenkins-home
        persistentVolumeClaim:
          claimName: jenkins-home
-- Rico
Source: StackOverflow