Merge pull request #22575 from MikaelCluseau/wip-issue-20466
Automatic merge from submit-queue Add subPath to mount a child dir or file of a volumeMount Allow users to specify a subPath in Container.volumeMounts so they can use a single volume for many mounts instead of creating many volumes. For instance, a user can now use a single PersistentVolume to store the Mysql database and the document root of an Apache server of a LAMP stack pod by mapping them to different subPaths in this single volume. Also solves https://github.com/kubernetes/kubernetes/issues/20466.
This commit is contained in:
@@ -1213,6 +1213,10 @@ func TestValidateVolumeMounts(t *testing.T) {
|
||||
{Name: "abc", MountPath: "/foo"},
|
||||
{Name: "123", MountPath: "/bar"},
|
||||
{Name: "abc-123", MountPath: "/baz"},
|
||||
{Name: "abc-123", MountPath: "/baa", SubPath: ""},
|
||||
{Name: "abc-123", MountPath: "/bab", SubPath: "baz"},
|
||||
{Name: "abc-123", MountPath: "/bac", SubPath: ".baz"},
|
||||
{Name: "abc-123", MountPath: "/bad", SubPath: "..baz"},
|
||||
}
|
||||
if errs := validateVolumeMounts(successCase, volumes, field.NewPath("field")); len(errs) != 0 {
|
||||
t.Errorf("expected success: %v", errs)
|
||||
@@ -1224,6 +1228,10 @@ func TestValidateVolumeMounts(t *testing.T) {
|
||||
"empty mountpath": {{Name: "abc", MountPath: ""}},
|
||||
"colon mountpath": {{Name: "abc", MountPath: "foo:bar"}},
|
||||
"mountpath collision": {{Name: "foo", MountPath: "/path/a"}, {Name: "bar", MountPath: "/path/a"}},
|
||||
"absolute subpath": {{Name: "abc", MountPath: "/bar", SubPath: "/baz"}},
|
||||
"subpath in ..": {{Name: "abc", MountPath: "/bar", SubPath: "../baz"}},
|
||||
"subpath contains ..": {{Name: "abc", MountPath: "/bar", SubPath: "baz/../bat"}},
|
||||
"subpath ends in ..": {{Name: "abc", MountPath: "/bar", SubPath: "./.."}},
|
||||
}
|
||||
for k, v := range errorCases {
|
||||
if errs := validateVolumeMounts(v, volumes, field.NewPath("field")); len(errs) == 0 {
|
||||
|
Reference in New Issue
Block a user