Allow cinder-volume to be configured to use NFS

Allow cinder-volume, nova-compute and nova-libvirtd to be configured to
use NFS. In order to mount and work with NFS shares, several containers
needed the NFS packages installed during build time.

One somewhat significant change is the addition of an explicit bind
volume for nova-compute that has shared mounts enabled.

According to docker-run(1), the shared mount propagation flag can only
be specified for bind mounted Docker volumes and not named volumes.

In an NFS setup, cinder-volume mounts the NFS shares so that it can
create and manage the Cinder volumes. When a new instance is created
with a Cinder volume or a Cinder volume is attached to an existing
instance, nova-compute mounts the Cinder volume from the NFS share for
nova-libvirtd. In order for nova-libvirtd to then see those Cinder
volumes the shared mounts flag must be enabled for the Docker volume.

Remove the rpcbind container as it is only necessary for operators who
are using NFSv3 or lower. There is no known need for this currently
however, this container can be added in the future should an operator
require it.

Co-authored-by: Ryan Hallisey <rhallise@redhat.com>
Co-authored-by: Andrew Widdersheim <amwiddersheim@gmail.com>
Change-Id: Iad77c05bce8876bdcc69b7ec22edd50e3bf48b9f
Closes-Bug: #1530515
Partially implements: blueprint  nfs-support-in-cinder
This commit is contained in:
xionglingfeng 2016-02-13 23:50:46 -03:30 committed by Andrew Widdersheim
parent b8da31d448
commit 17e6e629f5
9 changed files with 45 additions and 35 deletions

View File

@ -254,6 +254,7 @@ enable_ceph_rgw: "no"
enable_cinder: "no" enable_cinder: "no"
enable_cinder_backend_iscsi: "no" enable_cinder_backend_iscsi: "no"
enable_cinder_backend_lvm: "no" enable_cinder_backend_lvm: "no"
enable_cinder_backend_nfs: "no"
enable_cloudkitty: "no" enable_cloudkitty: "no"
enable_congress: "no" enable_congress: "no"
enable_etcd: "no" enable_etcd: "no"

View File

@ -74,5 +74,8 @@ cinder_backends:
- name: "lvm-1" - name: "lvm-1"
driver: "lvm" driver: "lvm"
enabled: "{{ enable_cinder_backend_lvm | bool }}" enabled: "{{ enable_cinder_backend_lvm | bool }}"
- name: "nfs-1"
driver: "nfs"
enabled: "{{ enable_cinder_backend_nfs | bool }}"
cinder_enabled_backends: "{{ cinder_backends|selectattr('enabled', 'equalto', true)|list }}" cinder_enabled_backends: "{{ cinder_backends|selectattr('enabled', 'equalto', true)|list }}"

View File

@ -49,3 +49,14 @@
dest: "{{ node_config_directory }}/cinder/policy.json" dest: "{{ node_config_directory }}/cinder/policy.json"
when: when:
cinder_policy.stat.exists cinder_policy.stat.exists
- name: Copying over nfs_shares files for cinder_volume
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/cinder-volume/nfs_shares"
with_first_found:
- "{{ node_custom_config }}/nfs_shares.j2"
- "{{ node_custom_config }}/cinder/nfs_shares.j2"
- "{{ node_custom_config }}/cinder/cinder-volume/nfs_shares.j2"
- "{{ node_custom_config }}/cinder/{{ inventory_hostname }}/nfs_shares.j2"
when: enable_cinder_backend_nfs | bool

View File

@ -6,19 +6,28 @@
"dest": "/etc/cinder/cinder.conf", "dest": "/etc/cinder/cinder.conf",
"owner": "cinder", "owner": "cinder",
"perm": "0600" "perm": "0600"
}{% if cinder_backend_ceph | bool %}, },
{ {
"source": "{{ container_config_directory }}/ceph.*", "source": "{{ container_config_directory }}/ceph.*",
"dest": "/etc/ceph/", "dest": "/etc/ceph/",
"owner": "cinder", "owner": "cinder",
"perm": "0700" "perm": "0700",
"optional": {{ (not cinder_backend_ceph | bool) | string | lower }}
}, },
{ {
"source": "{{ container_config_directory }}/ceph.conf", "source": "{{ container_config_directory }}/ceph.conf",
"dest": "/etc/ceph/ceph.conf", "dest": "/etc/ceph/ceph.conf",
"owner": "cinder", "owner": "cinder",
"perm": "0600" "perm": "0600",
}{% endif %} "optional": {{ (not cinder_backend_ceph | bool) | string | lower }}
},
{
"source": "{{ container_config_directory }}/nfs_shares",
"dest": "/etc/cinder/nfs_shares",
"owner": "cinder",
"perm": "0600",
"optional": {{ (not enable_cinder_backend_nfs | bool) | string | lower }}
}
], ],
"permissions": [ "permissions": [
{ {

View File

@ -99,5 +99,12 @@ rbd_secret_uuid = {{ rbd_secret_uuid }}
report_discard_supported = True report_discard_supported = True
{% endif %} {% endif %}
{% if enable_cinder_backend_nfs | bool %}
[nfs-1]
volume_driver = cinder.volume.drivers.nfs.NfsDriver
volume_backend_name = nfs-1
nfs_shares_config = /etc/cinder/nfs_shares
{% endif %}
[privsep_entrypoint] [privsep_entrypoint]
helper_command=sudo cinder-rootwrap /etc/cinder/rootwrap.conf privsep-helper --config-file /etc/cinder/cinder.conf helper_command=sudo cinder-rootwrap /etc/cinder/rootwrap.conf privsep-helper --config-file /etc/cinder/cinder.conf

View File

@ -17,6 +17,7 @@
- "kolla_logs:/var/log/kolla/" - "kolla_logs:/var/log/kolla/"
- "libvirtd:/var/lib/libvirt" - "libvirtd:/var/lib/libvirt"
- "nova_compute:/var/lib/nova/" - "nova_compute:/var/lib/nova/"
- "/var/lib/nova/mnt:/var/lib/nova/mnt:shared"
- "nova_libvirt_qemu:/etc/libvirt/qemu" - "nova_libvirt_qemu:/etc/libvirt/qemu"
register: start_nova_libvirt_container register: start_nova_libvirt_container
# NOTE(Jeffrey4l): retry 5 to remove nova_libvirt container because when # NOTE(Jeffrey4l): retry 5 to remove nova_libvirt container because when
@ -37,6 +38,7 @@
- "{% if enable_iscsid | bool %}iscsi_info:/etc/iscsi{% endif %}" - "{% if enable_iscsid | bool %}iscsi_info:/etc/iscsi{% endif %}"
- "libvirtd:/var/lib/libvirt" - "libvirtd:/var/lib/libvirt"
- "nova_compute:/var/lib/nova/" - "nova_compute:/var/lib/nova/"
- "/var/lib/nova/mnt:/var/lib/nova/mnt:shared"
- name: Starting nova-compute container - name: Starting nova-compute container
kolla_docker: kolla_docker:
@ -94,6 +96,7 @@
- "/etc/localtime:/etc/localtime:ro" - "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla" - "kolla_logs:/var/log/kolla"
- "nova_compute:/var/lib/nova" - "nova_compute:/var/lib/nova"
- "/var/lib/nova/mnt:/var/lib/nova/mnt:shared"
- "heka_socket:/var/lib/kolla/heka/" - "heka_socket:/var/lib/kolla/heka/"
# TODO(jeffrey4l): how to handle the nova-compute-fake and # TODO(jeffrey4l): how to handle the nova-compute-fake and
# nova-compute-ironic # nova-compute-ironic

View File

@ -1,29 +0,0 @@
FROM {{ namespace }}/{{ image_prefix }}cinder-base:{{ tag }}
MAINTAINER {{ maintainer }}
{% block cinder_rpcbind_header %}{% endblock %}
{% import "macros.j2" as macros with context %}
{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
{% set cinder_rpcbind_packages = [
'nfs-utils',
'nfs-utils-lib'
] %}
{% elif base_distro in ['ubuntu', 'debian'] %}
{% set cinder_rpcbind_packages = [
'rpcbind'
] %}
{% endif %}
{{ macros.install_packages(cinder_rpcbind_packages | customizable("packages")) }}
{% block cinder_rpcbind_footer %}{% endblock %}
{% block footer %}{% endblock %}
{{ include_footer }}
USER cinder

View File

@ -8,6 +8,7 @@ MAINTAINER {{ maintainer }}
{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
{% set cinder_volume_packages = [ {% set cinder_volume_packages = [
'nfs-utils',
'scsi-target-utils' 'scsi-target-utils'
] %} ] %}
@ -35,11 +36,11 @@ RUN sed -i '1 i include /var/lib/cinder/volumes/*' /etc/tgt/targets.conf
{% if base_distro in ['ubuntu', 'debian'] %} {% if base_distro in ['ubuntu', 'debian'] %}
{% set cinder_volume_packages = [ {% set cinder_volume_packages = [
'cinder-volume' 'cinder-volume',
'nfs-common'
] %} ] %}
{{ macros.install_packages(cinder_volume_packages | customizable("packages")) }} {{ macros.install_packages(cinder_volume_packages | customizable("packages")) }}
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@ -15,6 +15,7 @@ MAINTAINER {{ maintainer }}
'ceph-common', 'ceph-common',
'genisoimage', 'genisoimage',
'iscsi-initiator-utils', 'iscsi-initiator-utils',
'nfs-utils',
'targetcli', 'targetcli',
'python-rtslib' 'python-rtslib'
] %} ] %}
@ -32,6 +33,7 @@ MAINTAINER {{ maintainer }}
'ironic-common', 'ironic-common',
'python-ironicclient', 'python-ironicclient',
'genisoimage', 'genisoimage',
'nfs-common',
'open-iscsi', 'open-iscsi',
'targetcli', 'targetcli',
'python-rtslib' 'python-rtslib'
@ -53,6 +55,7 @@ RUN rm -f /etc/nova/nova-compute.conf
'ceph-common', 'ceph-common',
'genisoimage', 'genisoimage',
'iscsi-initiator-utils', 'iscsi-initiator-utils',
'nfs-utils',
'targetcli', 'targetcli',
'python-rtslib' 'python-rtslib'
] %} ] %}
@ -64,6 +67,7 @@ RUN rm -f /etc/nova/nova-compute.conf
'qemu-utils', 'qemu-utils',
'ceph-common', 'ceph-common',
'genisoimage', 'genisoimage',
'nfs-common',
'open-iscsi', 'open-iscsi',
'targetcli', 'targetcli',
'python-rtslib' 'python-rtslib'