Skip to content

Add 'oc set volume --sub-path' option, or equivalent. #16275

Closed
@GrahamDumpleton

Description

@GrahamDumpleton

There is no way from the command line using oc set volume, to say that you want to mount a sub path from a volume.

In other words, any option on 'oc set volume' which allows setting:

$ oc explain dc.spec.template.spec.containers.volumeMounts.subPath
FIELD: subPath <string>

DESCRIPTION:
    Path within the volume from which the container's volume should be mounted.
    Defaults to "" (volume's root).

when mounting the volume into a container.

One can specify a sub path through the web console, but not with the command line unless not interpreting the help messages properly.

Seems it would be useful to have a --sub-path option, or some other more descriptive option to serve this purpose.

This would avoid needing to manually edit resource definitions for the deployment configuration to add such a volume mount.

Version
oc v3.7.0-alpha.1+fdbd3dc
kubernetes v1.7.0+695f48a16f
features: Basic-Auth
Steps To Reproduce

Try and find option of oc set volume which gives the desired result.

Current Result

Can't seem to find such an option.

Expected Result

Would like to be able to do:

oc set volume dc/wordpress --add --name=data -t pvc --claim-size=1G --claim-name wordpress-data --mount-path /opt/app-root/src/wp-content --containers=wordpress --sub-path wordpress-content

oc set volume dc/wordpress --add --name=data --claim-name wordpress-data --mount-path /var/lib/mysql/data --containers=wordpress-1 --sub-path mysql-database --overwrite

The --overwrite is needed for the later command because otherwise it will complain that the --name option uses the same value. This is the same persistent volume claim though that I want to reference, so would be nice if it was a bit more intelligent and realised that and not complain, just reusing the existing definition.

Don't use --overwrite and get:

error: deploymentconfigs/wordpress volume 'data' already exists. Use --overwrite to replace

One has to use the same name because it appears that if you reference the same persistent volume claim more than once in a deployment config, from multiple volume definitions with different names, that OpenShift will fail to deploy anything.

Additional Information

The web console provides a way of specifying a sub path, but the command line doesn't provide an easy equivalent and forces you to edit resource definitions directly as YAML/JSON.

Although the web console provides a way of mounting from a sub path, it fails on not providing an equivalent for the --overwrite option. The result is you can't do what was wanted, mounting two different sub paths from one volume into two containers of same pod, from the web console either. See openshift/origin-web-console#2045

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions