#docker #docker-compose #dockerfile #docker-swarm #traefik
#docker #docker-compose #dockerfile #docker-swarm #трафикинг
Вопрос:
Я пытался использовать руководство по базовому примеру в Traefik docs web, но всегда получаю ошибку при проверке службы WhoAmi:
Я должен увидеть вывод службы whoami (узел curl -H: whoami.volkonik.xyzhttp://whoami.volkonik.xyz ). Что-то похожее на:
Hostname: d7f919e54651
IP: 127.0.0.1
IP: 192.168.64.2
GET / HTTP/1.1
Host: whoami.localhost
User-Agent: curl/7.52.1
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 192.168.64.1
X-Forwarded-Host: whoami.localhost
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Server: 7f0c797dbc51
X-Real-Ip: 192.168.64.1
Но я получаю:
404 page not found
Что касается моей задачи, я должен использовать docker swarm с 3 менеджерами, использующими команды «docker stack», а не docker compose и deploy traefik с открытым сервисом whoami.
Команда, которую я использую для развертывания моего стека: deploy -c overflow.переполнение yml. Мой overflow.yml:
version: "3.3"
services:
traefik:
image: "traefik:v2.2"
command:
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.swarmMode=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
whoami:
image: "containous/whoami"
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`whoami.volkonik.xyz`)"
- "traefik.http.routers.whoami.entrypoints=web"
Информация о докере:
Client:
Debug Mode: false
Server:
Containers: 2
Running: 1
Paused: 0
Stopped: 1
Images: 5
Server Version: 19.03.12
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
NodeID: 5l5fmyv287ro7x07h5rhrzim5
Is Manager: true
ClusterID: zoiwzedomj7lbyvqh69rn9m64
Managers: 3
Nodes: 3
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 164.90.229.118
Manager Addresses:
138.68.65.250:2377
164.90.229.118:2377
164.90.229.127:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-112-generic
Operating System: Ubuntu 18.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.946GiB
Name: nikolay-volkov-small-1
ID: YARQ:QDCY:35IG:SNZQ:MUNG:UZL2:WBUK:N7Q5:P4C6:6FTV:52NU:7DTF
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
Docker network ls:
NETWORK ID NAME DRIVER SCOPE
7266d22942a1 bridge bridge local
edfbf6592868 docker_gwbridge bridge local
72f35302100b host host local
hx6aj67pa4bz ingress overlay swarm
038d3f36bede none null local
rhksb2n1j235 overflow_default overlay swarm
docker stack ps overflow
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
cnk96s94dj8c overflow_traefik.1 traefik:v2.2 nikolay-volkov-small-2 Running Running 16 minutes ago
wjziltuypmfj overflow_whoami.1 containous/whoami:latest nikolay-volkov-small-1 Running Running 28 minutes ago`enter code here`
docker network inspect overflow_default:
[
{
"Name": "overflow_default",
"Id": "rhksb2n1j235b3qkuvlgdrprp",
"Created": "2020-08-15T14:21:20.194017073Z",
"Scope": "swarm",
"Driver": "overlay",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "10.0.2.0/24",
"Gateway": "10.0.2.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"61afaac4fff8c2474d7166c4227c776860081630c04f7c3a3403ef29b716f94d": {
"Name": "overflow_whoami.1.wjziltuypmfj7vg0zuxlj5kva",
"EndpointID": "5ce2f8cfb37f2294210bbb538576d485c7c3cf066d836771da6a002e5fbbbafe",
"MacAddress": "02:42:0a:00:02:03",
"IPv4Address": "10.0.2.3/24",
"IPv6Address": ""
},
"lb-overflow_default": {
"Name": "overflow_default-endpoint",
"EndpointID": "d6453d2d9362bf95f3f34a06a8241e85410d3f8cf3ee0a6894baaecbe7348cea",
"MacAddress": "02:42:0a:00:02:04",
"IPv4Address": "10.0.2.4/24",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.driver.overlay.vxlanid_list": "4098"
},
"Labels": {
"com.docker.stack.namespace": "overflow"
},
"Peers": [
{
"Name": "995d8aecdcfe",
"IP": "164.90.229.118"
},
{
"Name": "853c9483a7b7",
"IP": "164.90.229.127"
}
]
}
]
служба docker проверяет переполнение_whoami:
[
{
"ID": "tkbf0ucohva6eg76vzvfkhh6m",
"Version": {
"Index": 57011
},
"CreatedAt": "2020-08-15T14:21:20.020420896Z",
"UpdatedAt": "2020-08-15T14:49:19.975265202Z",
"Spec": {
"Name": "overflow_whoami",
"Labels": {
"com.docker.stack.image": "containous/whoami",
"com.docker.stack.namespace": "overflow"
},
"TaskTemplate": {
"ContainerSpec": {
"Image": "containous/whoami:latest@sha256:7d6a3c8f91470a23ef380320609ee6e69ac68d20bc804f3a1c6065fb56cfa34e",
"Labels": {
"com.docker.stack.namespace": "overflow",
"traefik.enable": "true",
"traefik.http.routers.whoami.entrypoints": "web",
"traefik.http.routers.whoami.rule": "Host(`whoami.volkonik.xyz`)"
},
"Privileges": {
"CredentialSpec": null,
"SELinuxContext": null
},
"StopGracePeriod": 10000000000,
"DNSConfig": {},
"Isolation": "default"
},
"Resources": {},
"RestartPolicy": {
"Condition": "any",
"Delay": 5000000000,
"MaxAttempts": 0
},
"Placement": {
"Platforms": [
{
"Architecture": "386",
"OS": "linux"
},
{
"Architecture": "amd64",
"OS": "linux"
},
{
"OS": "linux"
},
{
"OS": "linux"
},
{
"Architecture": "arm64",
"OS": "linux"
}
]
},
"Networks": [
{
"Target": "rhksb2n1j235b3qkuvlgdrprp",
"Aliases": [
"whoami"
]
}
],
"ForceUpdate": 0,
"Runtime": "container"
},
"Mode": {
"Replicated": {
"Replicas": 1
}
},
"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": "overflow_whoami",
"Labels": {
"com.docker.stack.image": "containous/whoami",
"com.docker.stack.namespace": "overflow"
},
"TaskTemplate": {
"ContainerSpec": {
"Image": "containous/whoami:latest@sha256:7d6a3c8f91470a23ef380320609ee6e69ac68d20bc804f3a1c6065fb56cfa34e",
"Labels": {
"com.docker.stack.namespace": "overflow",
"traefik.enable": "true",
"traefik.http.routers.whoami.entrypoints": "web",
"traefik.http.routers.whoami.rule": "Host(`whoami.volkonik.xyz`)"
},
"Privileges": {
"CredentialSpec": null,
"SELinuxContext": null
},
"Isolation": "default"
},
"Resources": {},
"Placement": {
"Platforms": [
{
"Architecture": "386",
"OS": "linux"
},
{
"Architecture": "amd64",
"OS": "linux"
},
{
"OS": "linux"
},
{
"OS": "linux"
},
{
"Architecture": "arm64",
"OS": "linux"
}
]
},
"Networks": [
{
"Target": "rhksb2n1j235b3qkuvlgdrprp",
"Aliases": [
"whoami"
]
}
],
"ForceUpdate": 0,
"Runtime": "container"
},
"Mode": {
"Replicated": {
"Replicas": 1
}
},
"EndpointSpec": {
"Mode": "vip"
}
},
"Endpoint": {
"Spec": {
"Mode": "vip"
},
"VirtualIPs": [
{
"NetworkID": "rhksb2n1j235b3qkuvlgdrprp",
"Addr": "10.0.2.2/24"
}
]
}
}
]
служба docker проверяет переполнение_traefik:
[
{
"ID": "xzpl81oco98onhvqxxkhdnbxz",
"Version": {
"Index": 57010
},
"CreatedAt": "2020-08-15T14:21:21.644144642Z",
"UpdatedAt": "2020-08-15T14:49:18.348979648Z",
"Spec": {
"Name": "overflow_traefik",
"Labels": {
"com.docker.stack.image": "traefik:v2.2",
"com.docker.stack.namespace": "overflow"
},
"TaskTemplate": {
"ContainerSpec": {
"Image": "traefik:v2.2@sha256:f5af5a5ce17fc3e353b507e8acce65d7f28126408a8c92dc3cac246d023dc9e8",
"Labels": {
"com.docker.stack.namespace": "overflow"
},
"Args": [
"--api.insecure=true",
"--providers.docker=true",
"--providers.docker.swarmMode=true",
"--providers.docker.exposedbydefault=false",
"--entrypoints.web.address=:80"
],
"Privileges": {
"CredentialSpec": null,
"SELinuxContext": null
},
"Mounts": [
{
"Type": "bind",
"Source": "/var/run/docker.sock",
"Target": "/var/run/docker.sock",
"ReadOnly": true
}
],
"StopGracePeriod": 10000000000,
"DNSConfig": {},
"Isolation": "default"
},
"Resources": {},
"RestartPolicy": {
"Condition": "any",
"Delay": 5000000000,
"MaxAttempts": 0
},
"Placement": {
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux"
},
{
"OS": "linux"
},
{
"Architecture": "arm64",
"OS": "linux"
}
]
},
"Networks": [
{
"Target": "rhksb2n1j235b3qkuvlgdrprp",
"Aliases": [
"traefik"
]
}
],
"ForceUpdate": 0,
"Runtime": "container"
},
"Mode": {
"Replicated": {
"Replicas": 1
}
},
"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",
"Ports": [
{
"Protocol": "tcp",
"TargetPort": 80,
"PublishedPort": 80,
"PublishMode": "ingress"
},
{
"Protocol": "tcp",
"TargetPort": 8080,
"PublishedPort": 8080,
"PublishMode": "ingress"
}
]
}
},
"PreviousSpec": {
"Name": "overflow_traefik",
"Labels": {
"com.docker.stack.image": "traefik:v2.2",
"com.docker.stack.namespace": "overflow"
},
"TaskTemplate": {
"ContainerSpec": {
"Image": "traefik:v2.2@sha256:f5af5a5ce17fc3e353b507e8acce65d7f28126408a8c92dc3cac246d023dc9e8",
"Labels": {
"com.docker.stack.namespace": "overflow"
},
"Args": [
"--api.insecure=true",
"--providers.docker=true",
"--providers.docker.swarmMode=true",
"--providers.docker.exposedbydefault=false",
"--entrypoints.web.address=:80"
],
"Privileges": {
"CredentialSpec": null,
"SELinuxContext": null
},
"Mounts": [
{
"Type": "bind",
"Source": "/var/run/docker.sock",
"Target": "/var/run/docker.sock",
"ReadOnly": true
}
],
"Isolation": "default"
},
"Resources": {},
"Placement": {
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux"
},
{
"OS": "linux"
},
{
"Architecture": "arm64",
"OS": "linux"
}
]
},
"Networks": [
{
"Target": "rhksb2n1j235b3qkuvlgdrprp",
"Aliases": [
"traefik"
]
}
],
"ForceUpdate": 0,
"Runtime": "container"
},
"Mode": {
"Replicated": {
"Replicas": 1
}
},
"EndpointSpec": {
"Mode": "vip",
"Ports": [
{
"Protocol": "tcp",
"TargetPort": 80,
"PublishedPort": 80,
"PublishMode": "ingress"
},
{
"Protocol": "tcp",
"TargetPort": 8080,
"PublishedPort": 8080,
"PublishMode": "ingress"
}
]
}
},
"Endpoint": {
"Spec": {
"Mode": "vip",
"Ports": [
{
"Protocol": "tcp",
"TargetPort": 80,
"PublishedPort": 80,
"PublishMode": "ingress"
},
{
"Protocol": "tcp",
"TargetPort": 8080,
"PublishedPort": 8080,
"PublishMode": "ingress"
}
]
},
"Ports": [
{
"Protocol": "tcp",
"TargetPort": 80,
"PublishedPort": 80,
"PublishMode": "ingress"
},
{
"Protocol": "tcp",
"TargetPort": 8080,
"PublishedPort": 8080,
"PublishMode": "ingress"
}
],
"VirtualIPs": [
{
"NetworkID": "hx6aj67pa4bz4nu70dyrdatq6",
"Addr": "10.11.0.12/16"
},
{
"NetworkID": "rhksb2n1j235b3qkuvlgdrprp",
"Addr": "10.0.2.5/24"
}
]
}
}
]
Комментарии:
1. Привет, есть предложения? Я вижу, что traefik не видит службу Whoami, но я не знаю почему.