Support multiple local volume provisioner StorageClasses (#3450)
- Local Volume StorageClass configuration is now manged by `local_volume_provisioner_storage_classes`, a list of maps that specifies local storage classes with `name` `host_dir` and `mount_dir` keys per entry - Tasks and templates updated to loop through local volume storage classes - Previous defaults for path/class names were not changed - Fixed an issue where a `kubernetes/preinstall` was creating directories inconsistently with the `kubernetes-apps/external_provisioner/local_volume_provisioner` task
This commit is contained in:
parent
9232261665
commit
6602760a48
12 changed files with 66 additions and 35 deletions
|
@ -14,9 +14,19 @@ registry_enabled: false
|
||||||
# Local volume provisioner deployment
|
# Local volume provisioner deployment
|
||||||
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_base_dir: /mnt/disks
|
# local_volume_provisioner_storage_classes:
|
||||||
# local_volume_provisioner_mount_dir: /mnt/disks
|
# - name: "{{ local_volume_provisioner_storage_class | default('local-storage') }}"
|
||||||
# local_volume_provisioner_storage_class: local-storage
|
# host_dir: "{{ local_volume_provisioner_base_dir | default ('/mnt/disks') }}"
|
||||||
|
# mount_dir: "{{ local_volume_provisioner_mount_dir | default('/mnt/disks') }}"
|
||||||
|
# - name: "local-ssd"
|
||||||
|
# host_dir: "/mnt/local-storage/ssd"
|
||||||
|
# mount_dir: "/mnt/local-storage/ssd"
|
||||||
|
# - name: "local-hdd"
|
||||||
|
# host_dir: "/mnt/local-storage/hdd"
|
||||||
|
# mount_dir: "/mnt/local-storage/hdd"
|
||||||
|
# - name: "local-shared"
|
||||||
|
# host_dir: "/mnt/local-storage/shared"
|
||||||
|
# mount_dir: "/mnt/local-storage/shared"
|
||||||
|
|
||||||
# CephFS provisioner deployment
|
# CephFS provisioner deployment
|
||||||
cephfs_provisioner_enabled: false
|
cephfs_provisioner_enabled: false
|
||||||
|
|
|
@ -3,7 +3,7 @@ Local Storage Provisioner
|
||||||
|
|
||||||
The local storage provisioner is NOT a dynamic storage provisioner as you would
|
The local storage provisioner 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 manually created volumes located in the directory `local_volume_provisioner_base_dir`.
|
all manually created volumes located in the directories specified in the `local_volume_provisioner_storage_classes.host_dir` entries.
|
||||||
The default path is /mnt/disks and the rest of this doc will use that path as
|
The default path is /mnt/disks and the rest of this doc will use that path as
|
||||||
an example.
|
an example.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
local_volume_provisioner_namespace: "kube-system"
|
local_volume_provisioner_namespace: "kube-system"
|
||||||
local_volume_provisioner_base_dir: /mnt/disks
|
local_volume_provisioner_storage_classes:
|
||||||
local_volume_provisioner_mount_dir: /mnt/disks
|
- name: "{{ local_volume_provisioner_storage_class | default('local-storage') }}"
|
||||||
local_volume_provisioner_storage_class: local-storage
|
host_dir: "{{ local_volume_provisioner_base_dir | default ('/mnt/disks') }}"
|
||||||
|
mount_dir: "{{ local_volume_provisioner_mount_dir | default('/mnt/disks') }}"
|
|
@ -2,13 +2,15 @@
|
||||||
|
|
||||||
- name: Local Volume Provisioner | Ensure base dir is created on all hosts
|
- name: Local Volume Provisioner | Ensure base dir is created on all hosts
|
||||||
file:
|
file:
|
||||||
path: "{{ local_volume_provisioner_base_dir }}"
|
path: "{{ item[1].host_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0700
|
mode: 0700
|
||||||
delegate_to: "{{ item }}"
|
delegate_to: "{{ item[0] }}"
|
||||||
with_items: "{{ groups['k8s-cluster'] }}"
|
with_nested:
|
||||||
|
- "{{ groups['k8s-cluster'] }}"
|
||||||
|
- "{{ local_volume_provisioner_storage_classes }}"
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
- name: Local Volume Provisioner | Create addon dir
|
- name: Local Volume Provisioner | Create addon dir
|
||||||
|
|
|
@ -6,6 +6,8 @@ metadata:
|
||||||
namespace: {{ local_volume_provisioner_namespace }}
|
namespace: {{ local_volume_provisioner_namespace }}
|
||||||
data:
|
data:
|
||||||
storageClassMap: |
|
storageClassMap: |
|
||||||
{{ local_volume_provisioner_storage_class }}:
|
{% for class in local_volume_provisioner_storage_classes %}
|
||||||
hostDir: {{ local_volume_provisioner_base_dir }}
|
{{ class.name }}:
|
||||||
mountDir: {{ local_volume_provisioner_mount_dir }}
|
hostDir: {{ class.host_dir }}
|
||||||
|
mountDir: {{ class.mount_dir }}
|
||||||
|
{% endfor %}
|
|
@ -44,13 +44,17 @@ spec:
|
||||||
- name: local-volume-provisioner
|
- name: local-volume-provisioner
|
||||||
mountPath: /etc/provisioner/config
|
mountPath: /etc/provisioner/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: local-volume-provisioner-hostpath-mnt-disks
|
{% for class in local_volume_provisioner_storage_classes %}
|
||||||
mountPath: {{ local_volume_provisioner_mount_dir }}
|
- name: {{ class.name }}
|
||||||
|
mountPath: {{ class.mount_dir }}
|
||||||
mountPropagation: "HostToContainer"
|
mountPropagation: "HostToContainer"
|
||||||
|
{% endfor %}
|
||||||
volumes:
|
volumes:
|
||||||
- name: local-volume-provisioner
|
- name: local-volume-provisioner
|
||||||
configMap:
|
configMap:
|
||||||
name: local-volume-provisioner
|
name: local-volume-provisioner
|
||||||
- name: local-volume-provisioner-hostpath-mnt-disks
|
{% for class in local_volume_provisioner_storage_classes %}
|
||||||
|
- name: {{ class.name }}
|
||||||
hostPath:
|
hostPath:
|
||||||
path: {{ local_volume_provisioner_base_dir }}
|
path: {{ class.host_dir }}
|
||||||
|
{% endfor %}
|
||||||
|
|
|
@ -25,8 +25,10 @@ spec:
|
||||||
- 'downwardAPI'
|
- 'downwardAPI'
|
||||||
- 'hostPath'
|
- 'hostPath'
|
||||||
allowedHostPaths:
|
allowedHostPaths:
|
||||||
- pathPrefix: "{{ local_volume_provisioner_base_dir }}"
|
{% for class in local_volume_provisioner_storage_classes %}
|
||||||
|
- pathPrefix: "{{ class.host_dir }}"
|
||||||
readOnly: false
|
readOnly: false
|
||||||
|
{% endfor %}
|
||||||
hostNetwork: false
|
hostNetwork: false
|
||||||
hostIPC: false
|
hostIPC: false
|
||||||
hostPID: false
|
hostPID: false
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
{% for class in local_volume_provisioner_storage_classes %}
|
||||||
---
|
---
|
||||||
apiVersion: storage.k8s.io/v1
|
apiVersion: storage.k8s.io/v1
|
||||||
kind: StorageClass
|
kind: StorageClass
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ local_volume_provisioner_storage_class }}
|
name: {{ class.name }}
|
||||||
provisioner: kubernetes.io/no-provisioner
|
provisioner: kubernetes.io/no-provisioner
|
||||||
volumeBindingMode: WaitForFirstConsumer
|
volumeBindingMode: WaitForFirstConsumer
|
||||||
|
{% endfor %}
|
|
@ -31,8 +31,10 @@
|
||||||
-v {{ kubelet_flexvolumes_plugins_dir }}:{{ kubelet_flexvolumes_plugins_dir }}:rw \
|
-v {{ kubelet_flexvolumes_plugins_dir }}:{{ kubelet_flexvolumes_plugins_dir }}:rw \
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% if local_volume_provisioner_enabled -%}
|
{% if local_volume_provisioner_enabled -%}
|
||||||
-v {{ local_volume_provisioner_base_dir }}:{{ local_volume_provisioner_base_dir }}:rw \
|
{% for class in local_volume_provisioner_storage_classes -%}
|
||||||
-v {{ local_volume_provisioner_mount_dir }}:{{ local_volume_provisioner_mount_dir }}:rw \
|
-v {{ class.host_dir }}:{{ class.host_dir }}:rw \
|
||||||
|
-v {{ class.mount_dir }}:{{ class.mount_dir }}:rw \
|
||||||
|
{% endfor -%}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
-v {{kube_config_dir}}:{{kube_config_dir}}:ro \
|
-v {{kube_config_dir}}:{{kube_config_dir}}:ro \
|
||||||
-v /etc/os-release:/etc/os-release:ro \
|
-v /etc/os-release:/etc/os-release:ro \
|
||||||
|
|
|
@ -47,11 +47,13 @@ ExecStart=/usr/bin/rkt run \
|
||||||
--volume flexvolumes,kind=host,source={{ kubelet_flexvolumes_plugins_dir }},readOnly=false \
|
--volume flexvolumes,kind=host,source={{ kubelet_flexvolumes_plugins_dir }},readOnly=false \
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% if local_volume_provisioner_enabled %}
|
{% if local_volume_provisioner_enabled %}
|
||||||
--volume local-volume-provisioner-base-dir,kind=host,source={{ local_volume_provisioner_base_dir }},readOnly=false \
|
{% for class in local_volume_provisioner_storage_classes %}
|
||||||
|
--volume local-volume-provisioner-base-dir,kind=host,source={{ class.host_dir }},readOnly=false \
|
||||||
{# Not pretty, but needed to avoid double mount #}
|
{# Not pretty, but needed to avoid double mount #}
|
||||||
{% if local_volume_provisioner_base_dir not in local_volume_provisioner_mount_dir and local_volume_provisioner_mount_dir not in local_volume_provisioner_base_dir %}
|
{% if class.host_dir not in class.mount_dir and class.mount_dir not in class.host_dir %}
|
||||||
--volume local-volume-provisioner-mount-dir,kind=host,source={{ local_volume_provisioner_mount_dir }},readOnly=false \
|
--volume local-volume-provisioner-mount-dir,kind=host,source={{ class.mount_dir }},readOnly=false \
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if kubelet_load_modules == true %}
|
{% if kubelet_load_modules == true %}
|
||||||
--mount volume=lib-modules,target=/lib/modules \
|
--mount volume=lib-modules,target=/lib/modules \
|
||||||
|
@ -81,11 +83,13 @@ ExecStart=/usr/bin/rkt run \
|
||||||
--mount volume=flexvolumes,target={{ kubelet_flexvolumes_plugins_dir }} \
|
--mount volume=flexvolumes,target={{ kubelet_flexvolumes_plugins_dir }} \
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% if local_volume_provisioner_enabled %}
|
{% if local_volume_provisioner_enabled %}
|
||||||
--mount volume=local-volume-provisioner-base-dir,target={{ local_volume_provisioner_base_dir }} \
|
{% for class in local_volume_provisioner_storage_classes %}
|
||||||
|
--mount volume=local-volume-provisioner-base-dir,target={{ class.host_dir }} \
|
||||||
{# Not pretty, but needed to avoid double mount #}
|
{# Not pretty, but needed to avoid double mount #}
|
||||||
{% if local_volume_provisioner_base_dir not in local_volume_provisioner_mount_dir and local_volume_provisioner_mount_dir not in local_volume_provisioner_base_dir %}
|
{% if class.host_dir not in class.mount_dir and class.mount_dir not in class.host_dir %}
|
||||||
--mount volume=local-volume-provisioner-mount-dir,target={{ local_volume_provisioner_mount_dir }} \
|
--mount volume=local-volume-provisioner-mount-dir,target={{ class.mount_dir }} \
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
--stage1-from-dir=stage1-fly.aci \
|
--stage1-from-dir=stage1-fly.aci \
|
||||||
{% if kube_hyperkube_image_repo == "docker" %}
|
{% if kube_hyperkube_image_repo == "docker" %}
|
||||||
|
|
|
@ -46,12 +46,12 @@
|
||||||
|
|
||||||
- name: Create local volume provisioner directories
|
- name: Create local volume provisioner directories
|
||||||
file:
|
file:
|
||||||
path: "{{ item }}"
|
path: "{{ item.host_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: kube
|
owner: root
|
||||||
with_items:
|
group: root
|
||||||
- "{{ local_volume_provisioner_base_dir }}"
|
mode: 0700
|
||||||
- "{{ local_volume_provisioner_mount_dir }}"
|
with_items: "{{ local_volume_provisioner_storage_classes }}"
|
||||||
when:
|
when:
|
||||||
- inventory_hostname in groups['k8s-cluster']
|
- inventory_hostname in groups['k8s-cluster']
|
||||||
- local_volume_provisioner_enabled
|
- local_volume_provisioner_enabled
|
||||||
|
|
|
@ -301,9 +301,11 @@ vault_config_dir: "{{ vault_base_dir }}/config"
|
||||||
vault_roles_dir: "{{ vault_base_dir }}/roles"
|
vault_roles_dir: "{{ vault_base_dir }}/roles"
|
||||||
vault_secrets_dir: "{{ vault_base_dir }}/secrets"
|
vault_secrets_dir: "{{ vault_base_dir }}/secrets"
|
||||||
|
|
||||||
# Local volume provisioner dirs
|
# Local volume provisioner storage classes
|
||||||
local_volume_provisioner_base_dir: /mnt/disks
|
local_volume_provisioner_storage_classes:
|
||||||
local_volume_provisioner_mount_dir: /mnt/disks
|
- name: "{{ local_volume_provisioner_storage_class | default('local-storage') }}"
|
||||||
|
host_dir: "{{ local_volume_provisioner_base_dir | default ('/mnt/disks') }}"
|
||||||
|
mount_dir: "{{ local_volume_provisioner_mount_dir | default('/mnt/disks') }}"
|
||||||
|
|
||||||
# weave's network password for encryption
|
# weave's network password for encryption
|
||||||
# if null then no network encryption
|
# if null then no network encryption
|
||||||
|
|
Loading…
Reference in a new issue