bjw-s / helm-charts

A collection of Helm charts
https://bjw-s.github.io/helm-charts/
Apache License 2.0
580 stars 106 forks source link

Unable to mount hostPaths to a different path in the container #277

Closed lkshrk closed 6 months ago

lkshrk commented 7 months ago

Details

What steps did you take and what happened:

values.yaml:

prowlarr:
  env:
    TZ: Europe/Berlin
  envFrom:
  - configMapRef:
      name: prowlarr-config
  persistence:
    config:
      enabled: true
      type: hostPath
      hostPath: /mnt/config/arr/prowlarr
      hostPathType: Directory
      globalMounts:
      - path: /config

extract from the pod definition:

volumeMounts:
    - mountPath: /mnt/config/arr/prowlarr
      name: config
...
volumes:
  - hostPath:
      path: /mnt/config/arr/prowlarr
      type: Directory
    name: config

What did you expect to happen:

I would expect the hostPath /mnt/config/arr/prowlarr to be mounted under /config, instead it's mounted under /mnt/config/arr/prowlarr

Anything else you would like to add:

version: ghcr.io/onedr0p/prowlarr-develop:1.14.0.4286

Additional Information:

bjw-s commented 7 months ago

Thanks for raising the issue. Which version of the chart are you using, as I haven't really been able to reproduce this. There is even an explicit test present for this scenario: https://github.com/bjw-s/helm-charts/blob/main/charts/library/common-test/tests/container/volumemounts_test.yaml#L163-L181 so I'm kinda stumped 🤔

TheDarkula commented 6 months ago

I am not sure if this is related, but using version 3.0.2 of the app-template seems to have an issue with hostPath storage.

I have the following block:

persistence:
  config:
    enabled: true
    type: hostPath
    hostPath: /path/on/host
    accessMode: ReadWriteOnce
    size: 1Gi
    retain: true
    advancedMounts:
      main:
        main:
          - path: /path/in/container

Which gives these errors:

- persistence.config: Must validate one and only one schema (oneOf)
- persistence.config: Additional property hostPath is not allowed
- persistence.config.type: persistence.config.type does not match: "persistentVolumeClaim"
haraldkoch commented 6 months ago

For a working example of hostPath with 3.0.2 check out https://github.com/haraldkoch/kochhaus-home/blob/5163ab787270a2713e7ee847cb239f896c05c6a3/kubernetes/main/apps/home/zigbee2mqtt/app/helmrelease.yaml#L129

JuniorJPDJ commented 6 months ago

Probably accessMode: ReadWriteOnce shouldn't be here for hostPath type.

TheDarkula commented 6 months ago

@haraldkoch I had a look, but other than the asterisks, that looks to be the same formatting as what I have. Am I missing something?

TheDarkula commented 6 months ago

@JuniorJPDJ I just tried omitting it, and it is required:

- persistence.config: accessMode is required
bjw-s commented 6 months ago

I am not sure if this is related, but using version 3.0.2 of the app-template seems to have an issue with hostPath storage.

I have the following block:

persistence:
  config:
    enabled: true
    type: hostPath
    hostPath: /path/on/host
    accessMode: ReadWriteOnce
    size: 1Gi
    retain: true
    advancedMounts:
      main:
        main:
          - path: /path/in/container

Your persistence item has a number of fields that are unsupported for hostPath type mounts:

TheDarkula commented 6 months ago

Wonderful, thank you! Is there a readme/changelog somewhere that I can read to keep up with breaking changes like these?

Also, under ingress, I noticed that if I use the identifier tag, everything functions properly. Previously, I used the name tag, which now breaks traefik ingress.

p4block commented 1 month ago

Hostpath mounts behave differently than the others, just like in k8s itself we get the same path inside and outside the container.

However, other items under persistence: that are not hostpath in this chart automatically get mounted to a directory named after the key:, which I thought was inconsistent. Maybe in the future it would be possible for hostpath volumes to get automatically mounted to the volume /name like the others?