It is legal, and documented syntax, to add a label to a docker node:
docker node update node_x --label-add "label"
and this will add a label that when queried, will show as an empty string:
$ docker node inspect docker-desktop --format '{{json .Spec.Labels}}'
{"label":""}
But, there is seemingly no valid way to make a placement constraint that can be satisfied by this label.
A different take on the problem is the need to check that a label is some value that is not blank.
For example I might want to give two nodes a label:
docker node update node_x --label-add "fruit=apple"
docker node update node_y --label-add "fruit=orange"
version: "3.9"
services:
test:
image: alpine
deploy:
placement:
constraints:
- node.labels.label # == or != expected
- node.labels.label=="" # "" unexpected / '' unexpected.
- node.labels.fruit!="" # "" unexpected / '' unexpected.
So, have I missed something? Is there some way to check if a label is set, without checking for a specific value. And is there any way to check for labels that are set, but to a blank value?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…