From 171d2ce59cf4dd0d542d4adb9ae4a0533506b90a Mon Sep 17 00:00:00 2001 From: Hugo Blom Date: Wed, 26 Feb 2020 14:12:25 +0100 Subject: [PATCH] Implement topology support for Cinder CSI (#5667) * make cinder csi topology aware * change feature description do better reflect whats being done * remove sameas true since it isn't required --- .../cinder/templates/cinder-csi-controllerplugin.yml.j2 | 3 +++ .../cinder-csi/templates/cinder-csi-storage-class.yml.j2 | 9 +++++++++ roles/kubespray-defaults/defaults/main.yaml | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-controllerplugin.yml.j2 b/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-controllerplugin.yml.j2 index 659f21335..e360a448f 100644 --- a/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-controllerplugin.yml.j2 +++ b/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-controllerplugin.yml.j2 @@ -35,6 +35,9 @@ spec: image: {{ cinder_csi_provisioner_image_repo }}:{{ cinder_csi_provisioner_image_tag }} args: - "--csi-address=$(ADDRESS)" +{% if cinder_topology is defined and cinder_topology %} + - --feature-gates=Topology=true +{% endif %} env: - name: ADDRESS value: /var/lib/csi/sockets/pluginproxy/csi.sock diff --git a/roles/kubernetes-apps/persistent_volumes/cinder-csi/templates/cinder-csi-storage-class.yml.j2 b/roles/kubernetes-apps/persistent_volumes/cinder-csi/templates/cinder-csi-storage-class.yml.j2 index a13d94ff3..5f1f625da 100644 --- a/roles/kubernetes-apps/persistent_volumes/cinder-csi/templates/cinder-csi-storage-class.yml.j2 +++ b/roles/kubernetes-apps/persistent_volumes/cinder-csi/templates/cinder-csi-storage-class.yml.j2 @@ -11,4 +11,13 @@ parameters: {% for key, value in (class.parameters | default({})).items() %} "{{ key }}": "{{ value }}" {% endfor %} +{% if cinder_topology is defined and cinder_topology is sameas true %} +allowedTopologies: +- matchLabelExpressions: + - key: topology.cinder.csi.openstack.org/zone + values: +{% for zone in cinder_topology_zones %} + - "{{ zone }}" +{% endfor %} +{% endif %} {% endfor %} diff --git a/roles/kubespray-defaults/defaults/main.yaml b/roles/kubespray-defaults/defaults/main.yaml index ef3ee7f80..7bf7a5ea5 100644 --- a/roles/kubespray-defaults/defaults/main.yaml +++ b/roles/kubespray-defaults/defaults/main.yaml @@ -308,6 +308,13 @@ expand_persistent_volumes: false ## When OpenStack is used, Cinder version can be explicitly specified if autodetection fails (Fixed in 1.9: https://github.com/kubernetes/kubernetes/issues/50461) # openstack_blockstorage_version: "v1/v2/auto (default)" openstack_blockstorage_ignore_volume_az: "{{ volume_cross_zone_attachment | default('false') }}" +# Cinder CSI topology, when false volumes can be cross-mounted between availability zones +# cinder_topology: false +# Set Cinder topology zones (can be multiple zones, default not set) +# cinder_topology_zones: +# - nova + + ## When OpenStack is used, if LBaaSv2 is available you can enable it with the following 2 variables. openstack_lbaas_enabled: false # openstack_lbaas_subnet_id: "Neutron subnet ID (not network ID) to create LBaaS VIP"