mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #28078 from sanimej/inspect
Show peer nodes in network inspect for swarm overlay networks
This commit is contained in:
commit
5ef5a4216a
5 changed files with 82 additions and 0 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/libnetwork"
|
"github.com/docker/libnetwork"
|
||||||
|
"github.com/docker/libnetwork/networkdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *networkRouter) getNetworksList(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func (n *networkRouter) getNetworksList(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
|
@ -177,6 +178,11 @@ func (n *networkRouter) buildNetworkResource(nw libnetwork.Network) *types.Netwo
|
||||||
r.Internal = info.Internal()
|
r.Internal = info.Internal()
|
||||||
r.Labels = info.Labels()
|
r.Labels = info.Labels()
|
||||||
|
|
||||||
|
peers := info.Peers()
|
||||||
|
if len(peers) != 0 {
|
||||||
|
r.Peers = buildPeerInfoResources(peers)
|
||||||
|
}
|
||||||
|
|
||||||
epl := nw.Endpoints()
|
epl := nw.Endpoints()
|
||||||
for _, e := range epl {
|
for _, e := range epl {
|
||||||
ei := e.Info()
|
ei := e.Info()
|
||||||
|
@ -195,6 +201,17 @@ func (n *networkRouter) buildNetworkResource(nw libnetwork.Network) *types.Netwo
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func buildPeerInfoResources(peers []networkdb.PeerInfo) []network.PeerInfo {
|
||||||
|
peerInfo := make([]network.PeerInfo, 0, len(peers))
|
||||||
|
for _, peer := range peers {
|
||||||
|
peerInfo = append(peerInfo, network.PeerInfo{
|
||||||
|
Name: peer.Name,
|
||||||
|
IP: peer.IP,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return peerInfo
|
||||||
|
}
|
||||||
|
|
||||||
func buildIpamResources(r *types.NetworkResource, nwInfo libnetwork.NetworkInfo) {
|
func buildIpamResources(r *types.NetworkResource, nwInfo libnetwork.NetworkInfo) {
|
||||||
id, opts, ipv4conf, ipv6conf := nwInfo.IpamConfig()
|
id, opts, ipv4conf, ipv6conf := nwInfo.IpamConfig()
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,12 @@ type EndpointIPAMConfig struct {
|
||||||
LinkLocalIPs []string `json:",omitempty"`
|
LinkLocalIPs []string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PeerInfo represents one peer of a overlay network
|
||||||
|
type PeerInfo struct {
|
||||||
|
Name string
|
||||||
|
IP string
|
||||||
|
}
|
||||||
|
|
||||||
// EndpointSettings stores the network endpoint details
|
// EndpointSettings stores the network endpoint details
|
||||||
type EndpointSettings struct {
|
type EndpointSettings struct {
|
||||||
// Configurations
|
// Configurations
|
||||||
|
|
|
@ -396,6 +396,7 @@ type NetworkResource struct {
|
||||||
Containers map[string]EndpointResource // Containers contains endpoints belonging to the network
|
Containers map[string]EndpointResource // Containers contains endpoints belonging to the network
|
||||||
Options map[string]string // Options holds the network specific options to use for when creating the network
|
Options map[string]string // Options holds the network specific options to use for when creating the network
|
||||||
Labels map[string]string // Labels holds metadata specific to the network being created
|
Labels map[string]string // Labels holds metadata specific to the network being created
|
||||||
|
Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network
|
||||||
}
|
}
|
||||||
|
|
||||||
// EndpointResource contains network resources allocated and used for a container in a network
|
// EndpointResource contains network resources allocated and used for a container in a network
|
||||||
|
|
|
@ -183,6 +183,7 @@ This section lists each version from latest to oldest. Each listing includes a
|
||||||
* The `HostConfig` field now includes `CpuCount` that represents the number of CPUs available for execution by the container. Windows daemon only.
|
* The `HostConfig` field now includes `CpuCount` that represents the number of CPUs available for execution by the container. Windows daemon only.
|
||||||
* `POST /services/create` and `POST /services/(id or name)/update` now accept the `TTY` parameter, which allocate a pseudo-TTY in container.
|
* `POST /services/create` and `POST /services/(id or name)/update` now accept the `TTY` parameter, which allocate a pseudo-TTY in container.
|
||||||
* `POST /services/create` and `POST /services/(id or name)/update` now accept the `DNSConfig` parameter, which specifies DNS related configurations in resolver configuration file (resolv.conf) through `Nameservers`, `Search`, and `Options`.
|
* `POST /services/create` and `POST /services/(id or name)/update` now accept the `DNSConfig` parameter, which specifies DNS related configurations in resolver configuration file (resolv.conf) through `Nameservers`, `Search`, and `Options`.
|
||||||
|
* `GET /networks/(id or name)` now includes IP and name of all peers nodes for swarm mode overlay networks.
|
||||||
|
|
||||||
### v1.24 API changes
|
### v1.24 API changes
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,63 @@ $ docker network inspect simple-network
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For swarm mode overlay networks `network inspect` also shows the IP address and node name
|
||||||
|
of the peers. Peers are the nodes in the swarm cluster which have at least one task attached
|
||||||
|
to the network. Node name is of the format `<hostname>-<unique ID>`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ docker network inspect ingress
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"Name": "ingress",
|
||||||
|
"Id": "j0izitrut30h975vk4m1u5kk3",
|
||||||
|
"Created": "2016-11-08T06:49:59.803387552Z",
|
||||||
|
"Scope": "swarm",
|
||||||
|
"Driver": "overlay",
|
||||||
|
"EnableIPv6": false,
|
||||||
|
"IPAM": {
|
||||||
|
"Driver": "default",
|
||||||
|
"Options": null,
|
||||||
|
"Config": [
|
||||||
|
{
|
||||||
|
"Subnet": "10.255.0.0/16",
|
||||||
|
"Gateway": "10.255.0.1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Internal": false,
|
||||||
|
"Attachable": false,
|
||||||
|
"Containers": {
|
||||||
|
"ingress-sbox": {
|
||||||
|
"Name": "ingress-endpoint",
|
||||||
|
"EndpointID": "40e002d27b7e5d75f60bc72199d8cae3344e1896abec5eddae9743755fe09115",
|
||||||
|
"MacAddress": "02:42:0a:ff:00:03",
|
||||||
|
"IPv4Address": "10.255.0.3/16",
|
||||||
|
"IPv6Address": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Options": {
|
||||||
|
"com.docker.network.driver.overlay.vxlanid_list": "256"
|
||||||
|
},
|
||||||
|
"Labels": {},
|
||||||
|
"Peers": [
|
||||||
|
{
|
||||||
|
"Name": "net-1-1d22adfe4d5c",
|
||||||
|
"IP": "192.168.33.11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "net-2-d55d838b34af",
|
||||||
|
"IP": "192.168.33.12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "net-3-8473f8140bd9",
|
||||||
|
"IP": "192.168.33.13"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
## Related information
|
## Related information
|
||||||
|
|
||||||
* [network disconnect ](network_disconnect.md)
|
* [network disconnect ](network_disconnect.md)
|
||||||
|
|
Loading…
Reference in a new issue