OpenStack Keystone架构二

简介:

 六 keystone架构

 

6.1 Keystone API 

Keystone API与Openstack其他服务的API类似,也是基于ReSTFul HTTP实现的。

Keystone API划分为Admin API和Public API:

  • Public API不仅实现获取版本以及相应扩展信息的操作,同时包括获取Token以及Token租户信息的操作;

  • Admin API主要提供服务开发者使用,不仅可以完成Public API的操作,同时对User、Tenant、Role和Service Endpoint进行管理操作。

6.2 Router
Keystone Router主要实现上层API和底层服务的映射和转换功能,包括四种Router类型。 
(1) AdminRouter 
负责将Admin API请求映射为相应的行为操作并转发至底层相应的服务执行; 
(2) PublicRouter 
与AdminRouter类似; 
(3) PublicVersionRouter 
对系统版本的请求API进行映射操作; 
(4) AdminVersionRouter 
与PublicVersionRouter类似。 
6.3 Services
Keystone Service接收上层不同Router发来的操作请求,并根据不同后端驱动完成相应操作,主要包括四种类型; 
(1) Identity Service 

Identity Service提供关于用户和用户组的授权认证及相关数据。

Keystone-10.0.0支持ldap.core.Identity,Sql.Identity两种后端驱动,系统默认的是Sql.Identity;

 users和groups

 

 (2) Resource Service

Resouse服务提供关于projects和domains的数据 

 projects和domains

 

 在v3版本中的唯一性概念

 

(3) Assignment Service 

Assignment Service提供role及role assignments的数据

 roles和role assignments

 

(4) Token Service 
Token Service提供认证和管理令牌token的功能,用户的credentials认证通过后就得到token

Keystone-10.0.0对于Token Service 
支持Kvs.Token,Memcache.Token,Memcache_pool.Token,Sql.Token四种后端驱动,系统默认的是kvs.Token
(5) Catalog Service 
Catalog Service提供service和Endpoint相关的管理操作(service即openstack所有服务,endpont即访问每个服务的url)

keystone-10.0.0对Catalog Service支持两种后端驱动:Sql.Catalog、Templated.Catalog两种后端驱动,系统默认的是templated.Catalog; 

(6) Policy Service 
Policy Service提供一个基于规则的授权驱动和规则管理

keystone-10.0.0对Policy Service支持两种后端驱动:rules.Policy,sql.Policy,默认使用sql.Policy
6.4 Backend Driver

Backend Driver具有多种类型,不同的Service选择不同的Backend Driver。

官方http://docs.openstack.org/developer/keystone/architecture.html#groups

回到顶部

七 keystone管理这些概念的方法

组件名称 管理对象 生成方法 保存方式 配置项
identity user,以及 user group - sql, ldap.core

[identity]

driver = keystone.identity.backends.[sql|ldap.core].Identity

token 用户的临时 token pki,pkiz,uuid sql, kvs,memcached

[token]

driver = keystone.token.persistence.backends.[sql|kvs|memcache|memcache_pool].Token

provider=keystone.token.providers.[pkiz|pki|uuid].Provider
credential EC2 credential
sql

[credential]

driver = keystone.credential.backends.sql.Credential

provider=keystone.token.providers.[core|fernet].Provider

catalog region,service,endpoint
sql|templated

[catalog]

driver = keystone.catalog.backends.[sql|templated].Catalog

assignment tenant,domain,role 以及它们与 user 之间的关系 external, password, token sql

[assignment]

methods = external, password, token

password = keystone.auth.plugins.password.Password

trust trust  sql

[trust]

driver = keystone.trust.backends.[sql].Trust

policy Keystone service 的用户鉴权策略
 ruels|sql

[default]

policy_file = policy.json

[policy]

driver = keystone.policy.backends.[ruels|sql].Policy

 

 

回到顶部

八 keystone-10.0.0代码结构展示 

keystone-manage 是个 CLI 工具,它通过和 Keystone service 交互来做一些无法使用 Keystone REST API 来进行的操作,包括:

  • db_sync: Sync the database.

  • db_version: Print the current migration version of the database.

  • mapping_purge: Purge the identity mapping table.

  • pki_setup: Initialize the certificates used to sign tokens.

  • saml_idp_metadata: Generate identity provider metadata.

  • ssl_setup: Generate certificates for SSL.

  • token_flush: Purge expired tokens.

每个Keystone 组件,比如 catalog, token 等都有一个单独的目录。
每个组件目录中:
routes.py 定义了该组件的 routes (routes 见 探索 OpenStack 之(11):cinder-api Service 启动过程分析 以及 WSGI / Paste deploy / Router 等介绍)。其中identity 和 assignment 分别定义了 admin 和 public 使用的 routes,分别供 admin service 和 public service 使用。 
controller.py 文件定义了该组件所管理的对象,比如 assignment 的controller.py 文件定义了 Tenant、Role、Project 等类。
core.py 定了了两个类 Manager 和 Driver。Manager 类对外提供该组件操作具体对象的方法入口; Driver 类定义了该组件需要其Driver实现类所提供的接口。
backend 目录下的每个文件是每个具体driver 的实现

下载keystone-10.0.0演示www.openstack.org

回到顶部

九 keystone服务启动

Keystone is an HTTP front-end to several services. Like other OpenStack applications, this is done using python WSGI interfaces and applications are configured together using Paste. The application’s HTTP endpoints are made up of pipelines of WSGI middleware。。。

详见:http://docs.openstack.org/developer/keystone/architecture.html

 

/usr/bin/keystone-all 会启动 keystone 的两个service:admin and main,它们分别对应 /etc/keystone/keystone-paste.ini 文件中的两个composite:

可见 admin service 提供给administrator 使用;main 提供给 public 使用。它们分别都有 V2.0 和 V3 版本,只是目前的 keystone Cli 只支持 V2.0.比较下 admin 和 public:

名称 middlewares factory 功能区别
admin 比 public 多 s3_extension keystone.service:public_app_factory

从 factory 函数来看, admin service 比 public service 多了 identity 管理功能, 以及 assignment 的admin/public 区别:

1. admin 多了对 GET /users/{user_id} 的支持,多了 get_all_projects, get_project,get_user_roles 等功能

2. keystone 对 admin service 提供 admin extensions, 比如 OS-KSADM 等;对 public service 提供 public extensions。

简单总结一下, public service 主要提供了身份验证和目录服务功能;admin service 增加了 tenant、user、role、user group 的管理功能。

public

sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body_v2

json_body ec2_extension user_crud_extension

keystone.service:admin_app_factory

 

/usr/bin/keystone-all 会启动 admin 和 public 两个 service,分别绑定不同 host 和 端口。默认的话,绑定host 都是 0.0.0.0; admin 的绑定端口是 35357 (admin_port), public 的绑定端口是 5000 (public_port)。因此,给 admin 使用的 OS_AUTH_URL 为 http://controller:35357/v2.0, 给 public 使用的 OS_AUTH_URL=http://controller:5000/v2.0

 

keystone详细说明

WSGI server的父进程(50511号进程)开启两个socket去分别监听本环境的5000和35357号端口,
其中5000号端口是为main的WSGI server提供的,35357号端口为admin的WSGI server提供的。
即WSGI server的父进程接收到5000号端口的HTTP请求时,则将把该请求转发给为main开启的WSGI server去处理,
而WSGI server的父进程接收到35357号端口的HTTP请求时,则将把该请求转发给为admin开启的WSGI server去处理。

vim /etc/keystone/keystone-paste.ini

日志
2016-09-14 11:53:01.037 12698 INFO keystone.common.wsgi [req-07b28d5b-084c-467e-b45a-a4c8a52b7e96
9ff041112e454cca9b54bf117a80ca29 15426931fe4746d08736c5e5c1da6b1c 
- 6e495643fb014e5e8a3992c69d80d234 6e495643fb014e5e8a3992c69d80d234] 
GET http://controller02:35357/v3/auth/tokens


(1) type = composite

这个类型的section会把URL请求分发到对应的Application,use表明具体的分发方式,比如”egg:Paste#urlmap”表示使用Paste包中的urlmap模块,这个section里的其他形式如”key = value”的行是使用urlmap进行分发时的参数。

(2) type = app

一个app就是一个具体的WSGI Application。

(3) type = filter-app

接收一个请求后,会首先调用filter-app中的use所指定的app进行过滤,如果这个请求没有被过滤,就会转发到next所指定的app进行下一步的处理。

(4) type = filter

与filter-app类型的区别只是没有next。

(5) type = pipeline

pipeline由一系列filter组成。这个filter链条的末尾是一个app。pipeline类型主要是对filter-app进行了简化,
否则,如果多个filter,就需要多个filter-app,然后使用next进行连接。OpenStack的paste的deploy的配置文件主要采用的pipeline的方式。
因为url为http://192.168.118.1:5000/v2.0/tokens,因为基本url的后面接的信息为/v2.0,所以将到public_api的section作相应操作。



本文转自 OpenStack2015 51CTO博客,原文链接:http://blog.51cto.com/andyliu/1902617,如需转载请自行联系原作者
相关文章
|
8月前
|
数据安全/隐私保护
(二)Open Stack(M)----Keystone安装和配置(下)
(二)Open Stack(M)----Keystone安装和配置(下)
62 0
|
4月前
|
关系型数据库 MySQL 数据库
云计算|OpenStack|社区版OpenStack安装部署文档(三 --- 身份认证服务keystone安装部署---Rocky版)
云计算|OpenStack|社区版OpenStack安装部署文档(三 --- 身份认证服务keystone安装部署---Rocky版)
58 0
|
11月前
|
分布式计算 安全 前端开发
【私有云架构】Openstack VS CloudStack:比较异同
【私有云架构】Openstack VS CloudStack:比较异同
|
11月前
|
存储 关系型数据库 MySQL
【私有云架构】Cloudstack 与 OpenStack:哪个更适合您?
【私有云架构】Cloudstack 与 OpenStack:哪个更适合您?
|
11月前
|
存储 Linux API
「网络架构」OpenStack 脊页网络(Spine Leaf Networking) 介绍
「网络架构」OpenStack 脊页网络(Spine Leaf Networking) 介绍
|
11月前
Openstack架构构建及详解(7)--Cinder组件
Openstack架构构建及详解(7)--Cinder组件
91 0
|
11月前
|
Windows
Openstack架构构建及详解(6)--Dashboard组件
Openstack架构构建及详解(6)--Dashboard组件
145 0
|
11月前
|
网络架构
Openstack架构构建及详解(5)--Neutron组件
Openstack架构构建及详解(5)--Neutron组件
84 0
|
11月前
|
云计算 虚拟化 开发者
Openstack架构构建及详解(4)--Nova组件
Openstack架构构建及详解(4)--Nova组件
417 0
|
网络协议 Linux 网络安全
openstack 云平台一体化部署(超详细)
openstack 云平台一体化部署(超详细)
817 0
openstack 云平台一体化部署(超详细)