-
Notifications
You must be signed in to change notification settings - Fork 39.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
volumes/hostPath: Proposal - support for more explicitly specified hostPath volumes #31384
Comments
Related: #16888 |
SGTM overall - the subPath point is interesting. Would like to see more On Wed, Aug 24, 2016 at 3:49 PM, Euan Kemp [email protected] wrote:
|
cc @bgrant0607 |
I think what makes it confusing is that I think it would have been cleaner to implement it as its own type of volume for consistency... and it also would make this change easier to model for it. What I wish subPath were is the following: spec:
containers:
- name: example
volumeMounts:
- name: dbus
mountPath: /var/run/dbus/
- name: dockersock
mountPath: /var/run/docker.sock
volumes:
- name: var-run
hostPath:
path: /var/run
type: directory
- name: dbus
subPath:
parent: var-run
subPath: dbus # or maybe just 'path'
type: directory
- name: dockersock
subPath:
parent: var-run
subPath: docker.sock
type: socket However, keeping a happy backwards compatible api is more important, and I wouldn't want two different ways to do subPaths so the above isn't useful for this discussion other than framing why this feels so odd in the first place. Without further ado: The pros for putting them as an attribute of Volume source vs Volume mountImportant things are starred Pros (of HostPathVolumeSource attribute)
Cons (vs VolumeMount attribute)
These lists are pretty short, but I think the pros are important. Especially the ability to explicitly attach these as part of specify subPath too vs no optionHowever, that leaves the question of what to do for subPath. I propose that we add one additional subPath option, I think the other sane option is to simply not allow subPaths to tweak this option at all. Pros (of allowing specification)
Cons (vs not allowing)
split shouldCreate + type, or just typeOne final pro-con split. In the original comment, I specified I'm leaning towards having just Pros (of having both)
Cons (vs just type)
ConclusionI'll toss in an opinion that we should toss on |
Thanks for writing this up; basically +1 on your conclusion on both sides. |
I won't have time to review this for a couple of days, but the write up looks very thorough, thanks for the attention to detail. |
A gentle ping @pmorie. I'd like to know what the right next step should be for this. Perhaps distill this into a proper |
@euank I think a proposal PR is definitely the right way to go. I'm having a little trouble parsing your conclusion - can you clarify? |
I'm SGTM on the HostPathVolumeSource change, and the single field model I'm ambivalent about the subPath part. Is it a real pain point or On Tue, Sep 6, 2016 at 11:12 AM, Paul Morie [email protected]
|
I didn't get around to making a proposal for this and I'm heading off on two weeks vacation, so if anyone else wants to pick it up, please feel free! If no one does, I'll turn it into a real proposal when I get back. |
Discussion should happen in #34058 |
Automatic merge from submit-queue proposals: Add Volume Hostpath "type" proposal This is a continuation of #31384. It's related to #26816 as well. The discussion in #31384 is worth reading and this proposal largely derives from my comments there. cc @thockin @pmorie @saad-ali @kubernetes/sig-storage cc @yujuhong since it talks briefly about kubelet doing more cc @calebamiles I think we might need a "Feature" for this since it's an api change, though a minor one?
Automatic merge from submit-queue proposals: Add Volume Hostpath "type" proposal This is a continuation of kubernetes#31384. It's related to kubernetes#26816 as well. The discussion in kubernetes#31384 is worth reading and this proposal largely derives from my comments there. cc @thockin @pmorie @saad-ali @kubernetes/sig-storage cc @yujuhong since it talks briefly about kubelet doing more cc @calebamiles I think we might need a "Feature" for this since it's an api change, though a minor one?
Could you please inform if the hostPath type attribute has been added to kubernetes? If so, in which version? |
Note: I'm happy to write a more formal proposal out, I just wanted to quickly float the idea and see if it makes any sense to have.
Introduction
A hostPath volume source is probably the simplest one to define, needing only a single path. However, that simplicity comes with many assumptions and caveats.
Right now, the largest caveat with a hostPath volume under Docker is that the given target will be created as an empty directory owned by root if it does not already exist. This is rarely what the user actually wants because hostPath volumes are typically used to express a dependency on an existing external file or directory.
To copy from a different comment: hostPath volumes have the following uses:
Hostpath use-cases
Proposed API change
I propose that the
v1.HostPathVolumeSource
be changed to include the following field:type
- optional string ofauto|exists|file|device|socket|directory
- If not set, defaults toauto
, whereby any existing path will be accepted, and non-existent paths be created as new directories If set to a given value, something of the given type must be present at that path. If there is nothing present, or it is not of the specified type, the pod will fail to run.Note: For the default case, the presence or absence of the given path is resolved at container-runtime for any container that references the given path. For the other cases, it is resolved when the pod is placed prior to any containers being run.
Reason for change
In the first use-case above, creating the nonexistent thing is not a desirable action and can end up breaking things (aside, docker once had a bug where it created the
docker.sock
after starting old containers, so any restart=always containers bindmounting thedocker.sock
would create a directory there and crashloop the daemon).In the second and third use-cases, you do want the directory created. I think the first use-case is, however, the most common one.
Because Kubernetes runs across many machines and should value correctness, I propose that the
hostPath
volume should allow a user to specify additional expectations about what already exists, or does not, at that path such that it can fail quickly if those assumptions are not met, rather than mutate the host filesystem.This ensures that a host that is in an odd state (e.g. with some socket not existing that should) does not end up in a worse state, and also allows a pod to more clearly express the dependency it has such that an operator who accidentally runs it on a system it is not suited for can see quickly and clearly what went wrong.
Other considerations
the
subPath
feature is also relevant because it is a way in which one can reference directories which might-or-might not exist within a volume as well. One possible way to resolve both hostPath and subPath at the same time would be making my above proposed api-changes attributes of the reference within the container, not the volume source outside of it. I think that having the attribute of the volume on the host attached to the source is neater and makes more logical sense however, so I'd prefer keeping it there. Other solutions are to simply assume subPaths should always be created, or to duplicate these options for subPath as well. Opinions welcome!The examples folder contains many examples of pods where this feature would be useful. For example:
/boot
does not exist or/var/run/docker.sock
is at an alternate location, this should fail to run and the operator should edit the pod, not clobber the host/etc/ssl/certs
is not present (e.g. on/etc/pki/
distros) it should not be created, it should be an errordocker.sock
referenceOpinions on whether this increase in expressiveness is worth the increased API surface area. I think it is, but second opinions would be much appreciated.
cc @kubernetes/sig-storage @thockin @jonboulle
The text was updated successfully, but these errors were encountered: