From 9225c4ad1e8820c6df74c5a14ab7c090dc8b3576 Mon Sep 17 00:00:00 2001 From: David Moreau-Simard Date: Fri, 3 Nov 2017 17:46:56 -0400 Subject: [PATCH] Add support for hostpath persistent volume definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hostpath volumes [1] mount a file or directory from the host node’s filesystem into a pod. This adds support for declaring a hostPath volume as a persistent volume and do a persistent volume claim for one for the hosted registry. [1]: https://kubernetes.io/docs/concepts/storage/volumes/#hostpath --- filter_plugins/oo_filters.py | 19 +++++++++++++++++++ roles/openshift_hosted/tasks/registry.yml | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index f9564499d88..35b1b38bf2b 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -802,6 +802,25 @@ def oo_component_persistent_volumes(hostvars, groups, component, subcomponent=No path=path, readOnly=read_only))) + elif kind == 'hostpath': + volume = params['volume']['name'] + size = params['volume']['size'] + if 'labels' in params: + labels = params['labels'] + else: + labels = dict() + access_modes = params['access']['modes'] + path = params['hostpath']['path'] + persistent_volume = dict( + name="{0}-volume".format(volume), + capacity=size, + labels=labels, + access_modes=access_modes, + storage=dict( + hostPath=dict( + path=path, + ))) + elif not (kind == 'object' or kind == 'dynamic'): msg = "|failed invalid storage kind '{0}' for component '{1}'".format( kind, diff --git a/roles/openshift_hosted/tasks/registry.yml b/roles/openshift_hosted/tasks/registry.yml index f1aa9c5a8d0..4ed68d75400 100644 --- a/roles/openshift_hosted/tasks/registry.yml +++ b/roles/openshift_hosted/tasks/registry.yml @@ -110,7 +110,7 @@ type: persistentVolumeClaim claim_name: "{{ openshift.hosted.registry.storage.volume.name }}-claim" when: - - openshift.hosted.registry.storage.kind | default(none) in ['nfs', 'openstack', 'glusterfs'] + - openshift.hosted.registry.storage.kind | default(none) in ['nfs', 'openstack', 'glusterfs', 'hostpath'] - name: Create OpenShift registry oc_adm_registry: