Docker Swarm Сеть между API и Front - PullRequest
0 голосов
/ 10 сентября 2018

У меня проблема с Docker Swarm.

Я создал три контейнера (db, back и web).

Spring image - это API REST, и я хочу вызвать route / users сimage web_prod (ReactJS).

В Swarm у меня 3 менеджера и 3 рабочих.Все сервисы (db, back, web) подключены к оркестровке сети (оверлея).

Я могу свернуть свой API с URL http://tasks.back:4000/users (с другим контейнером -), но когда я вызываю этот адрес свеб-изображение, у меня нет результатов.Этот другой контейнер запущен (соответствующий / curl) в моем менеджере.

Может быть проблема между кластером и службой.

Проверка веб-службы моей службы:

docker@manager1:~$ docker service inspect web
[
    {
        "ID": "pfby9bxijwyopg3avz9omq7a2",
        "Version": {
            "Index": 413
        },
        "CreatedAt": "2018-09-10T13:58:26.4776156Z",
        "UpdatedAt": "2018-09-10T14:15:41.1509202Z",
        "Spec": {
            "Name": "web",
            "Labels": {},
            "TaskTemplate": {
                "ContainerSpec": {
                    "Image": "mirha/orchestration-web:0.3@sha256:b11278539b75e9ec315c3f865e70ca594d264f03abd8587262ea4496cf166f85",
                    "Env": [
                        "POSTGRES_DB=homefamily",
                        "POSTGRES_USER=postgres",
                        "POSTGRES_PASSWORD=postgres"
                    ],
                    "Init": false,
                    "StopGracePeriod": 10000000000,
                    "DNSConfig": {},
                    "Isolation": "default"
                },
                "Resources": {
                    "Limits": {},
                    "Reservations": {}
                },
                "RestartPolicy": {
                    "Condition": "any",
                    "Delay": 5000000000,
                    "MaxAttempts": 0
                },
                "Placement": {
                    "Platforms": [
                        {
                            "Architecture": "amd64",
                            "OS": "linux"
                        }
                    ]
                },
                "Networks": [
                    {
                        "Target": "cpcqcwcbxq7k6l33aa82g346m"
                    }
                ],
                "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": 3000,
                        "PublishedPort": 80,
                        "PublishMode": "ingress"
                    }
                ]
            }
        },
        "PreviousSpec": {
            "Name": "web",
            "Labels": {},
            "TaskTemplate": {
                "ContainerSpec": {
                    "Image": "mirha/orchestration-web:0.3@sha256:ead6e01788e51c9fbc31047772d380b639ea0c3e5f0b094695c5cfda2f42032c",
                    "Env": [
                        "POSTGRES_DB=homefamily",
                        "POSTGRES_USER=postgres",
                        "POSTGRES_PASSWORD=postgres"
                    ],
                    "Init": false,
                    "DNSConfig": {},
                    "Isolation": "default"
                },
                "Resources": {
                    "Limits": {},
                    "Reservations": {}
                },
                "Placement": {
                    "Platforms": [
                        {
                            "Architecture": "amd64",
                            "OS": "linux"
                        }
                    ]
                },
                "Networks": [
                    {
                        "Target": "cpcqcwcbxq7k6l33aa82g346m"
                    }
                ],
                "ForceUpdate": 0,
                "Runtime": "container"
            },
            "Mode": {
                "Replicated": {
                    "Replicas": 1
                }
            },
            "EndpointSpec": {
                "Mode": "vip",
                "Ports": [
                    {
                        "Protocol": "tcp",
                        "TargetPort": 3000,
                        "PublishedPort": 80,
                        "PublishMode": "ingress"
                    }
                ]
            }
        },
        "Endpoint": {
            "Spec": {
                "Mode": "vip",
                "Ports": [
                    {
                        "Protocol": "tcp",
                        "TargetPort": 3000,
                        "PublishedPort": 80,
                        "PublishMode": "ingress"
                    }
                ]
            },
            "Ports": [
                {
                    "Protocol": "tcp",
                    "TargetPort": 3000,
                    "PublishedPort": 80,
                    "PublishMode": "ingress"
                }
            ],
            "VirtualIPs": [
                {
                    "NetworkID": "w09wuwh6tt8bnlf6bsvtb0idq",
                    "Addr": "10.0.0.10/24"
                },
                {
                    "NetworkID": "cpcqcwcbxq7k6l33aa82g346m",
                    "Addr": "10.0.2.17/24"
                }
            ]
        },
        "UpdateStatus": {
            "State": "completed",
            "StartedAt": "2018-09-10T14:11:51.1926981Z",
            "CompletedAt": "2018-09-10T14:15:41.1509088Z",
            "Message": "update completed"
        }
    }
]

Осмотр моей спины

[
    {
        "ID": "uiesfpo3usn9z01cel30no930",
        "Version": {
            "Index": 463
        },
        "CreatedAt": "2018-09-10T12:49:03.0005436Z",
        "UpdatedAt": "2018-09-10T15:19:38.1407773Z",
        "Spec": {
            "Name": "back",
            "Labels": {},
            "TaskTemplate": {
                "ContainerSpec": {
                    "Image": "mirha/spring:5@sha256:ec12cc9cbff861656313f8835976d841204bea54bc8096d3346166c26fdcddaf",
                    "Hostname": "back.api",
                    "Env": [
                        "POSTGRES_DB=homefamily",
                        "POSTGRES_USER=postgres",
                        "POSTGRES_PASSWORD=postgres"
                    ],
                    "Init": false,
                    "StopGracePeriod": 10000000000,
                    "DNSConfig": {},
                    "Isolation": "default"
                },
                "Resources": {
                    "Limits": {},
                    "Reservations": {}
                },
                "RestartPolicy": {
                    "Condition": "any",
                    "Delay": 5000000000,
                    "MaxAttempts": 0
                },
                "Placement": {
                    "Platforms": [
                        {
                            "Architecture": "amd64",
                            "OS": "linux"
                        }
                    ]
                },
                "Networks": [
                    {
                        "Target": "cpcqcwcbxq7k6l33aa82g346m"
                    }
                ],
                "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": 4000,
                        "PublishedPort": 4000,
                        "PublishMode": "ingress"
                    }
                ]
            }
        },
        "PreviousSpec": {
            "Name": "back",
            "Labels": {},
            "TaskTemplate": {
                "ContainerSpec": {
                    "Image": "mirha/spring:5@sha256:ec12cc9cbff861656313f8835976d841204bea54bc8096d3346166c26fdcddaf",
                    "Hostname": "back.api",
                    "Env": [
                        "POSTGRES_DB=homefamily",
                        "POSTGRES_USER=postgres",
                        "POSTGRES_PASSWORD=postgres"
                    ],
                    "Init": false,
                    "DNSConfig": {},
                    "Isolation": "default"
                },
                "Resources": {
                    "Limits": {},
                    "Reservations": {}
                },
                "Placement": {
                    "Platforms": [
                        {
                            "Architecture": "amd64",
                            "OS": "linux"
                        }
                    ]
                },
                "Networks": [
                    {
                        "Target": "cpcqcwcbxq7k6l33aa82g346m"
                    }
                ],
                "ForceUpdate": 0,
                "Runtime": "container"
            },
            "Mode": {
                "Replicated": {
                    "Replicas": 1
                }
            },
            "EndpointSpec": {
                "Mode": "vip"
            }
        },
        "Endpoint": {
            "Spec": {
                "Mode": "vip",
                "Ports": [
                    {
                        "Protocol": "tcp",
                        "TargetPort": 4000,
                        "PublishedPort": 4000,
                        "PublishMode": "ingress"
                    }
                ]
            },
            "Ports": [
                {
                    "Protocol": "tcp",
                    "TargetPort": 4000,
                    "PublishedPort": 4000,
                    "PublishMode": "ingress"
                }
            ],
            "VirtualIPs": [
                {
                    "NetworkID": "cpcqcwcbxq7k6l33aa82g346m",
                    "Addr": "10.0.2.10/24"
                },
                {
                    "NetworkID": "w09wuwh6tt8bnlf6bsvtb0idq",
                    "Addr": "10.0.0.13/24"
                }
            ]
        },
        "UpdateStatus": {
            "State": "completed",
            "StartedAt": "2018-09-10T15:19:29.0789613Z",
            "CompletedAt": "2018-09-10T15:19:38.1407656Z",
            "Message": "update completed"
        }
    }
]

Результат в другом контейнере в той же сети:

docker@manager1:~$ docker run --rm -it --net=orchestration --name curl appropriate/curl http://tasks.back:4000/application

{"ip":"10.0.2.29","name":"back.api","id":null,"version":null}

Если у вас есть идея для этой проблемы (без результатакогда я вызываю API через веб-браузер изображений в моем браузере), я пытаюсь использовать ip менеджера (192.168.25.80:4000), localhost, имя изображения и т. д. ...

Спасибо

...