如何通过标签过滤泊坞窗群组节点? [英] How do I filter docker swarm nodes by label?

查看:170
本文介绍了如何通过标签过滤泊坞窗群组节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行docker 1.12.1,不能通过标签获得节点过滤。
我首先添加test标签:

  $ docker node update --label-add test mr-host 
mr-host

当我尝试过滤时,不显示任何节点: / p>

  $ docker node ls --filter label = test 
ID HOSTNAME状态可用性管理器状态

通过其他条件进行过滤,如名称正常工作:

  $ docker node ls --filter name = mr-host 
ID HOSTNAME状态可用性管理器状态
1c48m4msidbqwx7vj0lwib8ef * mr-host准备主动负责人

当我检查节点时,会显示标签:

  $ docker node inspect mr-host 
[
{
ID:1c48m4msidbqwx7vj0lwib8ef,
版本:{
索引:4865874
},
CreatedAt:2016-10-12T15:20:10.463286132Z,
UpdatedAt:
$ {
test:

角色:经理,
可用性:活动
},
描述:{
主机名:mr-host,
Platform:{
Architecture:x86_64,
OS:linux
},
资源:{
NanoCPUs:10000000000
MemoryBytes:67548012544
},
引擎:{
EngineVersion:1.12.1,
插件 :[
{
Type:Network,
Name:bridge
},
{
Type网络,
名称:主机
},
{
Type:Network,
Name:null
},
{
Type:Network,
名称:覆盖
},
{
类型:卷,
名称:本地
}

}
},
状态:{
状态:准备
},
ManagerStatus:{
Leader:true,
Reachability:reachable,
Addr:192.168.0.118:2377
}
}
]

我做错了什么?我确信我已经正确地遵循了这些文档: https:/ /docs.docker.com/engine/reference/commandline/node_ls/#/id

解决方案

简单的答案:这不像你以为会这样做,但它似乎可能会解决它。



Github问题


混乱来自我们有两组标签:



节点标签(通过码头节点更新设置的标签)
引擎标签当您使用
--label启动docker守护程序时,您设置)在docker节点ls中的标签过滤正在查看引擎标签,而不是节点标签。



我们应该还原到节点标签过滤,而不是引擎
过滤



I'm running docker 1.12.1 and can't get node filtering by label to work. I first add the "test" label:

$ docker node update --label-add test mr-host
mr-host

When I attempt to filter by it, no nodes are shown:

$ docker node ls --filter label=test
ID  HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS

Filtering by other criteria such as name works fine:

$ docker node ls --filter name=mr-host
ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
1c48m4msidbqwx7vj0lwib8ef *  mr-host   Ready   Active        Leader

The label is shown when I inspect the node:

$ docker node inspect mr-host
[
    {
        "ID": "1c48m4msidbqwx7vj0lwib8ef",
        "Version": {
            "Index": 4865874
        },
        "CreatedAt": "2016-10-12T15:20:10.463286132Z",
        "UpdatedAt": "2016-10-13T16:29:03.113522485Z",
        "Spec": {
            "Labels": {
                "test": ""
            },
            "Role": "manager",
            "Availability": "active"
        },
        "Description": {
            "Hostname": "mr-host",
            "Platform": {
                "Architecture": "x86_64",
                "OS": "linux"
            },
            "Resources": {
                "NanoCPUs": 10000000000,
                "MemoryBytes": 67548012544
            },
            "Engine": {
                "EngineVersion": "1.12.1",
                "Plugins": [
                    {
                        "Type": "Network",
                        "Name": "bridge"
                    },
                    {
                        "Type": "Network",
                        "Name": "host"
                    },
                    {
                        "Type": "Network",
                        "Name": "null"
                    },
                    {
                        "Type": "Network",
                        "Name": "overlay"
                    },
                    {
                        "Type": "Volume",
                        "Name": "local"
                    }
                ]
            }
        },
        "Status": {
            "State": "ready"
        },
        "ManagerStatus": {
            "Leader": true,
            "Reachability": "reachable",
            "Addr": "192.168.0.118:2377"
        }
    }
]

What am I doing wrong? I'm pretty sure I've followed the documentation here correctly: https://docs.docker.com/engine/reference/commandline/node_ls/#/id

解决方案

Simple answer: this doesn't work like you'd think it would, but it looks like they might fix it.

Quoting from the Github issue:

The confusion comes from the fact that we have two set of labels:

Node labels (the ones you've been setting through docker node update) Engine labels (the ones that you set when you start docker daemon with --label) Label filtering in docker node ls is looking at engine labels rather than node labels.

We should probably revert to node label filtering rather than engine filtering

这篇关于如何通过标签过滤泊坞窗群组节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆