How can I use an existing PVC to helm install stable/jenkins

5/23/2019

I am stuck with a helm install of jenkins

:(

please help!

I have predefined a storage class via:

$ kubectl apply -f generic-storage-class.yaml 

with generic-storage-class.yaml:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: generic
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  zones: us-east-1a, us-east-1b, us-east-1c
  fsType: ext4

I then define a PVC via:

$ kubectl apply -f jenkins-pvc.yaml

with jenkins-pvc.yaml:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-pvc
  namespace: jenkins-project
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

I can then see the PVC go into the BOUND status:

$ kubectl get pvc --all-namespaces
NAMESPACE         NAME               STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
jenkins-project   jenkins-pvc        Bound    pvc-a173294f-7cea-11e9-a90f-161c7e8a0754   20Gi       RWO            gp2            27m

But when I try to Helm install jenkins via:

$ helm install --name jenkins \
--set persistence.existingClaim=jenkins-pvc \
stable/jenkins --namespace jenkins-project

I get this output:

NAME:   jenkins
LAST DEPLOYED: Wed May 22 17:07:44 2019
NAMESPACE: jenkins-project
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME           DATA  AGE
jenkins        5     0s
jenkins-tests  1     0s

==> v1/Deployment
NAME     READY  UP-TO-DATE  AVAILABLE  AGE
jenkins  0/1    1           0          0s

==> v1/PersistentVolumeClaim
NAME     STATUS   VOLUME  CAPACITY  ACCESS MODES  STORAGECLASS  AGE
jenkins  Pending  gp2     0s

==> v1/Pod(related)
NAME                      READY  STATUS   RESTARTS  AGE
jenkins-6c9f9f5478-czdbh  0/1    Pending  0         0s

==> v1/Secret
NAME     TYPE    DATA  AGE
jenkins  Opaque  2     0s

==> v1/Service
NAME           TYPE          CLUSTER-IP      EXTERNAL-IP  PORT(S)         AGE
jenkins        LoadBalancer  10.100.200.27   <pending>    8080:31157/TCP  0s
jenkins-agent  ClusterIP     10.100.221.179  <none>       50000/TCP       0s


NOTES:
1. Get your 'admin' user password by running:
  printf $(kubectl get secret --namespace jenkins-project jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo
2. Get the Jenkins URL to visit by running these commands in the same shell:
  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        You can watch the status of by running 'kubectl get svc --namespace jenkins-project -w jenkins'
  export SERVICE_IP=$(kubectl get svc --namespace jenkins-project jenkins --template "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
  echo http://$SERVICE_IP:8080/login

3. Login with the password from step 1 and the username: admin


For more information on running Jenkins on Kubernetes, visit:
https://cloud.google.com/solutions/jenkins-on-container-engine

where I see helm creating a new PersistentVolumeClaim called jenkins.

How come helm did not use the "exsistingClaim"

I see this as the only helm values for the jenkins release

$ helm get values jenkins
persistence:
  existingClaim: jenkins-pvc

and indeed it has just made its own PVC instead of using the pre-created one.

kubectl get pvc --all-namespaces
NAMESPACE         NAME               STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
jenkins-project   jenkins            Bound    pvc-a9caa3ba-7cf1-11e9-a90f-161c7e8a0754   8Gi        RWO            gp2            6m11s
jenkins-project   jenkins-pvc        Bound    pvc-a173294f-7cea-11e9-a90f-161c7e8a0754   20Gi       RWO            gp2            56m

I feel like I am close but missing something basic. Any ideas?

-- gh4x
jenkins
kubernetes
kubernetes-helm
kubernetes-pvc

1 Answer

5/23/2019

So per Matthew L Daniel's comment I ran helm repo update and then re-ran the helm install command. This time it did not re-create the PVC but instead used the pre-made one.

My previous jenkins chart version was "jenkins-0.35.0"

For anyone wondering what the deployment looked like:

Name:               jenkins
Namespace:          jenkins-project
CreationTimestamp:  Wed, 22 May 2019 22:03:33 -0700
Labels:             app.kubernetes.io/component=jenkins-master
                    app.kubernetes.io/instance=jenkins
                    app.kubernetes.io/managed-by=Tiller
                    app.kubernetes.io/name=jenkins
                    helm.sh/chart=jenkins-1.1.21
Annotations:        deployment.kubernetes.io/revision: 1
Selector:           app.kubernetes.io/component=jenkins-master,app.kubernetes.io/instance=jenkins
Replicas:           1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType:       Recreate
MinReadySeconds:    0
Pod Template:
  Labels:           app.kubernetes.io/component=jenkins-master
                    app.kubernetes.io/instance=jenkins
                    app.kubernetes.io/managed-by=Tiller
                    app.kubernetes.io/name=jenkins
                    helm.sh/chart=jenkins-1.1.21
  Annotations:      checksum/config: 867177d7ed5c3002201650b63dad00de7eb1e45a6622e543b80fae1f674a99cb
  Service Account:  jenkins
  Init Containers:
   copy-default-config:
    Image:      jenkins/jenkins:lts
    Port:       <none>
    Host Port:  <none>
    Command:
      sh
      /var/jenkins_config/apply_config.sh
    Limits:
      cpu:     2
      memory:  4Gi
    Requests:
      cpu:     50m
      memory:  256Mi
    Environment:
      ADMIN_PASSWORD:  <set to the key 'jenkins-admin-password' in secret 'jenkins'>  Optional: false
      ADMIN_USER:      <set to the key 'jenkins-admin-user' in secret 'jenkins'>      Optional: false
    Mounts:
      /tmp from tmp (rw)
      /usr/share/jenkins/ref/plugins from plugins (rw)
      /usr/share/jenkins/ref/secrets/ from secrets-dir (rw)
      /var/jenkins_config from jenkins-config (rw)
      /var/jenkins_home from jenkins-home (rw)
      /var/jenkins_plugins from plugin-dir (rw)
  Containers:
   jenkins:
    Image:       jenkins/jenkins:lts
    Ports:       8080/TCP, 50000/TCP
    Host Ports:  0/TCP, 0/TCP
    Args:
      --argumentsRealm.passwd.$(ADMIN_USER)=$(ADMIN_PASSWORD)
      --argumentsRealm.roles.$(ADMIN_USER)=admin
    Limits:
      cpu:     2
      memory:  4Gi
    Requests:
      cpu:      50m
      memory:   256Mi
    Liveness:   http-get http://:http/login delay=90s timeout=5s period=10s #success=1 #failure=5
    Readiness:  http-get http://:http/login delay=60s timeout=5s period=10s #success=1 #failure=3
    Environment:
      JAVA_OPTS:
      JENKINS_OPTS:
      JENKINS_SLAVE_AGENT_PORT:  50000
      ADMIN_PASSWORD:            <set to the key 'jenkins-admin-password' in secret 'jenkins'>  Optional: false
      ADMIN_USER:                <set to the key 'jenkins-admin-user' in secret 'jenkins'>      Optional: false
    Mounts:
      /tmp from tmp (rw)
      /usr/share/jenkins/ref/plugins/ from plugin-dir (rw)
      /usr/share/jenkins/ref/secrets/ from secrets-dir (rw)
      /var/jenkins_config from jenkins-config (ro)
      /var/jenkins_home from jenkins-home (rw)
  Volumes:
   plugins:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   tmp:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   jenkins-config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      jenkins
    Optional:  false
   plugin-dir:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   secrets-dir:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   jenkins-home:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  jenkins-pvc
    ReadOnly:   false
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      False   MinimumReplicasUnavailable
  Progressing    True    ReplicaSetUpdated
OldReplicaSets:  jenkins-86dcf94679 (1/1 replicas created)
NewReplicaSet:   <none>
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  42s   deployment-controller  Scaled up replica set jenkins-86dcf94679 to 1
-- gh4x
Source: StackOverflow