Bugfixes for Local Volume Provisioner

- Fixed an issue where storage class host directories were looped
through excessive target hosts
- Fixes examples in the LVP `README.md` to use nested dicts instead of a
list of dicts
pull/4009/head
Chad Swenson 2019-01-08 17:32:39 -06:00
parent 4fb8adb9e4
commit 72802e4d8d
5 changed files with 40 additions and 41 deletions

View File

@ -21,10 +21,10 @@ metrics_server_enabled: false
local_volume_provisioner_enabled: false local_volume_provisioner_enabled: false
# local_volume_provisioner_namespace: kube-system # local_volume_provisioner_namespace: kube-system
# local_volume_provisioner_storage_classes: # local_volume_provisioner_storage_classes:
# - local-storage: # local-storage:
# host_dir: /mnt/disks # host_dir: /mnt/disks
# mount_dir: /mnt/disks # mount_dir: /mnt/disks
# - fast-disks: # fast-disks:
# host_dir: /mnt/fast-disks # host_dir: /mnt/fast-disks
# mount_dir: /mnt/fast-disks # mount_dir: /mnt/fast-disks
# block_cleaner_command: # block_cleaner_command:

View File

@ -5,15 +5,15 @@ The [local storage provisioner](https://github.com/kubernetes-incubator/external
is NOT a dynamic storage provisioner as you would is NOT a dynamic storage provisioner as you would
expect from a cloud provider. Instead, it simply creates PersistentVolumes for expect from a cloud provider. Instead, it simply creates PersistentVolumes for
all mounts under the host_dir of the specified storage class. all mounts under the host_dir of the specified storage class.
These storage classes are specified in the `local_volume_provisioner_storage_classes` list. These storage classes are specified in the `local_volume_provisioner_storage_classes` nested dictionary.
An example this list: Example:
```yaml ```yaml
local_volume_provisioner_storage_classes: local_volume_provisioner_storage_classes:
- local-storage: local-storage:
host_dir: /mnt/disks host_dir: /mnt/disks
mount_dir: /mnt/disks mount_dir: /mnt/disks
- fast-disks: fast-disks:
host_dir: /mnt/fast-disks host_dir: /mnt/fast-disks
mount_dir: /mnt/fast-disks mount_dir: /mnt/fast-disks
block_cleaner_command: block_cleaner_command:
@ -23,8 +23,8 @@ local_volume_provisioner_storage_classes:
fs_type: ext4 fs_type: ext4
``` ```
For each dictionary in `local_volume_provisioner_storage_classes` a storageClass with the For each key in `local_volume_provisioner_storage_classes` a storageClass with the
same name is created. The keys of this dictionary are converted to camelCase and added same name is created. The subkeys of each storage class are converted to camelCase and added
as attributes to the storageClass. as attributes to the storageClass.
The result of the above example is: The result of the above example is:

View File

@ -10,7 +10,6 @@
with_nested: with_nested:
- "{{ groups['k8s-cluster'] }}" - "{{ groups['k8s-cluster'] }}"
- "{{ local_volume_provisioner_storage_classes.keys() }}" - "{{ local_volume_provisioner_storage_classes.keys() }}"
failed_when: false
- name: Local Volume Provisioner | Create addon dir - name: Local Volume Provisioner | Create addon dir
file: file:

View File

@ -1,7 +1,9 @@
--- ---
dependencies: dependencies:
- role: kubernetes-apps/external_provisioner/local_volume_provisioner - role: kubernetes-apps/external_provisioner/local_volume_provisioner
when: local_volume_provisioner_enabled when:
- local_volume_provisioner_enabled
- inventory_hostname == groups['kube-master'][0]
tags: tags:
- apps - apps
- local-volume-provisioner - local-volume-provisioner

View File

@ -47,14 +47,12 @@
- name: Create local volume provisioner directories - name: Create local volume provisioner directories
file: file:
path: "{{ local_volume_provisioner_storage_classes[item.1].host_dir }}" path: "{{ local_volume_provisioner_storage_classes[item].host_dir }}"
state: directory state: directory
owner: root owner: root
group: root group: root
mode: 0700 mode: 0700
with_nested: with_items: "{{ local_volume_provisioner_storage_classes.keys() }}"
- "{{ groups['k8s-cluster'] }}"
- "{{ local_volume_provisioner_storage_classes.keys() }}"
when: when:
- inventory_hostname in groups['k8s-cluster'] - inventory_hostname in groups['k8s-cluster']
- local_volume_provisioner_enabled - local_volume_provisioner_enabled