Thursday, December 4, 2025

OpenStack Epoxy : Configure Barbican

 

OpenStack Epoxy : Configure Barbican

 

Install OpenStack Key Manager Service (Barbican).

This example is based on the environment like follows.

------------+--------------------------+--------------------------+------------
            |                          |                          |
        eth0|10.0.0.30             eth0|10.0.0.50             eth0|10.0.0.51
+-----------+-----------+  +-----------+-----------+  +-----------+-----------+
|   [ dlp.srv.world ]   |  | [ network.srv.world ] |  |  [ node01.srv.world ] |
|     (Control Node)    |  |     (Network Node)    |  |     (Compute Node)    |
|                       |  |                       |  |                       |
|  MariaDB    RabbitMQ  |  |      Open vSwitch     |  |        Libvirt        |
|  Memcached  Nginx     |  |     Neutron Server    |  |      Nova Compute     |
|  Keystone   httpd     |  |      OVN-Northd       |  |      Open vSwitch     |
|  Glance     Nova API  |  |  Nginx  iSCSI Target  |  |   OVN Metadata Agent  |
|  Cinder API           |  |     Cinder Volume     |  |     OVN-Controller    |
|  Barbican API         |  |    Heat API/Engine    |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

[1]Add a User or Endpoint for Barbican to Keystone on Control Node.
# create [barbican] user in [service] project

root@dlp ~(keystone)# 
openstack user create --domain default --project service --password servicepassword barbican

+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| default_project_id  | a60814a6c56241edbbdfae6c290f8abc |
| domain_id           | default                          |
| email               | None                             |
| enabled             | True                             |
| id                  | 51afe4e130af413792bced4534157914 |
| name                | barbican                         |
| description         | None                             |
| password_expires_at | None                             |
+---------------------+----------------------------------+

# add [barbican] user in [admin] role

root@dlp ~(keystone)# 
openstack role add --project service --user barbican admin
# create service entry for [barbican]

root@dlp ~(keystone)# 
openstack service create --name barbican --description "OpenStack Key Manager" key-manager

+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| id          | 26ed60c049164be8ba9e7df0c2d2b00e |
| name        | barbican                         |
| type        | key-manager                      |
| enabled     | True                             |
| description | OpenStack Key Manager            |
+-------------+----------------------------------+

# define Barbican API Host

root@dlp ~(keystone)# 
export controller=dlp.srv.world
# create endpoint for [barbican] (public)

root@dlp ~(keystone)# 
openstack endpoint create --region RegionOne key-manager public https://$controller:9311

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | be3ff4dce0b0441b9ac76cce2f33c55f |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 26ed60c049164be8ba9e7df0c2d2b00e |
| service_name | barbican                         |
| service_type | key-manager                      |
| url          | https://dlp.srv.world:9311       |
+--------------+----------------------------------+

# create endpoint for [barbican] (internal)

root@dlp ~(keystone)# 
openstack endpoint create --region RegionOne key-manager internal https://$controller:9311

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 013f8385d6864bf08fc79fdf75220064 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 26ed60c049164be8ba9e7df0c2d2b00e |
| service_name | barbican                         |
| service_type | key-manager                      |
| url          | https://dlp.srv.world:9311       |
+--------------+----------------------------------+

# create endpoint for [barbican] (admin)

root@dlp ~(keystone)# 
openstack endpoint create --region RegionOne key-manager admin https://$controller:9311

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | bcf887d1407c45a690ee9b38f1b3d7d9 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 26ed60c049164be8ba9e7df0c2d2b00e |
| service_name | barbican                         |
| service_type | key-manager                      |
| url          | https://dlp.srv.world:9311       |
+--------------+----------------------------------+
[2]Add a User and Database on MariaDB for Barbican.
root@dlp ~(keystone)# 
mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 263
Server version: 11.8.2-MariaDB-1 from Debian -- Please help get to 10k stars at https://github.com/MariaDB/Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database barbican; 
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on barbican.* to barbican@'localhost' identified by 'password'; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on barbican.* to barbican@'%' identified by 'password'; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit 
Bye
[3]Install Barbican service.
root@dlp ~(keystone)# 
apt -y install barbican-api
[4]Configure Barbican.
root@dlp ~(keystone)# 
mv /etc/barbican/barbican.conf /etc/barbican/barbican.conf.org

root@dlp ~(keystone)# 
vi /etc/barbican/barbican.conf
# create new

[DEFAULT]
bind_host = 127.0.0.1
bind_port = 9311
host_href = https://dlp.srv.world:9311
log_file = /var/log/barbican/api.log
# RabbitMQ connection info
transport_url = rabbit://openstack:password@dlp.srv.world:5672

[secretstore]
namespace = barbican.secretstore.plugin
enabled_secretstore_plugins = store_crypto

[crypto]
namespace = barbican.crypto.plugin
enabled_crypto_plugins = simple_crypto

[simple_crypto_plugin]
kek = 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY='

# MariaDB connection info
[database]
connection = mysql+pymysql://barbican:password@dlp.srv.world/barbican

# Keystone auth info
[keystone_authtoken]
www_authenticate_uri = https://dlp.srv.world:5000
auth_url = https://dlp.srv.world:5000
memcached_servers = dlp.srv.world:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = barbican
password = servicepassword
# if using self-signed certs on Apache2 Keystone, turn to [true]
insecure = false

[oslo_policy]
enforce_new_defaults = true

root@dlp ~(keystone)# 
chmod 640 /etc/barbican/barbican.conf

root@dlp ~(keystone)# 
chgrp barbican /etc/barbican/barbican.conf
root@dlp ~(keystone)# 
sed -i -e "s/UWSGI_BIND_IP=\"\"/UWSGI_BIND_IP=\"127.0.0.1\"/" /etc/init.d/barbican-api
[5]Configure Nginx for proxy settings.
root@dlp ~(keystone)# 
vi /etc/nginx/nginx.conf
# add into the [stream] section

stream {
    upstream glance-api {
        server 127.0.0.1:9292;
    }
    server {
        listen 10.0.0.30:9292 ssl;
        proxy_pass glance-api;
    }
    upstream nova-api {
        server 127.0.0.1:8774;
    }
    server {
        listen 10.0.0.30:8774 ssl;
        proxy_pass nova-api;
    }
    upstream nova-metadata-api {
        server 127.0.0.1:8775;
    }
    server {
        listen 10.0.0.30:8775 ssl;
        proxy_pass nova-metadata-api;
    }
    upstream placement-api {
        server 127.0.0.1:8778;
    }
    server {
        listen 10.0.0.30:8778 ssl;
        proxy_pass placement-api;
    }
    upstream novncproxy {
        server 127.0.0.1:6080;
    }
    server {
        listen 10.0.0.30:6080 ssl;
        proxy_pass novncproxy;
    }
    upstream cinder-api {
        server 127.0.0.1:8776;
    }
    server {
        listen 10.0.0.30:8776 ssl;
        proxy_pass cinder-api;
    }
    upstream barbican-api {
        server 127.0.0.1:9311;
    }
    server {
        listen 10.0.0.30:9311 ssl;
        proxy_pass barbican-api;
    }
    ssl_certificate "/etc/letsencrypt/live/dlp.srv.world/fullchain.pem";
    ssl_certificate_key "/etc/letsencrypt/live/dlp.srv.world/privkey.pem";
}
[6]Add Data into Database and start Barbican services.
root@dlp ~(keystone)# 
su -s /bin/bash barbican -c "barbican-manage db upgrade"

root@dlp ~(keystone)# 
systemctl restart barbican-api

root@dlp ~(keystone)# 
systemctl enable barbican-api

root@dlp ~(keystone)# 
systemctl restart nginx

Matched Content

No comments:

Post a Comment