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

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

Closed
GrahamDumpleton opened this Issue Sep 11, 2017 · 1 comment

Comments

Projects
None yet
4 participants
@GrahamDumpleton

GrahamDumpleton commented Sep 11, 2017

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

@juanvallejo

This comment has been minimized.

Show comment
Hide comment
@juanvallejo

juanvallejo Sep 20, 2017

Member

Opened PR to add sub-path option here.

As for the --overwrite case, any time you update a volumeMount, you are asking to
overwrite existing volumeMount with a newly updated one
(if it already exists).
It is better to leave this as an explicit user action.

Member

juanvallejo commented Sep 20, 2017

Opened PR to add sub-path option here.

As for the --overwrite case, any time you update a volumeMount, you are asking to
overwrite existing volumeMount with a newly updated one
(if it already exists).
It is better to leave this as an explicit user action.

openshift-merge-robot added a commit that referenced this issue Oct 5, 2017

Merge pull request #16459 from juanvallejo/jvallejo/add-sub-path-opt-…
…oc-set-volume

Automatic merge from submit-queue (batch tested with PRs 16545, 16684, 16643, 16459, 16682).

add --sub-path opt to set-volume cmd

Fixes #16275

Adds a `--sub-path` option to `oc set volume ...`.
Updates command to match web-console functionality.

cc @openshift/cli-review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment