security use blockdev in virtual env

我前面写了一篇关于ceph块设备的使用,

http://blog.163.com/digoal@126/blog/static/1638770402014112325944867/

使用块设备功能时, 客户端需要安装rbd模块, 并且需要能连接到ceph集群.

然后客户端就可以肆无忌惮的创建镜像, 映射块设备.

如果在IaaS环境中, 虚拟机直接连接存储的话, 这显然是不安全的, 因为虚拟机的用户可以肆无忌惮的操作ceph集群.

那么CEPH要在云环境中使用, 如何来加固呢?

如图 : 

显然虚拟机并不是直接和CEPH集群连接的, 

宿主机连接CEPH集群, 在宿主机上创建块设备或在CEPH FS中创建QEMU镜像文件, 通过libvirt指派给虚拟机.

所以虚拟机看到的虚拟硬盘是安全的,

虚拟机也不需要RBD模块, 不需要连接到ceph集群.

在DOCKER环境中, 也可以这么来用.

但是有点问题, 权限受到限制.

[root@localhost rbd1]# docker run -t -i --rm --device=/dev/rbd3:/dev/xvdc centos:centos6 /bin/bash
[root@3cce0bbf3b9e /]# ll /dev/xvdc
brw-rw---- 1 root root 249, 0 Dec 23 16:47 /dev/xvdc
[root@3cce0bbf3b9e /]# mount /dev/xvdc /mnt
mount: permission denied

然而使用--privileged启动容器显然也是不安全的, 并且也看不到这个设备.

例如 :

# df -h
/dev/rbd0                  8.0G   33M  8.0G   1% /rbd0

# 使用--privileged启动后, 容器中无法查看到这个映射的虚拟块设备
[root@localhost rbd1]# docker run -t -i --rm --device=/dev/rbd3:/dev/xvdc --privileged centos:centos6 /bin/bash
[root@4fc9c06d4ebc /]# ll /dev/xvdc
ls: cannot access /dev/xvdc: No such file or directory

使用--privileged启动容器, 可以直接访问宿主机的所有设备, 所以mount /dev/rbd0是可以的.

这显然是不安全的. 所以不能这么来使用.

[root@4fc9c06d4ebc /]# mount /dev/rbd0 /mnt
[root@4fc9c06d4ebc /]# cd /mnt
[root@4fc9c06d4ebc mnt]# ll
total 0

在容器中写如一个文件

[root@4fc9c06d4ebc mnt]# touch abc
[root@4fc9c06d4ebc mnt]# exit
exit

在宿主机可以看到这个文件被写入.

[root@localhost rbd1]# cd /rbd0
[root@localhost rbd0]# ll
total 0
-rw-r--r-- 1 root root 0 Dec 24 00:49 abc

那么容器应该怎么来使用虚拟块设备呢?

[参考]

1. http://ceph.com/docs/master/rbd/libvirt/

2. http://ceph.com/docs/master/rbd/qemu-rbd/

3. http://blog.163.com/digoal@126/blog/static/1638770402014112325944867/

4. man docker-run

5. http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/

6. http://developerblog.redhat.com/2014/09/30/overview-storage-scalability-docker/

时间: 2024-08-05 03:09:13

security use blockdev in virtual env的相关文章

Java微服务开发指南 -- 集群管理、失败转移和负载均衡的实践

集群管理.失败转移和负载均衡的实践     在前一章节中,我们快速的介绍了集群管理.Linux容器,接下来让我们使用这些技术来解决微服务的伸缩性问题.作为参考,我们使用的微服务工程来自于第二.第三和第四章节(Spring Boot.Dropwizard和WildFly Swarm)中的内容,接下来的步骤都适合上述三款框架. 开始     我们需要将微服务打包成为Docker镜像,最终将其部署到Kubernetes,首先进入到项目工程hola-springboot,然后启动jboss-forge,

Ubuntu16.04的Python virtualenv使用问题

问题描述 最新release的Ubuntu16.04想让大家都把Python环境都迁移到Python3上,但是目前python2还是主流,还有很多第三方库是基于Python2来实现的,所以我想还是有很多人和我一样,开发和生产环境必须要使用Python2. 而在系统上安装virtualenv基本是每个开发人员都必须的,但是这次在Ubuntu16.04上安装了virtualenv后却碰到了很多奇奇怪怪问题. 问题解决办法 首先检查python环境,Ubuntu16.04默认使用的Python2.7.

Online CPU Console using a Web Control Library with .NET Security(1)

web ABSTRACTAdministering applications and servers when not connected to the network can be a nightmare, especially when only a few people manage the application. Just imagine going out for an evening on the town and then you're paged at one o'clock

Online CPU Console using a Web Control Library with .NET Security(3)

web Call the event viewer control by the tag prefix colon and the class name of eventlog.cs. Note that we set a property from the query string in the code behind file.Display vw_EventLog.aspx file < !-- Register the WROXControlLib Assembly  -- ><

TensorFlow教程之API DOC 6.1.1Class tensorflow::Env

本文档为TensorFlow参考文档,本转载已得到TensorFlow中文社区授权. Class tensorflow::Env An interface used by the tensorflow implementation to access operating system functionality like the filesystem etc. Callers may wish to provide a custom Env object to get fine grain co

REST Security with JWT using Java and Spring Security

  Security Security is the enemy of convenience, and vice versa. This statement is true for any system, virtual or real, from the physical house entrance to web banking platforms. Engineers are constantly trying to find the right balance for the give

5 ways to minimize the security risks of the cloud

Like real clouds, cloud services have holes. The Cloud Security Alliance (CSA) has warned that the shared and on-demand nature of cloud computing introduces the possibility of new security risks that can erase any gains made by the switch to cloud te

CacheGuard Web Security Gateway 5.7.6发布 一体化OS设备

CacheGuard Appliance 是一个Web安全网关的一体化OS设备,提供了防火墙.网络防病毒.缓存.压缩.URL过滤.代理服务器.内容过滤.带宽分配.http://www.aliyun.com/zixun/aggregation/13996.html">负载均衡.反向和正向代理.高可用性.Web应用防火墙和URL守护等功能. CacheGuard Web Security Gateway 5.7.6该版本添加一个新的订阅验证模块到系统中. 软件信息:http://www.cac

Astaro Security Gateway 8.171发布 一套集成的软件解决方案

Astaro http://www.aliyun.com/zixun/aggregation/16952.html">Security Gateway 8.171更新日志: Fixed Issues: ·[17000] [UBB][8.160] rename IMP2P to application control ·[18097] [UBB][8.165] WiFi: WLAN not stable / Problems with certain devices ·[18204] [UB