From 85e8fbf7f33717ef6a0d6cf9e2143b52c874c2de Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 16 Aug 2021 16:11:26 +0200 Subject: Wire network interface into libpod Make use of the new network interface in libpod. This commit contains several breaking changes: - podman network create only outputs the new network name and not file path. - podman network ls shows the network driver instead of the cni version and plugins. - podman network inspect outputs the new network struct and not the cni conflist. - The bindings and libpod api endpoints have been changed to use the new network structure. The container network status is stored in a new field in the state. The status should be received with the new `c.getNetworkStatus`. This will migrate the old status to the new format. Therefore old containers should contine to work correctly in all cases even when network connect/ disconnect is used. New features: - podman network reload keeps the ip and mac for more than one network. - podman container restore keeps the ip and mac for more than one network. - The network create compat endpoint can now use more than one ipam config. The man pages and the swagger doc are updated to reflect the latest changes. Signed-off-by: Paul Holzinger --- docs/source/markdown/podman-network-create.1.md | 39 ++++++------ docs/source/markdown/podman-network-inspect.1.md | 76 ++++++++++++++---------- docs/source/markdown/podman-network-ls.1.md | 67 +++++++++++++-------- 3 files changed, 106 insertions(+), 76 deletions(-) (limited to 'docs') diff --git a/docs/source/markdown/podman-network-create.1.md b/docs/source/markdown/podman-network-create.1.md index 04290c188..816dd53ea 100644 --- a/docs/source/markdown/podman-network-create.1.md +++ b/docs/source/markdown/podman-network-create.1.md @@ -15,7 +15,7 @@ with the host network's DHCP server. If no options are provided, Podman will assign a free subnet and name for your network. -Upon completion of creating the network, Podman will display the path to the newly added network file. +Upon completion of creating the network, Podman will display the name of the newly added network. ## OPTIONS #### **--disable-dns** @@ -61,49 +61,50 @@ The subnet in CIDR notation. #### **--ipv6** -Enable IPv6 (Dual Stack) networking. You must pass a IPv6 subnet. The *subnet* option must be used with the *ipv6* option. +Enable IPv6 (Dual Stack) networking. ## EXAMPLE -Create a network with no options +Create a network with no options. ``` -# podman network create -/etc/cni/net.d/cni-podman-4.conflist +$ podman network create +cni-podman2 ``` Create a network named *newnet* that uses *192.5.0.0/16* for its subnet. ``` -# podman network create --subnet 192.5.0.0/16 newnet -/etc/cni/net.d/newnet.conflist +$ podman network create --subnet 192.5.0.0/16 newnet +newnet ``` -Create an IPv6 network named *newnetv6*, you must specify the subnet for this network, otherwise the command will fail. -For this example, we use *2001:db8::/64* for its subnet. +Create an IPv6 network named *newnetv6* with a subnet of *2001:db8::/64*. ``` -# podman network create --subnet 2001:db8::/64 --ipv6 newnetv6 -/etc/cni/net.d/newnetv6.conflist +$ podman network create --subnet 2001:db8::/64 --ipv6 newnetv6 +newnetv6 ``` -Create a network named *newnet* that uses *192.168.33.0/24* and defines a gateway as *192.168.133.3* +Create a network named *newnet* that uses *192.168.33.0/24* and defines a gateway as *192.168.133.3*. ``` -# podman network create --subnet 192.168.33.0/24 --gateway 192.168.33.3 newnet -/etc/cni/net.d/newnet.conflist +$ podman network create --subnet 192.168.33.0/24 --gateway 192.168.33.3 newnet +newnet ``` Create a network that uses a *192.168.55.0/24** subnet and has an IP address range of *192.168.55.129 - 192.168.55.254*. ``` -# podman network create --subnet 192.168.55.0/24 --ip-range 192.168.55.128/25 -/etc/cni/net.d/cni-podman-5.conflist +$ podman network create --subnet 192.168.55.0/24 --ip-range 192.168.55.128/25 +cni-podman5 ``` -Create a Macvlan based network using the host interface eth0 +Create a Macvlan based network using the host interface eth0. Macvlan networks can only be used as root. ``` # podman network create -d macvlan -o parent=eth0 newnet -/etc/cni/net.d/newnet.conflist +newnet ``` ## SEE ALSO -podman(1), podman-network(1), podman-network-inspect(1) +**[podman(1)](podman.1.md)**, **[podman-network(1)](podman-network.1.md)**, **[podman-network-inspect(1)](podman-network-inspect.1.md)**, **[podman-network-ls(1)](podman-network-ls.1.md)** ## HISTORY +August 2021, Updated with the new network format by Paul Holzinger + August 2019, Originally compiled by Brent Baude diff --git a/docs/source/markdown/podman-network-inspect.1.md b/docs/source/markdown/podman-network-inspect.1.md index 56515d0c1..726f167e5 100644 --- a/docs/source/markdown/podman-network-inspect.1.md +++ b/docs/source/markdown/podman-network-inspect.1.md @@ -4,57 +4,71 @@ podman\-network\-inspect - Displays the raw CNI network configuration for one or more networks ## SYNOPSIS -**podman network inspect** [*options*] [*network* ...] +**podman network inspect** [*options*] *network* [*network* ...] ## DESCRIPTION Display the raw (JSON format) network configuration. ## OPTIONS -#### **--format**, **-f** +#### **--format**, **-f**=*format* Pretty-print networks to JSON or using a Go template. +| **Placeholder** | **Description** | +| ----------------- | ----------------------------------------- | +| .ID | Network ID | +| .Name | Network name | +| .Driver | Network driver | +| .Labels | Network labels | +| .Options | Network options | +| .IPAMOptions | Network ipam options | +| .Created | Timestamp when the network was created | +| .Internal | Network is internal (boolean) | +| .IPv6Enabled | Network has ipv6 subnet (boolean) | +| .DNSEnabled | Network has dns enabled (boolean) | +| .NetworkInterface | Name of the network interface on the host | +| .Subnets | List of subnets on this network | + ## EXAMPLE -Inspect the default podman network +Inspect the default podman network. ``` -# podman network inspect podman -[{ - "cniVersion": "0.3.0", - "name": "podman", - "plugins": [ - { - "type": "bridge", - "bridge": "cni0", - "isGateway": true, - "ipMasq": true, - "ipam": { - "type": "host-local", - "subnet": "10.88.1.0/24", - "routes": [ - { "dst": "0.0.0.0/0" } - ] - } - }, - { - "type": "portmap", - "capabilities": { - "portMappings": true +$ podman network inspect podman +[ + { + "name": "podman", + "id": "2f259bab93aaaaa2542ba43ef33eb990d0999ee1b9924b557b7be53c0b7a1bb9", + "driver": "bridge", + "network_interface": "cni-podman0", + "created": "2021-06-03T12:04:33.088567413+02:00", + "subnets": [ + { + "subnet": "10.88.0.0/16", + "gateway": "10.88.0.1" + } + ], + "ipv6_enabled": false, + "internal": false, + "dns_enabled": false, + "ipam_options": { + "driver": "host-local" } - } - ] -} + } ] ``` +Show the subnet and gateway for a network. + ``` -# podman network inspect podman --format '{{(index .plugins 0).ipam.ranges}}' -[[map[gateway:10.88.0.1 subnet:10.88.0.0/16]]] +$ podman network inspect podman --format "{{range .Subnets}}Subnet: {{.Subnet}} Gateway: {{.Gateway}}{{end}}" +Subnet: 10.88.0.0/16 Gateway: 10.88.0.1 ``` ## SEE ALSO -podman(1), podman-network(1), podman-network-ls(1) +**[podman(1)](podman.1.md)**, **[podman-network(1)](podman-network.1.md)**, **[podman-network-ls(1)](podman-network-ls.1.md)**, **[podman-network-create(1)](podman-network-create.1.md)** ## HISTORY +August 2021, Updated with the new network format by Paul Holzinger + August 2019, Originally compiled by Brent Baude diff --git a/docs/source/markdown/podman-network-ls.1.md b/docs/source/markdown/podman-network-ls.1.md index b7fd13ec6..99b734157 100644 --- a/docs/source/markdown/podman-network-ls.1.md +++ b/docs/source/markdown/podman-network-ls.1.md @@ -10,7 +10,7 @@ podman\-network\-ls - Display a summary of CNI networks Displays a list of existing podman networks. ## OPTIONS -#### **--filter**, **-f** +#### **--filter**, **-f**=*filter=value* Filter output based on conditions given. Multiple filters can be given with multiple uses of the --filter option. @@ -19,27 +19,34 @@ Filters with the same key work inclusive with the only exception being Valid filters are listed below: -| **Filter** | **Description** | -| ---------- | ------------------------------------------------------------------------------------- | -| name | [Name] Network name (accepts regex) | -| id | [ID] Full or partial network ID | -| label | [Key] or [Key=Value] Label assigned to a network | -| plugin | [Plugin] CNI plugins included in a network (e.g `bridge`,`portmap`,`firewall`,`tuning`,`dnsname`,`macvlan`) | -| driver | [Driver] Only `bridge` is supported | +| **Filter** | **Description** | +| ---------- | ----------------------------------------------------------------- | +| name | [Name] Network name (accepts regex) | +| id | [ID] Full or partial network ID | +| label | [Key] or [Key=Value] Label assigned to a network | +| driver | [Driver] `bridge` or ,`macvlan` is supported | +| until | [Until] Show all networks that were created before the given time | -#### **--format** +#### **--format**=*format* Change the default output format. This can be of a supported type like 'json' or a Go template. Valid placeholders for the Go template are listed below: -| **Placeholder** | **Description** | -| --------------- | --------------------------------| -| .ID | Network ID | -| .Name | Network name | -| .Plugins | Network Plugins | -| .Labels | Network labels | -| .Version | CNI Version of the config file | +| **Placeholder** | **Description** | +| ----------------- | ----------------------------------------- | +| .ID | Network ID | +| .Name | Network name | +| .Driver | Network driver | +| .Labels | Network labels | +| .Options | Network options | +| .IPAMOptions | Network ipam options | +| .Created | Timestamp when the network was created | +| .Internal | Network is internal (boolean) | +| .IPv6Enabled | Network has ipv6 subnet (boolean) | +| .DNSEnabled | Network has dns enabled (boolean) | +| .NetworkInterface | Name of the network interface on the host | +| .Subnets | List of subnets on this network | #### **--noheading** @@ -47,7 +54,7 @@ Omit the table headings from the listing of networks. #### **--no-trunc** -Do not truncate the network ID. The network ID is not displayed by default and must be specified with **--format**. +Do not truncate the network ID. #### **--quiet**, **-q** @@ -58,17 +65,16 @@ The `quiet` option will restrict the output to only the network names. Display networks ``` -# podman network ls -NAME VERSION PLUGINS -podman 0.3.0 bridge,portmap -podman2 0.3.0 bridge,portmap -outside 0.3.0 bridge -podman9 0.3.0 bridge,portmap +$ podman network ls +NETWORK ID NAME DRIVER +88a7120ee19d podman bridge +6dd508dbf8cd cni-podman6 bridge +8e35c2cd3bf6 cni-podman5 macvlan ``` Display only network names ``` -# podman network ls -q +$ podman network ls -q podman podman2 outside @@ -77,14 +83,23 @@ podman9 Display name of network which support bridge plugin ``` -# podman network ls --filter plugin=portmap --format {{.Name}} +$ podman network ls --filter driver=bridge --format {{.Name}} podman podman2 podman9 ``` +List networks with their subnets +``` +$ podman network ls --format "{{.Name}}: {{range .Subnets}}{{.Subnet}} {{end}}" +podman: 10.88.0.0/16 +cni-podman3: 10.89.30.0/24 fde4:f86f:4aab:e68f::/64 +macvlan: +``` ## SEE ALSO -podman(1), podman-network(1), podman-network-inspect(1) +**[podman(1)](podman.1.md)**, **[podman-network(1)](podman-network.1.md)**, **[podman-network-inspect(1)](podman-network-inspect.1.md)**, **[podman-network-create(1)](podman-network-create.1.md)** ## HISTORY +August 2021, Updated with the new network format by Paul Holzinger + August 2019, Originally compiled by Brent Baude -- cgit v1.2.3-54-g00ecf