码迷,mamicode.com
首页 > 其他好文 > 详细

docker swarm英文文档学习-11-上锁你的集群来保护你的加密密钥

时间:2019-01-10 16:31:44      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:rtu   swa   store   you   remember   ide   arm   please   abc   

Lock your swarm to protect its encryption key上锁你的集群来保护你的加密密钥

在Docker 1.13及更高版本中,默认情况下,群管理器使用的Raft日志在磁盘上加密。这种静止加密保护你的服务的配置和数据不受获得加密Raft日志访问权的攻击者的攻击。引入该特性的原因之一是支持新的Docker secrets特性。

当Docker重新启动时,用于加密集群节点间通信的TLS密钥和用于加密和解密磁盘Raft日志的密钥都被加载到每个管理器节点的内存中。Docker 1.13引入了保护相互TLS加密密钥和用于加密和解密Raft日志的密钥的能力,允许你获得这些密钥的所有权,并要求手动解锁管理器。这个功能叫做自动锁。

当Docker重新启动时,必须首先使用Docker在集群被锁定时生成的密钥加密密钥对集群进行解锁。你可以在任何时候轮转此密钥加密密钥。

注意:当一个新节点加入群集时,你不需要解锁群集,因为密钥是通过相互的TLS传播到它的。

 

Initialize a swarm with autolocking enabled 初始化启动自动锁功能的集群

在初始化一个新集群时,可以使用--autolock标志在Docker重新启动时启用集群管理器节点的自动锁。

$ docker swarm init --autolock

Swarm initialized: current node (k1q27tfyx9rncpixhk69sa61v) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join     --token SWMTKN-1-0j52ln6hxjpxk2wgk917abcnxywj3xed0y8vi1e5m9t3uttrtu-7bnxvvlz2mrcpfonjuztmtts9     172.31.46.109:2377

To add a manager to this swarm, run docker swarm join-token manager and follow the instructions.

To unlock a swarm manager after it restarts, run the `docker swarm unlock`
command and provide the following key:

    SWMKEY-1-WuYH/IX284+lRcXuoVf38viIDK3HJEKY13MIHX+tTt8

将密钥存储在安全的地方,如密码管理器中。

当Docker重启时,你需要解锁集群。当你试图启动或重新启动服务时,锁定的集群会导致如下错误:

$ sudo service docker restart

$ docker service ls

Error response from daemon: Swarm is encrypted and needs to be unlocked before it can be used. Use "docker swarm unlock" to unlock it.

 

Enable or disable autolock on an existing swarm在已有集群中启用或禁用自动锁功能

在已有集群中启用自动锁功能,设置autolock标志为true

$ docker swarm update --autolock=true

Swarm updated.
To unlock a swarm manager after it restarts, run the `docker swarm unlock`
command and provide the following key:

    SWMKEY-1-+MrE8NgAyKj5r3NcR4FiQMdgu+7W72urH0EZeSmP/0Y

Please remember to store this key in a password manager, since without it you
will not be able to restart the manager.

若要禁用自动锁,请将--autolock设置为false。用于读写Raft日志的相互TLS密钥和加密密钥未加密地存储在磁盘上。在存储未加密的加密密钥的风险和重新启动集群而不需要解锁每个管理器之间存在权衡。

$ docker swarm update --autolock=false

在禁用自动锁之后,请将解锁密钥保留一段时间,以防在仍然配置为使用旧密钥锁定时,管理器出现故障。

 

Unlock a swarm解锁集群

使用docker swarm unlock 命令解锁一个上锁集群

$ docker swarm unlock

Please enter unlock key:

输入在锁定集群或轮转密钥时生成并显示在命令输出中的加密密钥,集群就会解锁。

 

View the current unlock key for a running swarm 查看正在运行的集群的当前解锁密钥

考虑这样一种情况:你的集群按预期运行,然后管理器节点变得不可用。你可以对问题进行故障排除并使物理节点重新联机,但是你需要通过提供解锁密钥来读取加密的凭据和Raft日志来解锁管理器。

如果自节点离开群集后密钥没有被轮转,并且你在群集中有一个仲裁的函数管理器节点,那么你可以使用docker swarm unlock-key查看当前的解锁密钥,而不需要任何参数。

$ docker swarm unlock-key

To unlock a swarm manager after it restarts, run the `docker swarm unlock`
command and provide the following key:

    SWMKEY-1-8jDgbUNlJtUe5P/lcr9IXGVxqZpZUXPzd+qzcGp4ZYA

Please remember to store this key in a password manager, since without it you
will not be able to restart the manager.

如果在群集节点不可用之后轮转了密钥,并且你没有上一个密钥的记录,则可能需要强制管理器离开群集,并将其作为新管理器加入到群集中。

 

Rotate the unlock key轮转解锁密钥

你应该定期轮转被锁集群的解锁密钥。

$ docker swarm unlock-key --rotate

Successfully rotated manager unlock key.

To unlock a swarm manager after it restarts, run the `docker swarm unlock`
command and provide the following key:

    SWMKEY-1-8jDgbUNlJtUe5P/lcr9IXGVxqZpZUXPzd+qzcGp4ZYA

Please remember to store this key in a password manager, since without it you
will not be able to restart the manager.

警告:当你轮转解锁密钥时,请将旧键的记录保留几分钟,这样,如果管理器在获取新键之前宕机,那么它仍然可以使用旧键解锁。

docker swarm英文文档学习-11-上锁你的集群来保护你的加密密钥

标签:rtu   swa   store   you   remember   ide   arm   please   abc   

原文地址:https://www.cnblogs.com/wanghui-garcia/p/10245865.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!