Openstack组件部署 — keystone(domain, projects, users, and roles)
目录
前文列表
Openstack组件部署 — Overview和前期环境准备
Openstack组建部署 — Environment of Controller Node
Openstack组件部署 — Keystone功能介绍与认证实现流程
Openstack组件部署 — Keystone Install & Create service entity and API endpoints
Create a domain, projects, users, and roles
The Identity service provides authentication services for each OpenStack service. The authentication service uses a combination of domains, projects (tenants), users, and roles.
Identity service为每一个Openstack service都提供了身份认证的服务,而身份认证服务使用domains, projects (tenants), users, and roles的组合来实现。
domain, projects, users, and roles的意义和作用
Create the default domain
在上一篇Openstack组件部署 — Keystone Install & Create service entity and API endpoints中解释了,因为MySQL数据库里默认是没有任何authentication 和catalog services信息的,但是在调用Keystone的服务时,首先就需要进行token的校验,这样显然无法完成。所以如果想在这样的情况下使用Keystone服务,我们可以为其指定一个临时的Token(keystone.conf中的admin_token参数项),并且定义一个OS_TOKEN系统变量,Keystone会通过匹配OS_TOKEN和admin_token的值是否一致来确定是否能够使用Keystone的服务。如果不一致时,就会触发An unexpected error prevented the server from fulfilling your request. 的ERROR。
加载临时token的环境变量:
[root@controller ~]# cat auth_token
export OS_TOKEN=c44048d3212d3f977643
export OS_URL=http://controller.jmilk.com:35357/v3
export OS_IDENTITY_API_VERSION=3
[root@controller ~]# source auth_token
创建domain:
[root@controller ~]# openstack domain create --description "Default Domain" default
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Default Domain |
| enabled | True |
| id | 011fbf8c04f1479ab1a4e49b019b22d1 |
| name | default |
+-------------+----------------------------------+
Create the service project(tenant)
This guide uses a service project that contains a unique user for each service that you add to your environment.
每一个Openstack service在service tenant都含有唯一的user。Openstack需要使用这个service tenant来将所有的Openstack service关联起来。
[root@controller ~]# openstack project create --domain default --description "Service Project" service
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Service Project |
| domain_id | 011fbf8c04f1479ab1a4e49b019b22d1 |
| enabled | True |
| id | 358f241ed9ad4a2faf1e9796d761e4bf |
| is_domain | False |
| name | service |
| parent_id | 011fbf8c04f1479ab1a4e49b019b22d1 |
+-------------+----------------------------------+
创建用于管理的用户、租户和角色
Create the admin project(tenant)
Create an administrative project, user, and role for administrative operations in your environment
为了在你的环境上执行管理操作,需要创建管理项目、用户和角色。
创建一个属于default
域的tenant(租户)
[root@controller ~]# openstack project create --domain default --description "Admin Project" admin
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Admin Project |
| domain_id | 011fbf8c04f1479ab1a4e49b019b22d1 |
| enabled | True |
| id | 6c04f1d3ecd04aafb427f4f8d01be534 |
| is_domain | False |
| name | admin |
| parent_id | 011fbf8c04f1479ab1a4e49b019b22d1 |
+-------------+----------------------------------+
Note:Openstack会使用动态的id。
Create the admin user
需要为user设定密码。
[root@controller ~]# openstack user create --domain default --password-prompt admin
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | 011fbf8c04f1479ab1a4e49b019b22d1 |
| enabled | True |
| id | d5e5331d665540159f1bfabb7327eca5 |
| name | admin |
+-----------+----------------------------------+
Create the admin role
[root@controller ~]# openstack role create admin
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | 192f3667f323410b83497d8898d2ec80 |
| name | admin |
+-----------+----------------------------------+
Add the admin role to the admin project and user
添加admin tenant、admin user到admin role中
[root@controller ~]# openstack role add --project admin --user admin admin
Note:Any roles that you create must map to roles specified in the policy.json file in the configuration file directory of each OpenStack service. The default policy for most services grants administrative access to the admin role.
注意:所有创建的roles都必须要映射到每一个Openstack service特定的policy.json
配置文件中,默认的policy会将大多数的services的管理权限授予admin角色。所以上面我们创建了default domain、admin tenant、admin user、admin role,并且将tenant和user绑定到了roles中,这样的话tenant和user就拥有了admin role的权限。
/etc/keystone/policy.json
创建一般用户、租户和角色
Create the demo project(tenant)
Regular (non-admin) tasks should use an unprivileged project and user. As an example, this guide creates the demo project and user.
在Openstack中一般的任务我们都应该使用一个没有太多权限的project(tenant)和user来操作。在这里我们创建一个demo user。
[root@controller ~]# openstack project create --domain default --description "Demo Project" demo
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Demo Project |
| domain_id | 011fbf8c04f1479ab1a4e49b019b22d1 |
| enabled | True |
| id | 4e069f1af37c4a37910e838365213530 |
| is_domain | False |
| name | demo |
| parent_id | 011fbf8c04f1479ab1a4e49b019b22d1 |
+-------------+----------------------------------+
Note:Do not repeat this step when creating additional users for this project.
Create the demo user:
[root@controller ~]# openstack user create --domain default --password-prompt demo
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | 011fbf8c04f1479ab1a4e49b019b22d1 |
| enabled | True |
| id | 27549a09628a453ea4fea34feb201855 |
| name | demo |
+-----------+----------------------------------+
Create the user role
[root@controller ~]# openstack role create user
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | ed533bf15c0b4487a7023c3d489c9411 |
| name | user |
+-----------+----------------------------------+
Add the user role to the demo project and user
[root@controller ~]# openstack role add --project demo --user demo user
Verify operation 验证操作
在安装Openstack的其他services之前,我们需要确定Keystone service能够正常使用。
Step1.For security reasons, disable the temporary authentication token mechanism
出于安全考虑,我们现在可以禁用掉临时的认证token机制。
Edit the /etc/keystone/keystone-paste.ini file and remove admin_token_auth from the [pipeline:public_api], [pipeline:admin_api], and [pipeline:api_v3] sections.
将/etc/keystone/keystone-paste.ini
文件中的节点[pipeline:public_api]
、[pipeline:admin_api]
、[pipeline:api_v3]
中的admin_token_auth
参数删除。
vim /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 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 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 build_auth_context token_auth json_body ec2_extension_v3 s3_extension service_v3
Step2.Unset the temporary OS_TOKEN and OS_URL environment variables
[root@controller ~]# unset OS_TOKEN OS_URL
Step3.As the admin user, request an authentication token
使用admin user来请求获取authentication token
获取一个authentication token需要指定:
--os-auth-url
确定keystone service,并且admin用户需要使用Post:35357来区分,Post:35357是admin专用的Endpoint。--os-project-domain-name
确定一个admin tenant所处在的domain--os-user-domain-name
确定admin user所处在的domainos-project-name
确定admin tenant--os-username
确定admin user,这样才能唯一的定位到一个user,之后在指定申请token
注意:因为在之前创建了admin tenant、admin user、admin role,就是说现在数据库中已经存在了admin user的相关信息,所以keystone可以在不需要使用临时token的情况下直接申请admin user的token。 —— 也就是说如果一个User希望从Keystone上申请到一个Token并以此来登陆Openstack进行操作的话,首先需要创建这个User和对应的tenant并将其加入role中。
[root@controller ~]# openstack --os-auth-url http://controller.jmilk.com:35357/v3 \
> --os-project-domain-name default --os-user-domain-name default \
> --os-project-name admin --os-username admin token issue
Password:
+------------+----------------------------------------------------------------------------+
| Field | Value |
+------------+----------------------------------------------------------------------------+
| expires | 2016-06-15T16:15:15.389159Z |
| id | gAAAAABXYXEDwdmX7VMLYkNas7r_aAz91zrfUvoJCwGLIE6qOWcdjVH9NjJwNl3bkeYaspbrm9 |
| | _Ygm_Eba8kUNUnipTHM8D9ASOxOV4BQUmn- |
| | uSZO9vmrHy91B7vx3vfidKz2_83X5PhOMhZxrFkluYzsJtIuH9T0UTiuaVA_THJ4zNOXzKYEtA |
| project_id | 6c04f1d3ecd04aafb427f4f8d01be534 |
| user_id | d5e5331d665540159f1bfabb7327eca5 |
+------------+----------------------------------------------------------------------------+
ERROR:Unable to establish connection to http://controller:35357/v3/auth/tokens
出现这个错误时候,检查认证Endpoint URL选项--os-auth-url
的参数是否正确,openstack需要通过Endpoint URL来确定auth-Keystone服务。
Step4.As the demo user, request an authentication token
[root@controller ~]# openstack --os-auth-url http://controller.jmilk.com:5000/v3 \
> --os-project-domain-name default --os-user-domain-name default \
> --os-project-name demo --os-username demo token issue
Password:
+------------+----------------------------------------------------------------------------+
| Field | Value |
+------------+----------------------------------------------------------------------------+
| expires | 2016-06-15T16:26:46.556759Z |
| id | gAAAAABXYXO2Tn4c9mO5TAY5gBeGxgSRmbAkDRfB8gyuELVtAB6BVARzY8d6OL9diCtAy- |
| | mNyY3uA7DFBrnKoTtyu5jX5oEf9ax61q8StnYjNDtRdiOKLN2Q23f- |
| | jNYALrWUkr91Z98oLD7LVrjRLcSaC-XCpK5tB-kU-Piyu7Y0rzbEXM06AIo |
| project_id | 4e069f1af37c4a37910e838365213530 |
| user_id | 27549a09628a453ea4fea34feb201855 |
+------------+----------------------------------------------------------------------------+
Note:This command uses the password for the demo user and API port 5000 which only allows regular (non-admin) access to the Identity service API.
注意:非管理员账户使用Port:5000来定位Keystone service。
Step5.使用admin账户身份来查看project、user、role的列表
[root@controller ~]# openstack --os-auth-url http://controller.jmilk.com:35357/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name admin --os-username admin project list
Password:
+----------------------------------+---------+
| ID | Name |
+----------------------------------+---------+
| 358f241ed9ad4a2faf1e9796d761e4bf | service |
| 4e069f1af37c4a37910e838365213530 | demo |
| 6c04f1d3ecd04aafb427f4f8d01be534 | admin |
+----------------------------------+---------+
[root@controller ~]# openstack --os-auth-url http://controller.jmilk.com:35357/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name admin --os-username admin user list
Password:
+----------------------------------+-------+
| ID | Name |
+----------------------------------+-------+
| 27549a09628a453ea4fea34feb201855 | demo |
| d5e5331d665540159f1bfabb7327eca5 | admin |
+----------------------------------+-------+
[root@controller ~]# openstack --os-auth-url http://controller.jmilk.com:35357/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name admin --os-username admin role list
Password:
+----------------------------------+-------+
| ID | Name |
+----------------------------------+-------+
| 192f3667f323410b83497d8898d2ec80 | admin |
| ed533bf15c0b4487a7023c3d489c9411 | user |
+----------------------------------+-------+
Create OpenStack client environment scripts
The previous section used a combination of environment variables and command options to interact with the Identity service via the openstack client. To increase efficiency of client operations, OpenStack supports simple client environment scripts also known as OpenRC files. These scripts typically contain common options for all clients, but also support unique options。
在上面的操作中,我们通过openstack client使用了环境变量和指令选项的组合来进行操作。为了增加openstack client的操作效率(每一次都需要使用--os-auth-url
这类的选项实在是非常繁复),Openstack支持简易的环境脚本,也称之为OpenRC文件。这些脚本可以包含有常用的openstack client选项,但是每一个脚本只支持唯一的选项值。简而言之,使用这些脚本能够让我们不需要为每一条openstack client指令都添加这么多的认证选项。
Edit the admin-openrc file and add the following content
为admin user创建OpenRC文件
vim ~/admin-openrc
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=fanguiju #给出admin的password
export OS_AUTH_URL=http://controller.jmilk.com:35357/v3 #给出admin的Endpoint
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
Edit the demo-openrc file and add the following content
为demo user创建OpenRC文件
vim ~/demo-openrc
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=fanguiju
export OS_AUTH_URL=http://controller.jmilk.com:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
Using the scripts
[root@controller ~]# . admin-openrc
[root@controller ~]# openstack token issue
+------------+----------------------------------------------------------------------------+
| Field | Value |
+------------+----------------------------------------------------------------------------+
| expires | 2016-06-15T16:59:48.937673Z |
| id | gAAAAABXYXt0PviJjz-fzA89XNr7w2KxM5jOOzg868rTDLXE- |
| | 2l__BMNLBYDX0nWKlrjlLRvqwFXMpAL2WhAlZVEZis6Ud-dqcSA4JV- |
| | 4Ehr9aRCwSK3cm4L_eHnoLeAoDU- |
| | 40RYHViL0GB3kav8ML5DbTGNRPq3aHVNsvQHgkfAWiHKm9YM5xo |
| project_id | 6c04f1d3ecd04aafb427f4f8d01be534 |
| user_id | d5e5331d665540159f1bfabb7327eca5 |
+------------+----------------------------------------------------------------------------+
再次获取admin的token变得非常的简单
最后
到这里Keystone组件的安装就全部结束了。 : )
Openstack组件部署 — keystone(domain, projects, users, and roles)的更多相关文章
- Openstack组件部署 — Keystone Install & Create service entity and API endpoints
目录 目录 前文列表 Install and configure Prerequisites 先决条件 Create the database for identity service 生成一个随机数 ...
- Openstack组件部署 — Keystone功能介绍与认证实现流程
目录 目录 前文列表 Keystone认证服务 Keystone认证服务中的概念 Keystone的验证过程 简单来说 前文列表 Openstack组件部署 - Overview和前期环境准备 Ope ...
- Openstack组件部署 — Networking service_Compute Node
目录 目录 前文列表 安装组件 配置通用组件 配置自服务网络选项 配置Linux 桥接代理 配置Nova使用网络 完成安装 验证操作Execute following commands on Cont ...
- Openstack组件部署 — Networking service_安装并配置Controller Node
目录 目录 前文列表 前提条件 网络环境 完成下面的步骤以创建数据库 创建service credentials服务凭证 创建Neutron的API Endpoints 配置自服务网络 安装网络组件 ...
- Openstack组件部署 — Netwotking service组件介绍与网络基本概念
目录 目录 前文列表 Openstack Networking serivce 基本的Neutron概念 Neutron的抽象对象 网络networks 子网subnets 路由器routers 端口 ...
- Openstack组件部署 — Nova_Install and configure a compute node
目录 目录 前文列表 Prerequisites 先决条件 Install and configure a compute node Install the packages Edit the etc ...
- Openstack组件部署 — Nova_安装和配置Controller Node
目录 目录 前文列表 Prerequisites 先决条件 To create the databases To create the service credentials Create the C ...
- Openstack组件部署 — Nova overview
目录 目录 前文列表 前言 Compute service overview Nova 的组件 nova-api service nova-api-metadata service nova-comp ...
- openstack组件之keystone
一 什么是keystone keystone是 OpenStack Identity Service 的项目名称.它在整个体系中充当一个授权者的角色. Keystone项目的主要目的是给整个opens ...
随机推荐
- AGC024B Backfront
题目大意 给你一个1~n的排列 你有两个操作:将一个数移到最后或将一个数移到最前 问将排列排序最少要几次操作 分析 年纪大了,脑子不行了.. 实际我们只需求出对与一段连续的数它在排列中已经有序的最长长 ...
- 使用Docker快速部署Gitlab
使用Docker部署Gitlab 1. 下载gitlab镜像 docker pull gitlab/gitlab-ce 2. 运行gitlab实例 GITLAB_HOME=`pwd`/data/git ...
- 头疼3-4次的问题,数据从DB导出到EXCEL,再从EXCEL导入到DB,数据格式发生错误 ,导致 程序出错。
反思: 1 解决 问题的思路 绕远了: 在这个问题出现前,程序是运行正确 的 问题出现前,我误删了DB 的 testcase表的所有 case ,然后 再把邮件 中的excel数据导入到 DB 然后 ...
- JumpServer堡垒机安装笔记
厂商文档--一步一步安装CentOS(https://jumpserver.readthedocs.io/zh/master/setup_by_centos.html) 厂商文档--简单优化(http ...
- VB - 变量
Cbool函数将变量转换成布尔值: Cbyte函数将变量转换为0到255之间的整数. Ccur函数.Cdbl函数和Csng函数将变量转换为浮点数值,前者只精确到小数点后四位,后两者要更加精确,数值的范 ...
- [LeetCode] 196.删除重复的电子邮箱
编写一个 SQL 查询,来删除 Person 表中所有重复的电子邮箱,重复的邮箱里只保留 Id 最小 的那个. +----+------------------+ | Id | Email | +-- ...
- 《穷爸爸富爸爸——Cashflow》
读<穷爸爸富爸爸>大约两年前了,当时对理财没什么概念,除了支付宝,就是京东小金库,哪个利率高就存哪个里.记忆中除了感觉这应该是有一定经济基础的人通常做的事,工薪阶级的自己还未达标,工资除了 ...
- Vue中src属性绑定的问题
地址:https://blog.csdn.net/qq_25479327/article/details/80082520 地址:https://blog.csdn.net/sinat_3655513 ...
- C++中函数模板的深入理解
1,函数模板深入理解: 1,编译器从函数模板通过具体类型产生不同的函数: 1,模板就是模子,通过这个模子可以产生很多的实物: 2,函数模板就是编译器用来产生具体函数的模子: 2,编译器会对函数模板进行 ...
- [Fw]初探linux中断系统(1)
1. 重要接口 LDD上说,“内核维护了一个中断信号线的注册表,该注册表类似于I/O端口的注册表.模块在使用中断前要先请求一个中断通道(或者中断请求IRQ),然后在使用后释放该通道.” 撇开系统如何遍 ...