在Docker Swarm集群上部署datadog服务时,我注意到了一些奇怪的事情。
我目前有4个节点:2个工作人员,2个管理人员(是的,我不建议这样做,但仍处于测试模式)。
我的服务被声明为全局模式:
version: '3.3'
services:
dd-agent:
image: datadog/agent:latest
environment:
- "DD_API_KEY=xxx"
- "DD_LOGS_ENABLED=true"
- "DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true"
- "DD_AC_EXCLUDE=image:datadog-agent"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
- /opt/datadog-agent/run:/opt/datadog-agent/run:rw
deploy:
mode: global
restart_policy:
condition: on-failure
但是,实际上,在我的集群上,我只看到3个实例部署,一个管理器没有实例。
查询Docker的服务列表时,它告诉我只有3个副本要部署:
ubuntu@docker-swarm-manager-1:~$ sudo docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
paiqnrqiwpbq dd-agent_dd-agent global 3/3 datadog/agent:latest
v6w4mrn6vavt xxx_yyy replicated 2/2 xxx/yyy:test-0.2
cib3gj4omojk traefik_traefik global 2/2 traefik:1.7 *:80->80/tcp, *:443->443/tcp, *:8080->8080/tcp
xhrl8oaftf1c visualizer_visualizer replicated 1/1 dockersamples/visualizer:latest
检查命令看起来不错:
ubuntu@docker-swarm-manager-1:~$ sudo docker service inspect dd-agent_dd-agent
[
{
"ID": "paiqnrqiwpbqmg4kooxtzpaer",
"Version": {
"Index": 49139
},
"CreatedAt": "2019-04-23T15:49:31.947283769Z",
"UpdatedAt": "2019-04-24T10:01:42.078629559Z",
"Spec": {
"Name": "dd-agent_dd-agent",
"Labels": {
"com.docker.stack.image": "datadog/agent:latest",
"com.docker.stack.namespace": "dd-agent"
},
"TaskTemplate": {
"ContainerSpec": {
"Image": "datadog/agent:latest@sha256:5fbe2c87d4c4c2d9fc2d4bf45e39b0572f7f3f8ff906e3a77515a3308ab0c2cf",
"Labels": {
"com.docker.stack.namespace": "dd-agent"
},
"Env": [
"DD_AC_EXCLUDE=image:datadog-agent",
"DD_API_KEY=xxx",
"DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true",
"DD_LOGS_ENABLED=true"
],
"Privileges": {
"CredentialSpec": null,
"SELinuxContext": null
},
"Mounts": [
{
"Type": "bind",
"Source": "/var/run/docker.sock",
"Target": "/var/run/docker.sock",
"ReadOnly": true
},
{
"Type": "bind",
"Source": "/proc/",
"Target": "/host/proc/",
"ReadOnly": true
},
{
"Type": "bind",
"Source": "/sys/fs/cgroup/",
"Target": "/host/sys/fs/cgroup",
"ReadOnly": true
},
{
"Type": "bind",
"Source": "/opt/datadog-agent/run",
"Target": "/opt/datadog-agent/run"
}
],
"StopGracePeriod": 10000000000,
"DNSConfig": {},
"Isolation": "default"
},
"Resources": {},
"RestartPolicy": {
"Condition": "on-failure",
"Delay": 5000000000,
"MaxAttempts": 0
},
"Placement": {
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux"
}
]
},
"Networks": [
{
"Target": "5u989vnt4kukrzmwpaub5jn0t",
"Aliases": [
"dd-agent"
]
}
],
"ForceUpdate": 0,
"Runtime": "container"
},
"Mode": {
"Global": {}
},
"UpdateConfig": {
"Parallelism": 1,
"FailureAction": "pause",
"Monitor": 5000000000,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"RollbackConfig": {
"Parallelism": 1,
"FailureAction": "pause",
"Monitor": 5000000000,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"EndpointSpec": {
"Mode": "vip"
}
},
"PreviousSpec": {
"Name": "dd-agent_dd-agent",
"Labels": {
"com.docker.stack.image": "datadog/agent:latest",
"com.docker.stack.namespace": "dd-agent"
},
"TaskTemplate": {
"ContainerSpec": {
"Image": "datadog/agent:latest@sha256:5fbe2c87d4c4c2d9fc2d4bf45e39b0572f7f3f8ff906e3a77515a3308ab0c2cf",
"Labels": {
"com.docker.stack.namespace": "dd-agent"
},
"Env": [
"DD_AC_EXCLUDE=image:datadog-agent",
"DD_API_KEY=xxx",
"DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true",
"DD_LOGS_ENABLED=true"
],
"Privileges": {
"CredentialSpec": null,
"SELinuxContext": null
},
"Mounts": [
{
"Type": "bind",
"Source": "/var/run/docker.sock",
"Target": "/var/run/docker.sock",
"ReadOnly": true
},
{
"Type": "bind",
"Source": "/proc/",
"Target": "/host/proc/",
"ReadOnly": true
},
{
"Type": "bind",
"Source": "/sys/fs/cgroup/",
"Target": "/host/sys/fs/cgroup",
"ReadOnly": true
},
{
"Type": "bind",
"Source": "/opt/datadog-agent/run",
"Target": "/opt/datadog-agent/run"
}
],
"Isolation": "default"
},
"Resources": {},
"RestartPolicy": {
"Condition": "on-failure",
"MaxAttempts": 0
},
"Placement": {
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux"
}
]
},
"Networks": [
{
"Target": "5u989vnt4kukrzmwpaub5jn0t",
"Aliases": [
"dd-agent"
]
}
],
"ForceUpdate": 0,
"Runtime": "container"
},
"Mode": {
"Global": {}
},
"EndpointSpec": {
"Mode": "vip"
}
},
"Endpoint": {
"Spec": {
"Mode": "vip"
},
"VirtualIPs": [
{
"NetworkID": "5u989vnt4kukrzmwpaub5jn0t",
"Addr": "10.0.0.2/24"
}
]
}
}
]
我尝试重新部署(更新)服务,而不必删除并重新创建,但是Swarm保持不变。
似乎是一个问题,我在Github存储库上什么也没找到。有没有办法了解为什么不将此节点计为全局模式? (仅对于此datadog服务,traefik服务处于全局模式并且可以)