diff options
author | Jose A. Rivera <jarrpa@redhat.com> | 2018-02-12 08:56:35 -0600 |
---|---|---|
committer | Jose A. Rivera <jarrpa@redhat.com> | 2018-02-12 09:54:38 -0600 |
commit | 0101c000a6e1e944f98a037183d9f222ee9aeb13 (patch) | |
tree | e0782fe25a9809c7a9f156b97f57cebe53584df9 /roles | |
parent | b7cc4a8414f7aa51fab0898ec23cefa7717b62b2 (diff) | |
download | openshift-0101c000a6e1e944f98a037183d9f222ee9aeb13.tar.gz openshift-0101c000a6e1e944f98a037183d9f222ee9aeb13.tar.bz2 openshift-0101c000a6e1e944f98a037183d9f222ee9aeb13.tar.xz openshift-0101c000a6e1e944f98a037183d9f222ee9aeb13.zip |
Allow for blank StorageClass in PVC creation
In the case where a default StorageClass is already defined and a PV's
storage kind is not 'dynamic', allows for the storageClassName of the
associated PVC to be blank so as to not use the default SC.
Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Diffstat (limited to 'roles')
-rw-r--r-- | roles/lib_utils/action_plugins/generate_pv_pvcs_list.py | 8 | ||||
-rw-r--r-- | roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/roles/lib_utils/action_plugins/generate_pv_pvcs_list.py b/roles/lib_utils/action_plugins/generate_pv_pvcs_list.py index eb13a58ba..c60742dd3 100644 --- a/roles/lib_utils/action_plugins/generate_pv_pvcs_list.py +++ b/roles/lib_utils/action_plugins/generate_pv_pvcs_list.py @@ -118,10 +118,16 @@ class ActionModule(ActionBase): create_pvc = self._templar.template(create_pvc) if kind != 'object' and create_pv and create_pvc: volume, size, _, access_modes = self.build_common(varname=varname) + storageclass = self.task_vars.get(str(varname) + '_storageclass') + if storageclass: + storageclass = self._templar.template(storageclass) + elif storageclass is None and kind != 'dynamic': + storageclass = '' return dict( name="{0}-claim".format(volume), capacity=size, - access_modes=access_modes) + access_modes=access_modes, + storageclass=storageclass) return None def run(self, tmp=None, task_vars=None): diff --git a/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 b/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 index fac589a92..ca8b747ee 100644 --- a/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 +++ b/roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2 @@ -12,4 +12,7 @@ items: resources: requests: storage: "{{ claim.capacity }}" +{% if claim.storageclass is not None %} + storageClassName: "{{ claim.storageclass }}" +{% endif %} {% endfor %} |