Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1367200 - RFE: SUPPORTABILITY: oc run should have capability to mount storage.
Summary: RFE: SUPPORTABILITY: oc run should have capability to mount storage.
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: RFE
Version: 3.2.1
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: ---
Assignee: Andy Goldstein
QA Contact: Johnny Liu
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-15 20:29 UTC by Eric Rich
Modified: 2016-08-17 15:09 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-08-17 15:09:26 UTC


Attachments (Terms of Use)

Description Eric Rich 2016-08-15 20:29:40 UTC
Description of problem:

Support would like the ability to mount a tools container to use tools packages for testing various scenarios.

> oc run --restart=Never --attach --stdin --tty --image registry.access.redhat.com/rhel7/rhel-tools rhel-tools bash

However we are limited in what we can test with storage, using this method, because `oc run` can not mount a PV or PVC.

Comment 2 Andy Goldstein 2016-08-16 18:45:51 UTC
We have 'oc volume' which you can use after you run 'oc run' - is that not sufficient?

Comment 3 Eric Rich 2016-08-16 18:54:26 UTC
(In reply to Andy Goldstein from comment #2)
> We have 'oc volume' which you can use after you run 'oc run' - is that not
> sufficient?

So: 

> oc run --restart=Never --attach --stdin --tty --image registry.access.redhat.com/rhel7/rhel-tools rhel-tools bash
> oc volume pod/rhel-tools --add --name=v1 -m /data --overwrite

Let me try this and report back.

Comment 4 Eric Rich 2016-08-17 13:40:43 UTC
In testing this, I saw the following errors. 

error: may not update volume in pod "rhel-tools" directly

> This seemed to be caused because the pod was not yet deployed. 

error: Pod "rhel-tools" is invalid: spec: Forbidden: pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds`

> After the pod deployed, I saw the following. 

---------

> oc run --restart=Never --attach --stdin --tty --image registry.access.redhat.com/rhel7/rhel-tools rhel-tools bash
> oc volume pod/rhel-tools --add --name=v1 -m /data --overwrite

So this solution does not work.

Comment 5 Andy Goldstein 2016-08-17 13:42:12 UTC
You can't modify much of a pod once it's created. But you can modify DeploymentConfigs. How about that?

Comment 6 Eric Rich 2016-08-17 13:44:28 UTC
(In reply to Andy Goldstein from comment #5)
> You can't modify much of a pod once it's created. But you can modify
> DeploymentConfigs. How about that?

We don't have a DC as the pod is created with `oc run`

Comment 7 Andy Goldstein 2016-08-17 13:52:29 UTC
oc run --generator=deploymentconfig/v1 ..., or don't set --restart to Never.

What flags would you want if we add this to kubectl run? The 'oc volume' options that are related to adding a volume are:

--type (emptyDir, hostPath, secret, configmap, persistentVolumeClaim)
--mount-path (where to mount inside the container)
--path (for hostPath only, the path on the host to bind mount in to the container)
--secret-name
--configmap-name
--claim-mode
--claim-name (required when type=persistentVolumeClaim)
--claim-size
--containers (which containers should get the volume mount)
--name (volume name; autogenerated if not specified)
--source (raw json if you need to use a different volume type or set options that the oc volume command can't currently set)

As you can see, there are a lot, and we'd need to name them appropriately so it's very clear that they're all related to specifying a volume.

Comment 8 Eric Rich 2016-08-17 15:09:26 UTC
I was able to get the following working for my needs: 

> oc run --generator=deploymentconfig/v1 --attach --stdin --tty --image registry.access.redhat.com/rhel7/rhel-tools rhel-tools bash

> oc create -f pvc.yaml

~~~
apiVersion: v1
kind: PersistentVolume
metadata:
  name: testpv
spec:
  capacity:
    storage: 512Mi
  accessModes:
  - ReadWriteOnce 
  nfs: 
    path: /path/to/share
    server: nfs.example.com
  persistentVolumeReclaimPolicy: Recycle 
~~~

> oc create -f pvc.yaml

~~~
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: testclaim
spec:
  accessModes:
    - ReadWriteOnce 
  resources:
    requests:
      storage: 512Mi
~~~

> oc volume dc/rhel-tools --add --name=v1 -t pvc --claim-name=testclaim --mount-path=/tmp/ --overwrite


Note You need to log in before you can comment on or make changes to this bug.