charts: Fail when using existing claim for Artifactory
Is this a request for help?: no
Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT
Version of Helm and Kubernetes: Helm v2.8.2 - Kubernetes v1.10.1
Which chart: 7.4.2
What happened: Failed when using existing volume claim
What you expected to happen: It worked and used an existing claim
How to reproduce it (as minimally and precisely as possible): set existingClaim to a value
Anything else we need to know: The problem is in the /templates/artifactory-statefulset.yaml file. The accessModes and resources.requests.storage is not used when an existing claim is used, and kubernetes will fail the deployment. A volumeClaimTemplates needs these fields.
Instead the template part should look like this :
volumeClaimTemplates:
- metadata:
name: artifactory-volume
spec:
{{- if .Values.artifactory.persistence.existingClaim }}
selector:
matchLabels:
app: {{ template "artifactory.name" . }}
{{- else }}
{{- if .Values.artifactory.persistence.storageClass }}
{{- if (eq "-" .Values.artifactory.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.artifactory.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
accessModes: [ "{{ .Values.artifactory.persistence.accessMode }}" ]
resources:
requests:
storage: {{ .Values.artifactory.persistence.size }}
{{- else }}
- name: artifactory-volume
emptyDir: {}
{{- end }}
So that no matter if a claim is specified or not, accessMode and resource request storage is filled out.
Errors im getting before changing the template:
Statefulset failing:
Warning FailedCreate 2m (x12 over 2m) statefulset-controller create Pod artifactory-artifactory-0 in StatefulSet artifactory-artifactory failed error: Failed to create PVC artifactory-volume-artifactory-artifactory-0: PersistentVolumeClaim "artifactory-volume-artifactory-artifactory-0" is invalid: [spec.accessModes: Required value: at least 1 access mode is required, spec.resources[storage]: Required value]
Warning FailedCreate 2m (x13 over 2m) statefulset-controller create Claim artifactory-volume-artifactory-artifactory-0 for Pod artifactory-artifactory-0 in StatefulSet artifactory-artifactory failed error: PersistentVolumeClaim "artifactory-volume-artifactory-artifactory-0" is invalid: [spec.accessModes: Required value: at least 1 access mode is required, spec.resources[storage]: Required value]
Warning FailedCreate 1s (x11 over 7s) statefulset-controller create Claim artifactory-volume-artifactory-artifactory-0 for Pod artifactory-artifactory-0 in StatefulSet artifactory-artifactory failed error: PersistentVolumeClaim "artifactory-volume-artifactory-artifactory-0" is invalid: spec.resources[storage]: Required value
Warning FailedCreate 1s (x11 over 7s) statefulset-controller create Pod artifactory-artifactory-0 in StatefulSet artifactory-artifactory failed error: Failed to create PVC artifactory-volume-artifactory-artifactory-0: PersistentVolumeClaim "artifactory-volume-artifactory-artifactory-0" is invalid: spec.resources[storage]: Required value
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 20 (6 by maintainers)
@jainishshah17
Hi,
I haven’t tried it, but i just had a quick look at it.
In the Helm install command you use
--set postgresql.persistence.existingClaim=artifactory-database-pvcand have a PVC with the nameartifactory-data-pvc. They dont match.But. The helm chart doesnt try to find a PVC by name, but with a label
app: artifactory. Thats hard coded into the chart.That means, that no matter what i write in existingClaim, it will use that label selection.
I, as a user, have no control over which PVC it chooses if i have multible PVC’ with that one label.
And, as i stated in my initial post, if you choose to use existingClaim, it forgets to add resources and storageclass. And then the deployment breaks.
So, the name existingClaim is misleading and it doesnt work yet. And there are better ways to do it, as i have pointed out. Like using labels defined by the user, and not call it existingClaim.
getting same issue here. I think the common way to dealing with existing claim is like this
Thanks for the reply @hoeghh.
I did notice this as well, after I played with it and looked through the template. I did make a PVC with the label “app: artifactory”, and despite that it still didn’t use the existing one. I’m still curious if making a volumeClaimTemplate actually allows you to specify an old PVC using a selector or if it will allows create something. My workaround was similar to yours listed above, but I went at it from a slightly different angle. This is what I came up with:
In the volumes definition of spec, I added:
And then my volumeClaimTemplates looked like this:
So existingClaim gets passed in as the name of the claim like you said above, but it attaches it in the volume block instead of dealing with the volumeClaimTemplate. When existingClaim doesn’t exist, it will make a new volume with the other values.
@hoeghh I tried out your template change from your original comment, and while it no longer fails the deployment, it seems like the statefulset tries to make its own volume claim instead (ignoring my existing claim). Are you seeing that behavior?
Hi @jainishshah17 ,
sorry for the delay.
So, with other charts when they have an “existingClaim”, what is expected from the user, is to provide the name of an already existing volume claim. Like Jenkins here :
But this claim will take the value of existingClaim and use it to match a label with a key “app” as seen here :
I think its fine that you as a user can define labels. But i would then wish it was done like here :
So the user can give both the key and value, and as many as they need like here :
But, for now, it would be great if the chart would work at all, when specifying an “existingClaim”.
The problem is that when you specify an “existingClaim”, it will not add accessModes or resources elements, and it will fail.
If you use the helm code in my first post, it will add these for both an existingclaim AND if you dont.
Hope it makes sense.