local_volume_provisioner: match upstream storage class syntax (#13504)

Use the upstream keys without converting them to snake case. This avoids
converting back to camel case when rendering, and aligns ourselves more
with our upstream.
This commit is contained in:
Max Gautier
2026-09-14 15:45:22 +00:00
committed by GitHub
parent 49ca08fe0d
commit b1b01bc579
7 changed files with 28 additions and 46 deletions
@@ -3,7 +3,7 @@
The [local static storage provisioner](https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner)
is NOT a dynamic storage provisioner as you would
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 `hostDir` of the specified storage class.
These storage classes are specified in the `local_volume_provisioner_storage_classes` nested dictionary.
Example:
@@ -11,24 +11,18 @@ Example:
```yaml
local_volume_provisioner_storage_classes:
local-storage:
host_dir: /mnt/disks
mount_dir: /mnt/disks
hostDir: /mnt/disks
mountDir: /mnt/disks
fast-disks:
host_dir: /mnt/fast-disks
mount_dir: /mnt/fast-disks
block_cleaner_command:
hostDir: /mnt/fast-disks
mountDir: /mnt/fast-disks
blockCleanerCommand:
- "/scripts/shred.sh"
- "2"
volume_mode: Filesystem
fs_type: ext4
volumeMode: Filesystem
fsType: ext4
```
For each key in `local_volume_provisioner_storage_classes` a "storage class" with
the same name is created in the entry `storageClassMap` of the ConfigMap `local-volume-provisioner`.
The subkeys of each storage class in `local_volume_provisioner_storage_classes`
are converted to camelCase and added as attributes to the storage class in the
ConfigMap.
The result of the above example is:
```yaml
@@ -93,14 +87,14 @@ the rest of this documentation will use that path as an example.
```
This saves time of precreating filesystems. Note that your storageclass must have
`volume_mode` set to `"Filesystem"` and `fs_type` defined. If either is not set, the
`volumeMode` set to `"Filesystem"` and `fsType` defined. If either is not set, the
disk will be added as a raw block device.
1. PersistentVolumes with `volumeMode="Block"`
Just like above, you can create PersistentVolumes with volumeMode `Block`
by creating a symbolic link under discovery directory to the block device on
the node, if you set `volume_mode` to `"Block"`. This will create a volume
the node, if you set `volumeMode` to `"Block"`. This will create a volume
presented into a Pod as a block device, without any filesystem on it.
1. File-backed sparsefile method
@@ -37,18 +37,18 @@ local_volume_provisioner_enabled: false
# - topology.kubernetes.io/zone
# local_volume_provisioner_storage_classes:
# local-storage:
# host_dir: /mnt/disks
# mount_dir: /mnt/disks
# volume_mode: Filesystem
# fs_type: ext4
# hostDir: /mnt/disks
# mountDir: /mnt/disks
# volumeMode: Filesystem
# fsType: ext4
# fast-disks:
# host_dir: /mnt/fast-disks
# mount_dir: /mnt/fast-disks
# block_cleaner_command:
# hostDir: /mnt/fast-disks
# mountDir: /mnt/fast-disks
# blockCleanerCommand:
# - "/scripts/shred.sh"
# - "2"
# volume_mode: Filesystem
# fs_type: ext4
# volumeMode: Filesystem
# fsType: ext4
# local_volume_provisioner_tolerations:
# - effect: NoSchedule
# operator: Exists
@@ -1,14 +1,3 @@
# Macro to convert camelCase dictionary keys to snake_case keys
{% macro convert_keys(mydict) -%}
{% for key in mydict.keys() | list -%}
{% set key_split = key.split('_') -%}
{% set new_key = key_split[0] + key_split[1:] | map('capitalize') | join -%}
{% set value = mydict.pop(key) -%}
{{ mydict.__setitem__(new_key, value) -}}
{{ convert_keys(value) if value is mapping else None -}}
{% endfor -%}
{% endmacro -%}
---
apiVersion: v1
kind: ConfigMap
@@ -28,6 +17,5 @@ data:
storageClassMap: |
{% for class_name, storage_class in local_volume_provisioner_storage_classes.items() %}
{{ class_name }}:
{{- convert_keys(storage_class) }}
{{ storage_class | to_nice_yaml(indent=2) | indent(6) }}
{%- endfor %}
@@ -51,7 +51,7 @@ spec:
name: provisioner-dev
{% for class_name, class_config in local_volume_provisioner_storage_classes.items() %}
- name: local-volume-provisioner-hostpath-{{ class_name }}
mountPath: {{ class_config.mount_dir }}
mountPath: {{ class_config.mountDir }}
mountPropagation: "HostToContainer"
{% endfor %}
volumes:
@@ -64,5 +64,5 @@ spec:
{% for class_name, class_config in local_volume_provisioner_storage_classes.items() %}
- name: local-volume-provisioner-hostpath-{{ class_name }}
hostPath:
path: {{ class_config.host_dir }}
path: {{ class_config.hostDir }}
{% endfor %}
@@ -6,7 +6,7 @@ metadata:
name: {{ class_name }}
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
{% if class_config.reclaim_policy is defined %}
reclaimPolicy: {{ class_config.reclaim_policy }}
{% if class_config.reclaimPolicy is defined %}
reclaimPolicy: {{ class_config.reclaimPolicy }}
{% endif %}
{% endfor %}
@@ -103,7 +103,7 @@
- name: Create local volume provisioner directories
file:
path: "{{ local_volume_provisioner_storage_classes[item].host_dir }}"
path: "{{ local_volume_provisioner_storage_classes[item].hostDir }}"
state: directory
owner: root
group: root
+4 -4
View File
@@ -69,10 +69,10 @@ kube_pods_subnets: >-
local_volume_provisioner_storage_classes_default:
- key: "{{ local_volume_provisioner_storage_class }}"
value:
host_dir: "{{ local_volume_provisioner_base_dir }}"
mount_dir: "{{ local_volume_provisioner_mount_dir }}"
volume_mode: Filesystem
fs_type: ext4
hostDir: "{{ local_volume_provisioner_base_dir }}"
mountDir: "{{ local_volume_provisioner_mount_dir }}"
volumeMode: Filesystem
fsType: ext4
ssl_ca_dirs_per_os_family:
Debian: &usr_share