티스토리 뷰

728x90
반응형

본 포스팅은 OpenStack의 구성요소들을 수동으로 설치하는 방법에 대한 가이드입니다.


오픈스택은 Core 프로젝트 즉 주요 구성요소로 10가지를 채택하고 있습니다. 이들은 각자의 VM으로 구성되며 VM간의 연결을 위해 하이퍼바이저를 사용합니다. 본 포스팅에서는 각 구성요소들을 하나씩 수동으로 구성해 보고 연결과정에 대해 알아보겠습니다.

 

먼저 설치할 구성요소는 Identity Service인 keystone입니다.

OpenStack의 Identity 서비스는 인증, 인가 및 테넌트, 사용자, 역할을 생성합니다.
Identity 서비스에는 다음과 같은 구성 요소가 포함되어 있습니다.


- 서버
중앙 집중식 서버는 RESTful 인터페이스를 사용하는 인증 및 인가 서비스를 제공합니다.
- 드라이버
드라이버 또는 서비스 백엔드는 중앙집중식서버에 통합됩니다. OpenStack 외부의 Repository에서 Identity 정보에 액세스하는데 사용되며 OpenStack이 배포된 인프라(예: SQL 데이터베이스 또는 LDAP 서버)에 이미 있을 수 있습니다.
- 모듈
미들웨어 모듈은 Identity 서비스를 사용하는 OpenStack 구성요소의 주소 공간에서 실행됩니다. 서비스 요청을 Intercept하여 사용자 자격 증명을 추출한 다음 인증을 위해 중앙관리서버로 보냅니다. 미들웨어 모듈과 OpenStack 구성 요소 간의 통합에는 Python Web Server Gateway Interface가 사용됩니다.


 

OpenStack Identity Service Installation

Identity Service는 keystone이라는 프로젝트로 개발되었습니다. OpenStack은 오픈소스로써 이러한 프로젝트들이 핵심프로젝트로 올라가면 이를 실제 OpenStack에 반영하여 사용하고 실제 프로젝트 Name은 Module Name 및 CLI 환경에서 Command로 사용할 수 있습니다.

이에 Identity Service는 keystone이라는 모듈을 설치하는데서 부터 시작합니다.


- 본 테스트는 다음과 같은 환경에서 작성되었습니다.

[nrson@nrsonLinux~$]uname -a
Linux nrsonLinux 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[nrson@nrsonLinux~$]

- 본 포스팅에서는 다양한 설치가 이루어짐에 따라 필수로 설치되어야 하는 mysql, rabbitMQ등의 Install과정으 과감히 제거하였습니다. 별도의 포스팅에서 사전에 준비되야 하는 Package의 설치 과정을 설명드리겠습니다.

- 본 포스팅에서 설치되는 패키지들은 apt-get package manager를 통해 수행됩니다.


 

keystone 설치 이전 선행 작업

1. Database 생성


mysql> mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.7.23-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> CREATE DATABASE keystone;

Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'openstack1';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'openstack1';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>


2. 관리 토근 생성 (rand 함수로 무작위 hex 값을 추출합니다.)


[nrson@nrsonLinux~$]openssl rand -hex 10
a77fc9edac3440594f88
[nrson@nrsonLinux~$]


 

keystone Install

1. 필수 패키지를 설치합니다.


[nrson@nrsonLinux~$]sudo apt-get install keystone apache2 libapache2-mod-wsgi memcached python-memcache
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다
상태 정보를 읽는 중입니다... 완료

...

...
libapache2-mod-wsgi is the newest version (4.3.0-1.1build1).
python-memcache is the newest version (1.57-1).
apache2 is the newest version (2.4.18-2ubuntu3.9).
keystone is the newest version (2:9.3.0-0ubuntu3.2).
memcached is the newest version (1.4.25-2ubuntu1.4).


2. /etc/keystone/keystone.conf modify

admin_token은 openssl rand -hex 10 작성한 값입니다.


[nrson@nrsonLinux~$]sudo vi /etc/keystone/keystone.conf

[DEFAULT]

...

# admin_token을 주석을 풀고 앞서 생성한 관리토큰으로 변경합니다.

# admin_token = ADMIN

admin_token = a77fc9edac3440594f88

...

[database]

...

# connection을 선행작업에서 진행했던 정보를 기반으로 mysql+pymysql://dbid:dbpasswd@controller/databasename 으로 변경

# connection = sqlite:////var/lib/keystone/keystone.db
connection = mysql+pymysql://keystone:openstack1@localhost:3306/keystone

...

[memcache]

... 

# servers 주석을 해제합니다.

# servers = localhost:11211

servers = localhost:11211

...

[token]

...

# provider 주석을 해제합니다.

# provider = uuid

provider = uuid

# driver 주석 해제 및 memcache로 변경합니다.

# driver = sql

driver = memcache

...

[revoke]

...

# driver 주석을 해제합니다.

# driver = sql

driver = sql

...


3. keystone restart

설정한 내용을 반영하기 위해 keystone을 재시작합니다.


[nrson@nrsonLinux~$]sudo service keystone restart
[nrson@nrsonLinux~$]


4. keystone database 초기화

키스톤 데이터베이스를 생성하고 키스톤 서비스가 이 데이터베이스를 사용하도록 구성했지만 데이터베이스가 지금은 비어있는 상태입니다. 이에 작성한 keystone.conf 파일을 기준으로 데이터베이스의 스키마를 구축합니다.


[nrson@nrsonLinux~$]sudo su -s /bin/sh -c "keystone-manage db_sync" keystone

[nrson@nrsonLinux~$]


별다른 문제가 없을 경우 아무런 결과도 출력하지 않을 것입니다.

 

Apache HTTP Server 구성

1. /etc/apache2/apache2.conf


[nrson@nrsonLinux~$]sudo vi /etc/apache2/apache2.conf

...

ServerName 172.21.70.22

...


2. /etc/apache2/sites-available/wsgi-keystone.conf


[nrson@nrsonLinux~$]sudo vi /etc/apache2/sites-available/wsgi-keystone.conf
Listen 5000
Listen 35357

<VirtualHost *:5000>
    WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-public
    WSGIScriptAlias / /usr/bin/keystone-wsgi-public
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    <IfVersion >= 2.4>
      ErrorLogFormat "%{cu}t %M"
    </IfVersion>
    ErrorLog /var/log/apache2/keystone.log
    CustomLog /var/log/apache2/keystone_access.log combined

    <Directory /usr/bin>
        <IfVersion >= 2.4>
            Require all granted
        </IfVersion>
        <IfVersion < 2.4>
            Order allow,deny
            Allow from all
        </IfVersion>
    </Directory>
</VirtualHost>

<VirtualHost *:35357>
    WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-admin
    WSGIScriptAlias / /usr/bin/keystone-wsgi-admin
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    <IfVersion >= 2.4>
      ErrorLogFormat "%{cu}t %M"
    </IfVersion>
    ErrorLog /var/log/apache2/keystone.log
    CustomLog /var/log/apache2/keystone_access.log combined

    <Directory /usr/bin>
        <IfVersion >= 2.4>
            Require all granted
        </IfVersion>
        <IfVersion < 2.4>
            Order allow,deny
            Allow from all
        </IfVersion>
    </Directory>
</VirtualHost>


3. keystone 가상 호스트 활성화


[nrson@nrsonLinux~$]sudo ln -s /etc/apache2/sites-available/wsgi-keystone.conf /etc/apache2/sites-enabled
[nrson@nrsonLinux~$]


4. apache 재시작 및 keystone 설치시 함께 생성 되는 SQLiteDB를 제거합니다.


[nrson@nrsonLinux~$]sudo service apache2 restart
[nrson@nrsonLinux~$]sudo rm -f /var/lib/keystone/keystone.db
[nrson@nrsonLinux~$]


 

OpenStack Service Entity & API EndPoint 추가

지금부터는 OpenStack을 실제로 구성하는 단계입니다. 구성간 문제가 발생 시 참고 가능한 로그파일은 다음과 같습니다.

[nrson@nrsonLinux~$]sudo tail -f /var/log/keystone/keystone.log

1. profile 작성

OS_TOKEN은 openssl rand -hex 10 작성한 값입니다.


[nrson@nrsonLinux~$]vi ~/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
set -o vi
alias vi='vi'
export PS1="[\u@\h\w$]"

 

# keystone setting
export OS_TOKEN=ADMIN_TOKEN
export OS_TOKEN=a77fc9edac3440594f88
export OS_URL=http://172.21.70.22:35357/v2.0


2. Service Entity 생성


[nrson@nrsonLinux~$]openstack service create --name keystone --description "OpenStack Identity" identity
+-------------+------------------------------------------+
| Field       | Value                                             |
+-------------+------------------------------------------+
| description | OpenStack Identity                         |
| enabled     | True                                            |
| id             | 43b971fd1aae44d09a83a98baf38c478 |
| name        | keystone                                      |
| type          | identity                                        |
+-------------+------------------------------------------+
[nrson@nrsonLinux~$]


3. Identity Service EndPoint 생성

OpenStack은 각 서비스에 admin, internal, public 세 개의 API 엔드포인트를 사용합니다.

admin API 엔드포인트는 디폴트로 사용자와 tenant를 수정 할 수 있지만, public과 internal API는 해당 동작을 허용하지 않습니다.


[nrson@nrsonLinux~$]python2-openstack endpoint create --region RegionOne identity public http://172.21.70.22:5000/v2.0
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | afbfabcc36404814a2662996aa4157c7 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 49ad91a7e3244bdb90192c4565f1fe27 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://172.21.70.22:5000/v2.0    |
+--------------+----------------------------------+
[nrson@nrsonLinux~$]python2-openstack endpoint create --region RegionOne identity internal http://172.21.70.22:5000/v2.0
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 98fb2cbf052149ea8aaf1c5945c03861 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 49ad91a7e3244bdb90192c4565f1fe27 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://172.21.70.22:5000/v2.0    |
+--------------+----------------------------------+
[nrson@nrsonLinux~$]python2-openstack endpoint create --region RegionOne identity admin http://172.21.70.22:35357/v2.0
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 461f91e8dca947f1bd7e0f80cdfa768a |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 49ad91a7e3244bdb90192c4565f1fe27 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://172.21.70.22:35357/v2.0   |
+--------------+----------------------------------+
[nrson@nrsonLinux~$]


 

Tenant(Project), User, Role 생성

Identity 서비스는 각 OpenStack 서비스를 위한 인증 서비스를 제공합니다. 인증 서비스는 domains, projects (tenants), users, roles 를 결합하여 사용합니다.

1. Project (Tenants) 생성


[nrson@nrsonLinux~$]openstack project create --description "Admin Project" nrsonStack
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Admin Project                    |
| enabled     | True                             |
| id          | f0811cb886984f4a801578be8a06edfc |
| name        | nrsonStack                       |
+-------------+----------------------------------+
[nrson@nrsonLinux~$]openstack project create --description "Service Project" service
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Service Project                  |
| enabled     | True                             |
| id          | 16ffe3b92c634104b3989743e60c2e3d |
| name        | service                          |
+-------------+----------------------------------+
[nrson@nrsonLinux~$]openstack project create --description "Demo Project" demo
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Demo Project                     |
| enabled     | True                             |
| id          | 7e1f27d371d04f2da5b15fa9db5583f2 |
| name        | demo                             |
+-------------+----------------------------------+
[nrson@nrsonLinux~$]


총 3개의 Project를 생성하였습니다. nrsonStack은 admin용, Service는 서비스를 사용하는 사용자용, Demo는 관리권한이 없는 사용자용으로 구분하여 생성합니다.

2. User 생성


[nrson@nrsonLinux~$]openstack user create --password-prompt nrson
User Password:
Repeat User Password:
+----------+----------------------------------+
| Field    | Value                            |
+----------+----------------------------------+
| email    | None                             |
| enabled  | True                             |
| id       | b905da9125ad40d09b885af74e53745b |
| name     | nrson                            |
| username | nrson                            |
+----------+----------------------------------+
[nrson@nrsonLinux~$]openstack user create --password-prompt demo
User Password:
Repeat User Password:
+----------+----------------------------------+
| Field    | Value                            |
+----------+----------------------------------+
| email    | None                             |
| enabled  | True                             |
| id       | 4e5527bb4d2d4b3089d477279f4b5c60 |
| name     | demo                             |
| username | demo                             |
+----------+----------------------------------+
[nrson@nrsonLinux~$]


총 3명의 User를 생성하였습니다. nrson은 관리자로써 Demo는 사용자로써 사용 될 예정입니다.

3. Role 생성


[nrson@nrsonLinux~$]openstack role create admin
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | 9c336ee967b54ed5bd2bc474262980d1 |
| name      | admin                            |
+-----------+----------------------------------+
[nrson@nrsonLinux~$]openstack role create user
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | d840ab7059e545f28bee276cbff4e935 |
| name      | user                             |
+-----------+----------------------------------+
[nrson@nrsonLinux~$]


총 3개의 Role을 생성하였습니다. admin은 nrson 관리자용, user는 demo 사용자용으로 부여될 예정입니다.

4. Role 부여


[nrson@nrsonLinux~$]openstack role add --project nrsonStack --user nrson admin
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | 9c336ee967b54ed5bd2bc474262980d1 |
| name      | admin                            |
+-----------+----------------------------------+
[nrson@nrsonLinux~$]openstack role add --project demo --user demo user
[+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | d840ab7059e545f28bee276cbff4e935 |
| name      | user                             |
+-----------+----------------------------------+
[nrson@nrsonLinux~$]


위 Role 부여를 위한 동작은 openstack role add --project project_name --user user_name role_name 순으로 기입합니다.
총 2개의 Role을 각각 nrson 관리자에게 admin Role을 demo 사용자에게 user Role을 부여합니다.

 

검증과정

1. 보안상의 이유로, 임시 인증 토큰 방식을 비활성화합니다.

- [pipeline:public_api], [pipeline:admin_api], [pipeline:api_v3]에서 각각 admin_token_auth 제거

- unset OS_TOKEN OS_URL


[nrson@nrsonLinux~$]sudo vi /etc/keystone/keystone-paste.ini

...

[pipeline:public_api]
# The last item in this pipeline must be public_service or an equivalent
# application. It cannot be a filter.
pipeline = cors sizelimit url_normalize request_id admin_token_auth build_auth_context token_auth json_body ec2_extension public_service

[pipeline:admin_api]
# The last item in this pipeline must be admin_service or an equivalent
# application. It cannot be a filter.
pipeline = cors sizelimit url_normalize request_id admin_token_auth build_auth_context token_auth json_body ec2_extension s3_extension admin_service

[pipeline:api_v3]
# The last item in this pipeline must be service_v3 or an equivalent
# application. It cannot be a filter.
pipeline = cors sizelimit url_normalize request_id admin_token_auth build_auth_context token_auth json_body ec2_extension_v3 s3_extension service_v3

...


2. nrson 관리자의 인증토큰


[nrson@nrsonLinux~$]sudo openstack --os-auth-url http://172.21.70.22:35357/v3 --os-project-domain-id default --os-user-domain-id default --os-project-name nrsonStack --os-username nrson --os-auth-type password token issue
Password:
+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| expires    | 2018-08-08T10:34:22.000000Z      |
| id         | 5c812a0d30ac4adaabd17bd0e796941f |
| project_id | f0811cb886984f4a801578be8a06edfc |
| user_id    | b905da9125ad40d09b885af74e53745b |
+------------+----------------------------------+
[nrson@nrsonLinux~$]


- password는 nrson 관리자의 비밀번호입니다.

3. demo 사용자의 인증토큰


[nrson@nrsonLinux~$]sudo openstack --os-auth-url http://172.21.70.22:5000/v3 --os-project-domain-id default --os-user-domain-id default --os-project-name demo --os-username demo --os-auth-type password token issue
Password:
+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| expires    | 2018-08-09T03:24:14.000000Z      |
| id         | b1e0b2926f0641ddbbb3af047cb1f2c3 |
| project_id | 7e1f27d371d04f2da5b15fa9db5583f2 |
| user_id    | 4e5527bb4d2d4b3089d477279f4b5c60 |
+------------+----------------------------------+
[nrson@nrsonLinux~$]


- password는 demo 사용자의 비밀번호입니다.

 

사용자별 openrc 생성 및 테스트

현재까지 nrson 관리자, demo 사용자 유저를 생성하였습니다.

각 사용자별 Profile을 나누어 접근가능한 openrc를 생성하고 테스트 해 본 후 이번 포스팅을 마치도록 하겠습니다.

먼저 nrson 관리자 용 openrc 파일입니다.


[nrsonOpenrc.sh]

export OS_AUTH_URL=http://172.21.70.22:35357/v3
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=nrsonStack
export OS_USERNAME=nrson
export OS_PASSWORD=nrson
export OS_AUTH_TYPE=password
export OS_IDENTITY_API_VERSION=3


반영 방법은 source ./nrsonOpenrc.sh 입니다.

그럼 기존의 sudo openstack --os-auth-url http://172.21.70.22:35357/v3 --os-project-domain-id default --os-user-domain-id default --os-project-name nrsonStack --os-username nrson --os-auth-type password token issue 긴 명령어를 반영한 Profile에 맞게 수행해 보도록 하겠습니다.


root@nrsonLinux:~# openstack token issue
+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| expires    | 2018-08-09T03:45:35.000000Z      |
| id         | 9aad81f136d442ff8be394e593acb4f6 |
| project_id | f0811cb886984f4a801578be8a06edfc |
| user_id    | b905da9125ad40d09b885af74e53745b |
+------------+----------------------------------+
root@nrsonLinux:~#


다음으로 demo 사용자 용 openrc 파일입니다.


[demoOpenrc.sh]

export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=demo
export OS_TENANT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=demo
export OS_AUTH_URL=http://172.21.70.22:5000/v3
export OS_AUTH_TYPE=password
export OS_IDENTITY_API_VERSION=3


반영 방법은 source ./demoOpenrc.sh 입니다.

그럼 기존의 sudo openstack --os-auth-url http://172.21.70.22:5000/v3 --os-project-domain-id default --os-user-domain-id default --os-project-name demo --os-username demo --os-auth-type password token issue 긴 명령어를 반영한 Profile에 맞게 수행해 보도록 하겠습니다.


root@nrsonLinux:~# openstack token issue
+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| expires    | 2018-08-09T03:51:43.000000Z      |
| id         | c06ecc9a3db74d04b49b44a5c5070e33 |
| project_id | 7e1f27d371d04f2da5b15fa9db5583f2 |
| user_id    | 4e5527bb4d2d4b3089d477279f4b5c60 |
+------------+----------------------------------+
root@nrsonLinux:~#


 

지금까지 OpenStack 구성요소 인 키스톤(keystone) 아이덴티티 서비스를 구성해 보았습니다.

다음시간에는 글랜스(glance) 이미지 서비스에 대해 알아보겠습니다.

728x90
반응형