第 3 章 安装 Barbican
Red Hat OpenStack Platform 中不默认启用 Barbican。此流程描述了如何在现有 OpenStack 部署中部署 barbican。Barbican 作为容器化服务运行,因此此步骤还描述了如何准备和上传新的容器镜像:
此流程将 barbican 配置为使用 simple_crypto
后端。其他后端可用,如 PKCS11
和 DogTag,但本发行版本中不支持它们。
在 undercloud 节点上,为 barbican 创建环境文件。这将指示 director 安装 barbican (在 openstack overcloud deploy […]中包含的时)
$ cat /home/stack/configure-barbican.yaml parameter_defaults: BarbicanSimpleCryptoGlobalDefault: true
-
BarbicanSimpleCryptoGlobalDefault
- 将这个插件设置为全局默认插件。 更多选项也可以配置:
-
BarbicanPassword
- 为 barbican 服务帐户设置密码。 -
BarbicanWorkers
- 设置barbican::wsgi::apache
的 worker 数量。默认使用'%{::processorcount}'
。 -
BarbicanDebug
- 启用调试。 -
BarbicanPolicies
- 定义要为 barbican 配置的策略。使用 hash 值,例如:{ barbican-context_is_admin: { key: context_is_admin, value: 'role:admin' } }
。然后,此条目会添加到/etc/barbican/policy.json
中。后续章节中将详细介绍策略。 -
BarbicanSimpleCryptoKek
- director 生成密钥加密密钥(KEK) (如果没有指定)。
-
-
此步骤为 barbican 准备新的容器镜像。您需要包含
configure-barbican.yaml
和所有相关模板文件。更改以下示例以适合您的部署:$ openstack overcloud container image prepare \ --namespace example.lab.local:5000/rhosp13 \ --tag 2018-06-06.1 \ --push-destination 192.168.100.1:8787 \ --output-images-file ~/container-images-with-barbican.yaml \ -e /home/stack/virt/config_lvm.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml \ -e /home/stack/virt/network/network-environment.yaml \ -e /home/stack/virt/hostnames.yml \ -e /home/stack/virt/nodes_data.yaml \ -e /home/stack/virt/extra_templates.yaml \ -e /home/stack/virt/docker-images.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/services/barbican.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/barbican-backend-simple-crypto.yaml \ -e /home/stack/configure-barbican.yaml
将新容器镜像上传到 undercloud registry:
$ openstack overcloud container image upload --debug --config-file container-images-with-barbican.yaml
准备新的环境文件:
$ openstack overcloud container image prepare \ --tag 2018-06-06.1 \ --namespace 192.168.100.1:8787/rhosp13 \ --output-env-file ~/container-parameters-with-barbican.yaml \ -e /home/stack/virt/config_lvm.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml \ -e /home/stack/virt/network/network-environment.yaml \ -e /home/stack/virt/hostnames.yml \ -e /home/stack/virt/nodes_data.yaml \ -e /home/stack/virt/extra_templates.yaml \ -e /home/stack/virt/docker-images.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/services/barbican.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/barbican-backend-simple-crypto.yaml \ -e /home/stack/configure-barbican.yaml
要将这些更改应用到部署:更新 overcloud 并指定您在以前的 openstack overcloud deploy […] 中使用的所有 heat 模板文件。例如:
$ openstack overcloud deploy \ --timeout 100 \ --templates /usr/share/openstack-tripleo-heat-templates \ --stack overcloud \ --libvirt-type kvm \ --ntp-server clock.redhat.com \ -e /home/stack/virt/config_lvm.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml \ -e /home/stack/virt/network/network-environment.yaml \ -e /home/stack/virt/hostnames.yml \ -e /home/stack/virt/nodes_data.yaml \ -e /home/stack/virt/extra_templates.yaml \ -e /home/stack/container-parameters-with-barbican.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/services/barbican.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/barbican-backend-simple-crypto.yaml \ -e /home/stack/configure-barbican.yaml \ --log-file overcloud_deployment_38.log
3.1. 将用户添加到 Overcloud 的创建者角色
用户必须是 创建者
角色的成员,才能创建和编辑 barbican secret,或者创建加密的卷将机密存储在 barbican 中。
检索
创建者
角色的id
:openstack role show creator +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | None | | id | 4e9c560c6f104608948450fbf316f9d7 | | name | creator | +-----------+----------------------------------+
注意除非安装了 OpenStack Key Manager (barbican),否则您不会看到
创建
者角色。将用户分配到
创建
者角色,并指定相关的项目。在本例中,project_a
项目中名为user1
的用户被添加到创建者角色中
:openstack role add --user user1 --project project_a 4e9c560c6f104608948450fbf316f9d7
3.1.1. 测试 barbican 功能
这部分论述了如何测试 barbican 是否正常工作。
创建测试 secret。例如:
$ openstack secret store --name testSecret --payload 'TestPayload' +---------------+------------------------------------------------------------------------------------+ | Field | Value | +---------------+------------------------------------------------------------------------------------+ | Secret href | https://192.168.123.163/key-manager/v1/secrets/4cc5ffe0-eea2-449d-9e64-b664d574be53 | | Name | testSecret | | Created | None | | Status | None | | Content types | None | | Algorithm | aes | | Bit length | 256 | | Secret type | opaque | | Mode | cbc | | Expiration | None | +---------------+------------------------------------------------------------------------------------+
检索您刚才创建的 secret 的有效负载:
openstack secret get https://192.168.123.163/key-manager/v1/secrets/4cc5ffe0-eea2-449d-9e64-b664d574be53 --payload +---------+-------------+ | Field | Value | +---------+-------------+ | Payload | TestPayload | +---------+-------------+