CentOS Stream 9
Sponsored Link

OpenStack Yoga : Glance 設定2022/06/09

 
OpenStack Image Service(Glance)をインストールします。
当例では以下のような環境に Glance をインストールします。
        eth0|10.0.0.30 
+-----------+-----------+
|   [ dlp.srv.world ]   |
|     (Control Node)    |
|                       |
|  MariaDB    RabbitMQ  |
|  Memcached  httpd     |
|  Keystone   Glance    |
+-----------------------+

[1] Keystone に Glance 用のユーザー等々を作成しておきます。
# [service] プロジェクト所属で [glance] ユーザーを作成

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

+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| default_project_id  | 0f2625947bf0433a9519ba8a29434bdf |
| domain_id           | default                          |
| enabled             | True                             |
| id                  | b099e64a43d444a9b5cf82bc4c329916 |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

# [glance] ユーザーを [admin] ロール に加える

[root@dlp ~(keystone)]#
openstack role add --project service --user glance admin
# [glance] 用サービスエントリ作成

[root@dlp ~(keystone)]#
openstack service create --name glance --description "OpenStack Image service" image

+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image service          |
| enabled     | True                             |
| id          | 937e41ce976e423caa174ea65d4ed7e3 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

# Glance API ノードを定義

[root@dlp ~(keystone)]#
export controller=dlp.srv.world
# [glance] 用エンドポイント作成 (public)

[root@dlp ~(keystone)]#
openstack endpoint create --region RegionOne image public https://$controller:9292

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | defcdf11d2b942348747f0a709a57ceb |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 937e41ce976e423caa174ea65d4ed7e3 |
| service_name | glance                           |
| service_type | image                            |
| url          | https://dlp.srv.world:9292       |
+--------------+----------------------------------+

# [glance] 用エンドポイント作成 (internal)

[root@dlp ~(keystone)]#
openstack endpoint create --region RegionOne image internal https://$controller:9292

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | d80b3dcdcee847b8a0153762ebbda537 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 937e41ce976e423caa174ea65d4ed7e3 |
| service_name | glance                           |
| service_type | image                            |
| url          | https://dlp.srv.world:9292       |
+--------------+----------------------------------+

# [glance] 用エンドポイント作成 (admin)

[root@dlp ~(keystone)]#
openstack endpoint create --region RegionOne image admin https://$controller:9292

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 96be4645f30d44fd8694f3e5ffd58d1c |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 937e41ce976e423caa174ea65d4ed7e3 |
| service_name | glance                           |
| service_type | image                            |
| url          | https://dlp.srv.world:9292       |
+--------------+----------------------------------+
[2] Glance 用のユーザーとデータベースを MariaDB に作成しておきます。
[root@dlp ~(keystone)]#
mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.5.13-MariaDB 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 glance; 
Query OK, 1 row affected (0.00 sec)

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

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

MariaDB [(none)]> flush privileges; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
[3] Glance をインストールします。
# Yoga, EPEL, CRB からインストール

[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-yoga,epel,crb -y install openstack-glance
[4] Glance の基本設定です。
[root@dlp ~(keystone)]#
mv /etc/glance/glance-api.conf /etc/glance/glance-api.conf.org

[root@dlp ~(keystone)]#
vi /etc/glance/glance-api.conf
# 以下の内容で新規作成

[DEFAULT]
bind_host = 127.0.0.1
# RabbitMQ サーバー接続情報
transport_url = rabbit://openstack:password@dlp.srv.world

[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

[database]
# MariaDB 接続情報
connection = mysql+pymysql://glance:password@dlp.srv.world/glance

# keystone 認証情報
[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 = glance
password = servicepassword
# httpd の Keystone サイトで自己署名の証明書を使用の場合は [true]
insecure = false

[paste_deploy]
flavor = keystone

[root@dlp ~(keystone)]#
chmod 640 /etc/glance/glance-api.conf

[root@dlp ~(keystone)]#
chgrp glance /etc/glance/glance-api.conf
[root@dlp ~(keystone)]#
su -s /bin/bash glance -c "glance-manage db_sync"

[root@dlp ~(keystone)]#
systemctl enable --now openstack-glance-api

[5] Nginx にプロキシの設定をします。
SSL/TLS 証明書を取得は Apache httpd Keystone と同じ証明書を指定します。
[root@dlp ~(keystone)]#
vi /etc/nginx/nginx.conf
# 最終行に追記

stream {
    upstream glance-api {
        server 127.0.0.1:9292;
    }
    server {
        listen 10.0.0.30:9292 ssl;
        proxy_pass glance-api;
    }
    ssl_certificate "/etc/letsencrypt/live/dlp.srv.world/fullchain.pem";
    ssl_certificate_key "/etc/letsencrypt/live/dlp.srv.world/privkey.pem";
}

[root@dlp ~(keystone)]#
systemctl restart nginx
[6] SELinux を有効にしている場合は、ポリシーの変更が必要です。
[root@dlp ~(keystone)]#
setsebool -P glance_api_can_network on

[root@dlp ~(keystone)]#
vi glanceapi.te
# 以下の内容で新規作成

module glanceapi 1.0;

require {
        type glance_api_t;
        type mysqld_exec_t;
        type mysqld_safe_exec_t;
        type rpm_exec_t;
        type hostname_exec_t;
        type sudo_exec_t;
        type httpd_config_t;
        type iscsid_exec_t;
        type gpg_exec_t;
        type crontab_exec_t;
        type consolehelper_exec_t;
        type glance_port_t;
        type httpd_t;
        class tcp_socket name_bind;
        class dir search;
        class file { getattr open read };
}

#============= glance_api_t ==============
allow glance_api_t httpd_config_t:dir search;
allow glance_api_t mysqld_exec_t:file getattr;
allow glance_api_t mysqld_safe_exec_t:file getattr;
allow glance_api_t gpg_exec_t:file getattr;
allow glance_api_t hostname_exec_t:file getattr;
allow glance_api_t rpm_exec_t:file getattr;
allow glance_api_t sudo_exec_t:file getattr;
allow glance_api_t consolehelper_exec_t:file getattr;
allow glance_api_t crontab_exec_t:file getattr;
allow glance_api_t iscsid_exec_t:file { getattr open read };

#============= httpd_t ==============
allow httpd_t glance_port_t:tcp_socket name_bind;

[root@dlp ~(keystone)]#
checkmodule -m -M -o glanceapi.mod glanceapi.te

[root@dlp ~(keystone)]#
semodule_package --outfile glanceapi.pp --module glanceapi.mod

[root@dlp ~(keystone)]#
semodule -i glanceapi.pp

[7] Firewalld を有効にしている場合は、サービスポートの許可が必要です。
[root@dlp ~(keystone)]#
firewall-cmd --add-port=9292/tcp

success
[root@dlp ~(keystone)]#
firewall-cmd --runtime-to-permanent

success
関連コンテンツ