4.2. 加密块存储(cinder)卷
您可以使用 barbican 管理 Block Storage (cinder)加密密钥。此配置使用 LUKS 对连接到您的实例的磁盘进行加密,包括引导磁盘。密钥管理对用户是透明的;当您使用 luks
作为加密类型创建新卷时,cinder 会为卷生成一个对称密钥 secret,并将其存储在 barbican 中。引导实例时(或附加加密卷),nova 从 barbican 检索密钥,并将 secret 存储在本地作为 Compute 节点上的 Libvirt secret。
流程
在运行
cinder-volume
和nova-compute
服务的节点上,确认 nova 和 cinder 都配置为使用 barbican 进行密钥管理:crudini --get /var/lib/config-data/puppet-generated/cinder/etc/cinder/cinder.conf key_manager backend crudini --get /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf key_manager backend
$ crudini --get /var/lib/config-data/puppet-generated/cinder/etc/cinder/cinder.conf key_manager backend castellan.key_manager.barbican_key_manager.BarbicanKeyManager $ crudini --get /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf key_manager backend castellan.key_manager.barbican_key_manager.BarbicanKeyManager
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 创建使用加密的卷模板。当您创建新卷时,可以把它们建模到您此处定义的设置中:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 创建一个新卷,并指定它使用
LuksEncryptor-Template-256
设置:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 生成的 secret 会自动上传到 barbican 后端。
注意确保创建加密卷的用户在项目中具有
创建者
barbican 角色。如需更多信息,请参阅授予用户对创建者角色的访问权限
部分。使用 barbican 确认是否存在磁盘加密密钥。在本例中,时间戳与 LUKS 卷创建时间匹配:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将新卷附加到现有实例。例如:
openstack server add volume testInstance Encrypted-Test-Volume
$ openstack server add volume testInstance Encrypted-Test-Volume
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 然后,卷会呈现在客户端操作系统中,并可使用内置工具挂载。
4.2.1. 将块存储卷迁移到 OpenStack 密钥管理器 复制链接链接已复制到粘贴板!
如果您之前使用 ConfKeyManager
管理磁盘加密密钥,您可以通过扫描数据库以迁移到 barbican 范围内的 encryption_key_id
条目,将卷迁移到 OpenStack Key Manager。每个条目都会获得一个新的 barbican 密钥 ID,现有的 ConfKeyManager
secret 被保留。
-
在以前的版本中,您可以使用
ConfKeyManager
加密的卷重新分配所有权。对于由 barbican 管理的密钥的卷,这不可能。 -
激活 barbican 不会破坏现有的
keymgr
卷。
前提条件
在迁移前,请查看 Barbican 管理的加密卷和使用 ConfKeyManager
的卷之间的区别:
- 您无法传输加密卷的所有权,因为目前无法传输 barbican secret 的所有权。
- barbican 对允许读和删除 secret 的人员更严格,这可能会影响一些 cinder 卷操作。例如,用户无法附加、分离或删除其他用户的卷。
流程
- 部署 barbican 服务。
将创建
者角色
添加到 cinder 服务。例如:#openstack role create creator #openstack role add --user cinder creator --project service
#openstack role create creator #openstack role add --user cinder creator --project service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 重启
cinder-volume
和cinder-backup
服务。cinder-volume
和cinder-backup
服务会自动开始迁移过程。您可以检查日志文件以查看迁移的状态信息:-
cinder-volume
- 迁移存储在 cinder 的 Volumes 和 Snapshots 表中的密钥。 -
cinder-backup
- 迁移 Backups 表中的键。
-
-
监控显示迁移已完成的消息的日志,并检查没有更多卷正在使用
ConfKeyManager
all-zeros 加密密钥 ID。 -
从
cinder.conf
和nova.conf
中删除fixed_key
选项。您必须确定哪些节点配置了此设置。 -
从 cinder 服务中删除
创建者
角色。
验证
启动进程后,其中一个条目会出现在日志文件中。这表明迁移是否正确启动,或者它标识它遇到的问题:
-
不迁移加密密钥,因为 ConfKeyManager 仍在使用中。
-
不迁移加密密钥,因为 ConfKeyManager 的 fixed_key 没有被使用。
-
不支持迁移加密密钥,因为迁移到 'XXX' key_manager 后端。
- 此消息不太可能出现;它是一种安全检查来处理在 barbican 以外的另一个 Key Manager 后端。这是因为代码只支持一个迁移场景: 从 ConfKeyManager 到 barbican。 -
不迁移加密密钥,因为没有与此主机关联的卷。
- 当cinder-volume
在多个主机上运行时,可能会发生与它关联的卷。这是因为每个主机都需要负责处理自己的卷。 -
开始迁移 ConfKeyManager 键。
将卷 <UUID> 加密密钥迁移到 Barbican
- 迁移期间,将检查所有主机的卷;如果卷仍在使用 ConfKeyManager 的密钥 ID (它只包括零 (00000000-0000-0000-0000-000000000000
),则会出现这个消息。-
对于
cinder-backup
,此消息使用稍有不同的大写:迁移卷 [...]
或Migrating Backup [...]
-
对于
-
每个主机检查其所有卷后,主机会显示概述状态消息:
`No volumes are using the ConfKeyManager's encryption_key_id.` `No backups are known to be using the ConfKeyManager's encryption_key_id.`
`No volumes are using the ConfKeyManager's encryption_key_id.` `No backups are known to be using the ConfKeyManager's encryption_key_id.`
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 您还可以看到以下条目:
-
使用 ConfKeyManager 的全零加密密钥 ID 仍然有 %d 卷。
使用 ConfKeyManager 的全零加密密钥 ID 仍然有 %d 备份。
这两个消息都可能出现在
cinder-volume
和cinder-backup
日志中。每个服务仅处理自己的条目的迁移,而服务则了解另一个的状态。因此,cinder-volume
知道cinder-backup
仍然有要迁移的备份,cinder-backup
知道cinder-volume
服务是否有要迁移的卷。
-
虽然每个主机只迁移自己的卷,但摘要消息基于对任何卷仍然需要迁移的全局评估,但允许您确认所有卷的迁移已完成。
cleanup
将密钥 ID 迁移到 barbican 后,固定密钥会保留在配置文件中。这可能会对某些用户造成安全问题,因为 fixed_key
值没有在 .conf
文件中加密。
要解决这个问题,您可以从 nova 和 cinder 配置中手动删除 fixed_key
值。但是,首先先完成测试并查看日志文件的输出,因为仍依赖于这个值的磁盘无法访问。
encryption_key_id
最近被添加到 Backup
表中,作为 Queens 发行版本的一部分。因此,已存在的加密卷的备份可能会存在。all-zeros encryption_key_id
存储在备份本身上,但不出现在 备份
数据库中。因此,迁移过程无法知道某些加密卷的备份是否仍依赖于全零 ConfKeyMgr
密钥 ID。
检查现有的
fixed_key
值。这两个服务都必须匹配这些值。crudini --get /var/lib/config-data/puppet-generated/cinder/etc/cinder/cinder.conf keymgr fixed_key crudini --get /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf keymgr fixed_key
crudini --get /var/lib/config-data/puppet-generated/cinder/etc/cinder/cinder.conf keymgr fixed_key crudini --get /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf keymgr fixed_key
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 重要备份现有的
fixed_key
值。这允许您在出现问题时恢复值,或者需要恢复使用旧加密密钥的备份。删除
fixed_key
值:crudini --del /var/lib/config-data/puppet-generated/cinder/etc/cinder/cinder.conf keymgr fixed_key crudini --del /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf keymgr fixed_key
crudini --del /var/lib/config-data/puppet-generated/cinder/etc/cinder/cinder.conf keymgr fixed_key crudini --del /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf keymgr fixed_key
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
故障排除
只有请求者具有 创建者
角色时,才能创建 barbican secret。这意味着 cinder 服务本身需要创建者角色,否则会发生类似如下的日志序列:
-
开始迁移 ConfKeyManager 键。
-
将卷 <UUID> 加密密钥迁移到 Barbican
-
迁移加密密钥时出错:禁止创建 Secret - 查看您的用户/项目权限
-
使用 ConfKeyManager 的全零加密密钥 ID 仍然有 %d 卷。
键消息是第三个消息: Secret 创建尝试不允许。
要解决这个问题,更新 cinder
帐户的权限:
-
运行
openstack role add --project service --user cinder creator
-
重启
cinder-volume
和cinder-backup
服务。
因此,迁移的下一次尝试应该可以成功。