Im trying to create a step in my Jenkins pipeline wherein I would like to determine if a volume is already existing, if it is not existing then i will issue an oc set volume dc/mydeployment-config ... command, if its already existing then i will just use the --overwrite option.
I'm looking at jsonpath to determine if the expected name of my volume is already there, here is what i have right now.
$.spec.template.spec.volumes[?(@.name == 'mydeployment-volume')].name
I also tried this
oc set volume dc/mydeployment-config -o jsonpath={'$.spec.template.spec.volumes[?(@.name == 'mydeployment-volume')].name'}
The error was
error: --list and --output may not be specified together
Can anyone nudge me in the right direction to determine the correct
oc set volume
command to use? Or if there is a better way to do this?
To find volumes attached to a DeploymentConfig, you should be using oc get dc
, so something like
oc get dc/mydeployment-config -o jsonpath={'$.spec.template.spec.volumes[?(@.name == 'mydeployment-volume')].name'}
should show you if your volume is already attached to this DeploymentConfig.
If you simply just want to see the volumes that already exist, you can run
oc get pv
to see all the persistent volumes created.