O01八、理解 Keystone 核心概念

 
做爲OpenStack的基礎支持服務,Keystone作了下面幾件事情:
 
    一、管理用戶及其權限
    二、維護 OpenStack Services 的 Endpoint
    三、Authentication(認證)和 Authorization(鑑權)
 
學習 Keystone,得理解這些概念:
 
 
User
 
User 指代任何使用OpenStack的實體,能夠是真正的用戶,其餘系統或者服務。
 
 
當 User 請求訪問 OpenStack時,Keystone會對其進行驗證。Horizon 在 identity -> Users 管理 User
 
 
除了 admin 和 demo ,OpenStack也未 nova 、cinder 、glance、neutron 服務建立了對應 User。admin也能夠管理這些User。
 
 
Credentials
 
Credentials 是User 用來證實本身身份的信息,能夠是:
 
    一、用戶名/密碼
    二、Token
    三、API Key
    四、其餘高級方式
 
 
Authorization
 
Authorization 是 Keystone驗證 User 身份的過程。User訪問OpenStack 時向 Keystone 提交用戶名和密碼形式的 Credentials,Keystone 驗證經過後會給User 簽發一個Token做爲後續訪問的Credentials。
 
 
Token
 
Token 是由數字和字母組成的字符串,User 成功Authorization 後 Keystone生成 Token 並分配給User。
 
    一、Token 用作訪問Service 的Credentials
    二、Service會經過Keystone 驗證Token的有效性
    三、Token的有效期默認是24小時
 
 
Project
 
Project 用於將OpenStack的資源(計算、存儲和網絡)進行分組和隔離。根據OpenStack服務對象的不一樣,Project能夠是一個客戶(公有云、也叫租戶)、部門或者項目組(私有云)。
 
這裏須要注意:
 
    一、資源的全部權是屬於Project的,而不是User
    二、在OpenStack的界面和文檔中,Tenant、Project、Account 這幾個術語是通用的,但長期看會傾向於使用Project
    三、每一個User(包括admin)必須掛載Project裏才能訪問該Project的資源。一個User能夠屬於多個Project
    四、admin 至關於root用戶,具備最高權限
 
 
Horizon 在 Identity ->  Projects 中管理 Project
 
 
經過 Manage Members 將 User 添加到 Project
 
 
Service
 
OpenStack 的 Service 包括 Compute(Nova)、Block Storage(Cinder)、Object Storage(Swift)、Image Service(Glance)、Networking Service(Neutron)等。每一個 Service都會提供若干個 Endpoint,User 經過 Endpoint 訪問資源和執行操做。
 
 
Endpoint
 
Endpoint 是一個網絡上能夠訪問的地址,一般是一個URL。Service 經過Endpoint暴露本身的API。Keystone 負責管理和維護每一個 Service 的Endpoint。
 
 
可使用下面的命令來查看 Endpoint
 
root@DevStack-Controller:~# su - stack
 
stack@DevStack-Controller:~$ source devstack/openrc admin admin
WARNING: setting legacy OS_TENANT_NAME to support cli tools.
stack@DevStack-Controller:~$ openstack catalog list
+-------------+----------------+--------------------------------------------------------------------------+
| Name        | Type           | Endpoints                                                                |
+-------------+----------------+--------------------------------------------------------------------------+
| nova_legacy | compute_legacy | RegionOne                                                                |
|             |                |   internal: http://10.12.31.241:8774/v2/c2b9e5f4a15d43218f3fca6e13c49a3a |
|             |                | RegionOne                                                                |
|             |                |   admin: http://10.12.31.241:8774/v2/c2b9e5f4a15d43218f3fca6e13c49a3a    |
|             |                | RegionOne                                                                |
|             |                |   public: http://10.12.31.241:8774/v2/c2b9e5f4a15d43218f3fca6e13c49a3a   |
|             |                |                                                                          |
| nova        | compute        | RegionOne                                                                |
|             |                |   public: http://10.12.31.241:8774/v2.1                                  |
|             |                | RegionOne                                                                |
|             |                |   admin: http://10.12.31.241:8774/v2.1                                   |
|             |                | RegionOne                                                                |
|             |                |   internal: http://10.12.31.241:8774/v2.1                                |
|             |                |                                                                          |
| placement   | placement      | RegionOne                                                                |
|             |                |   admin: http://10.12.31.241/placement                                   |
|             |                | RegionOne                                                                |
|             |                |   public: http://10.12.31.241/placement                                  |
|             |                | RegionOne                                                                |
|             |                |   internal: http://10.12.31.241/placement                                |
|             |                |                                                                          |
| neutron     | network        | RegionOne                                                                |
|             |                |   internal: http://10.12.31.241:9696/                                    |
|             |                | RegionOne                                                                |
|             |                |   admin: http://10.12.31.241:9696/                                       |
|             |                | RegionOne                                                                |
|             |                |   public: http://10.12.31.241:9696/                                      |
|             |                |                                                                          |
| cinder      | volume         | RegionOne                                                                |
|             |                |   public: http://10.12.31.241:8776/v1/c2b9e5f4a15d43218f3fca6e13c49a3a   |
|             |                | RegionOne                                                                |
|             |                |   internal: http://10.12.31.241:8776/v1/c2b9e5f4a15d43218f3fca6e13c49a3a |
|             |                | RegionOne                                                                |
|             |                |   admin: http://10.12.31.241:8776/v1/c2b9e5f4a15d43218f3fca6e13c49a3a    |
|             |                |                                                                          |
| cinderv2    | volumev2       | RegionOne                                                                |
|             |                |   internal: http://10.12.31.241:8776/v2/c2b9e5f4a15d43218f3fca6e13c49a3a |
|             |                | RegionOne                                                                |
|             |                |   public: http://10.12.31.241:8776/v2/c2b9e5f4a15d43218f3fca6e13c49a3a   |
|             |                | RegionOne                                                                |
|             |                |   admin: http://10.12.31.241:8776/v2/c2b9e5f4a15d43218f3fca6e13c49a3a    |
|             |                |                                                                          |
| glance      | image          | RegionOne                                                                |
|             |                |   admin: http://10.12.31.241:9292                                        |
|             |                | RegionOne                                                                |
|             |                |   public: http://10.12.31.241:9292                                       |
|             |                | RegionOne                                                                |
|             |                |   internal: http://10.12.31.241:9292                                     |
|             |                |                                                                          |
| keystone    | identity       | RegionOne                                                                |
|             |                |   public: http://10.12.31.241/identity                                   |
|             |                | RegionOne                                                                |
|             |                |   admin: http://10.12.31.241/identity_admin                              |
|             |                | RegionOne                                                                |
|             |                |   internal: http://10.12.31.241/identity                                 |
|             |                |                                                                          |
| cinderv3    | volumev3       | RegionOne                                                                |
|             |                |   admin: http://10.12.31.241:8776/v3/c2b9e5f4a15d43218f3fca6e13c49a3a    |
|             |                | RegionOne                                                                |
|             |                |   internal: http://10.12.31.241:8776/v3/c2b9e5f4a15d43218f3fca6e13c49a3a |
|             |                | RegionOne                                                                |
|             |                |   public: http://10.12.31.241:8776/v3/c2b9e5f4a15d43218f3fca6e13c49a3a   |
|             |                |                                                                          |
+-------------+----------------+--------------------------------------------------------------------------+
 
Role
 
安全包含兩部分:Authentication(認證)和Authorization(鑑權)
 
Authentication    解決「你是誰」的問題
Authorization      解決「你能幹什麼的」的問題
 
Keystone 藉助 Role 實現 Authorization
 
stack@DevStack-Controller:~$ openstack role list
+----------------------------------+---------------+
| ID                               | Name          |
+----------------------------------+---------------+
| 27b9f9c4662f43c3b7105e850c379178 | ResellerAdmin |
| 3f30d75f5f36462188912589b6836845 | admin         |
| 4449fc37d1ca4553b01aeb13a9ade335 | service       |
| 7eaba228090b4b9085b3ae6dd5350779 | anotherrole   |
| 9fe2ff9ee4384b1894a90878d3e92bab | _member_      |
| ac26bf535bec47549f8da39809fc79a4 | Member        |
+----------------------------------+---------------+
 
    一、Keystone定義 Role
    二、能夠爲 User 分配一個或者多個 Role ,Horizon的菜單爲 Identity -> Project -> Manage Members 
 
 
    三、Service 決定每一個Role 能作什麼事情。Service 經過各自的 policy.json 文件對 Role 進行訪問控制。下面是 Nova 服務的json文件
 
cat /etc/nova/policy.json
 
 
上面配置的含義是:對於 create、attach_network 和 attach_volume 操做,任何 Role 的User 均可以執行; 但只有admin 這個Role 的User 才能執行 forced_host 操做。
 
OpenStack 默認配置只區分 admin  和 非admin Role。若是須要對特定的Role 進行受權,能夠修改 policy.json 。
相關文章
相關標籤/搜索