Documentation
¶
Index ¶
- Constants
- Variables
- type ContainerNetwork
- type DNSNetworkInfo
- type FilterFunc
- type HardwareAddr
- type IPNet
- type LeaseRange
- type NetAddress
- type NetInterface
- type Network
- type NetworkBackend
- type NetworkCreateOptions
- type NetworkInfo
- type NetworkOptions
- type NetworkUpdateOptions
- type OCICNIPortMapping
- type PerNetworkOptions
- type PortMapping
- type Route
- type SetupOptions
- type StatusBlock
- type Subnet
- type TeardownOptions
Constants ¶
const ( // BridgeNetworkDriver defines the bridge driver BridgeNetworkDriver = "bridge" // DefaultNetworkDriver is the default network type used DefaultNetworkDriver = BridgeNetworkDriver // MacVLANNetworkDriver defines the macvlan driver MacVLANNetworkDriver = "macvlan" // MacVLANNetworkDriver defines the macvlan driver IPVLANNetworkDriver = "ipvlan" // IPAM drivers Driver = "driver" // HostLocalIPAMDriver store the ip locally in a db HostLocalIPAMDriver = "host-local" // DHCPIPAMDriver get subnet and ip from dhcp server DHCPIPAMDriver = "dhcp" // NoneIPAMDriver do not provide ipam management NoneIPAMDriver = "none" // DefaultSubnet is the name that will be used for the default CNI network. DefaultNetworkName = "podman" // DefaultSubnet is the subnet that will be used for the default CNI network. DefaultSubnet = "10.88.0.0/16" // valid macvlan driver mode values MacVLANModeBridge = "bridge" MacVLANModePrivate = "private" MacVLANModeVepa = "vepa" MacVLANModePassthru = "passthru" // valid ipvlan driver modes IPVLANModeL2 = "l2" IPVLANModeL3 = "l3" IPVLANModeL3s = "l3s" // valid network options VLANOption = "vlan" MTUOption = "mtu" ModeOption = "mode" IsolateOption = "isolate" MetricOption = "metric" NoDefaultRoute = "no_default_route" BclimOption = "bclim" )
Variables ¶
var ( // ErrNoSuchNetwork indicates the requested network does not exist ErrNoSuchNetwork = errors.New("network not found") // ErrInvalidArg indicates that an invalid argument was passed ErrInvalidArg = errors.New("invalid argument") // ErrNetworkExists indicates that a network with the given name already // exists. ErrNetworkExists = errors.New("network already exists") // NameRegex is a regular expression to validate names. // This must NOT be changed. NameRegex = regexp.Delayed("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$") // RegexError is thrown in presence of an invalid name. RegexError = fmt.Errorf("names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*: %w", ErrInvalidArg) // nolint:revive // This lint is new and we do not want to break the API. // NotHexRegex is a regular expression to check if a string is // a hexadecimal string. NotHexRegex = regexp.Delayed(`[^0-9a-fA-F]`) )
var ValidIPVLANModes = []string{IPVLANModeL2, IPVLANModeL3, IPVLANModeL3s}
ValidIPVLANModes is the list of valid mode options for the ipvlan driver
var ValidMacVLANModes = []string{MacVLANModeBridge, MacVLANModePrivate, MacVLANModeVepa, MacVLANModePassthru}
ValidMacVLANModes is the list of valid mode options for the macvlan driver
Functions ¶
This section is empty.
Types ¶
type ContainerNetwork ¶
type ContainerNetwork interface {
// NetworkCreate will take a partial filled Network and fill the
// missing fields. It creates the Network and returns the full Network.
NetworkCreate(Network, *NetworkCreateOptions) (Network, error)
// NetworkUpdate will take network name and ID and updates network DNS Servers.
NetworkUpdate(nameOrID string, options NetworkUpdateOptions) error
// NetworkRemove will remove the Network with the given name or ID.
NetworkRemove(nameOrID string) error
// NetworkList will return all known Networks. Optionally you can
// supply a list of filter functions. Only if a network matches all
// functions it is returned.
NetworkList(...FilterFunc) ([]Network, error)
// NetworkInspect will return the Network with the given name or ID.
NetworkInspect(nameOrID string) (Network, error)
// Setup will setup the container network namespace. It returns
// a map of StatusBlocks, the key is the network name.
Setup(namespacePath string, options SetupOptions) (map[string]StatusBlock, error)
// Teardown will teardown the container network namespace.
Teardown(namespacePath string, options TeardownOptions) error
// Drivers will return the list of supported network drivers
// for this interface.
Drivers() []string
// DefaultNetworkName will return the default network name
// for this interface.
DefaultNetworkName() string
// NetworkInfo return the network information about backend type,
// binary path, package version and so on.
NetworkInfo() NetworkInfo
}
type DNSNetworkInfo ¶ added in v0.54.0
type DNSNetworkInfo struct {
Version string `json:"version,omitempty"`
Package string `json:"package,omitempty"`
Path string `json:"path,omitempty"`
}
NetworkInfo contains the DNS information.
type FilterFunc ¶
FilterFunc can be passed to NetworkList to filter the networks.
type HardwareAddr ¶
type HardwareAddr net.HardwareAddr
HardwareAddr is the same as net.HardwareAddr except that it adds the json marshal/unmarshal methods. This allows us to read the mac from a json string and a byte array. swagger:model MacAddress
func (HardwareAddr) MarshalText ¶
func (h HardwareAddr) MarshalText() ([]byte, error)
func (*HardwareAddr) String ¶
func (h *HardwareAddr) String() string
func (*HardwareAddr) UnmarshalJSON ¶
func (h *HardwareAddr) UnmarshalJSON(text []byte) error
type IPNet ¶
IPNet is used as custom net.IPNet type to add Marshal/Unmarshal methods.
func (*IPNet) MarshalText ¶
func (*IPNet) UnmarshalText ¶
type LeaseRange ¶
type LeaseRange struct {
// StartIP first IP in the subnet which should be used to assign ips.
// swagger:strfmt string
StartIP net.IP `json:"start_ip,omitempty"`
// EndIP last IP in the subnet which should be used to assign ips.
// swagger:strfmt string
EndIP net.IP `json:"end_ip,omitempty"`
}
LeaseRange contains the range where IP are leased.
type NetAddress ¶
type NetAddress struct {
// IPNet of this NetAddress. Note that this is a subnet but it has to contain the
// actual ip of the network interface and not the network address.
IPNet IPNet `json:"ipnet"`
// Gateway for the network. This can be empty if there is no gateway, e.g. internal network.
Gateway net.IP `json:"gateway,omitempty"`
}
NetAddress contains the ip address, subnet and gateway.
type NetInterface ¶
type NetInterface struct {
// Subnets list of assigned subnets with their gateway.
Subnets []NetAddress `json:"subnets,omitempty"`
// MacAddress for this Interface.
MacAddress HardwareAddr `json:"mac_address"`
}
NetInterface contains the settings for a given network interface.
type Network ¶
type Network struct {
// Name of the Network.
Name string `json:"name"`
// ID of the Network.
ID string `json:"id"`
// Driver for this Network, e.g. bridge, macvlan...
Driver string `json:"driver"`
// NetworkInterface is the network interface name on the host.
NetworkInterface string `json:"network_interface,omitempty"`
// Created contains the timestamp when this network was created.
Created time.Time `json:"created,omitempty"`
// Subnets to use for this network.
Subnets []Subnet `json:"subnets,omitempty"`
// Routes to use for this network.
Routes []Route `json:"routes,omitempty"`
// IPv6Enabled if set to true an ipv6 subnet should be created for this net.
IPv6Enabled bool `json:"ipv6_enabled"`
// Internal is whether the Network should not have external routes
// to public or other Networks.
Internal bool `json:"internal"`
// DNSEnabled is whether name resolution is active for container on
// this Network. Only supported with the bridge driver.
DNSEnabled bool `json:"dns_enabled"`
// List of custom DNS server for podman's DNS resolver at network level,
// all the containers attached to this network will consider resolvers
// configured at network level.
NetworkDNSServers []string `json:"network_dns_servers,omitempty"`
// Labels is a set of key-value labels that have been applied to the
// Network.
Labels map[string]string `json:"labels,omitempty"`
// Options is a set of key-value options that have been applied to
// the Network.
Options map[string]string `json:"options,omitempty"`
// IPAMOptions contains options used for the ip assignment.
IPAMOptions map[string]string `json:"ipam_options,omitempty"`
}
Network describes the Network attributes.
type NetworkBackend ¶
type NetworkBackend string
const ( CNI NetworkBackend = "cni" Netavark NetworkBackend = "netavark" )
type NetworkCreateOptions ¶ added in v0.51.0
type NetworkCreateOptions struct {
// IgnoreIfExists if true, do not fail if the network already exists
IgnoreIfExists bool
}
type NetworkInfo ¶ added in v0.54.0
type NetworkInfo struct {
Backend NetworkBackend `json:"backend"`
Version string `json:"version,omitempty"`
Package string `json:"package,omitempty"`
Path string `json:"path,omitempty"`
DNS DNSNetworkInfo `json:"dns,omitempty"`
}
NetworkInfo contains the network information.
type NetworkOptions ¶
type NetworkOptions struct {
// ContainerID is the container id, used for iptables comments and ipam allocation.
ContainerID string `json:"container_id"`
// ContainerName is the container name, used as dns name.
ContainerName string `json:"container_name"`
// PortMappings contains the port mappings for this container
PortMappings []PortMapping `json:"port_mappings,omitempty"`
// Networks contains all networks with the PerNetworkOptions.
// The map should contain at least one element.
Networks map[string]PerNetworkOptions `json:"networks"`
// List of custom DNS server for podman's DNS resolver.
// Priority order will be kept as defined by user in the configuration.
DNSServers []string `json:"dns_servers,omitempty"`
}
NetworkOptions for a given container.
type NetworkUpdateOptions ¶ added in v0.51.0
type NetworkUpdateOptions struct {
// List of custom DNS server for podman's DNS resolver.
// Priority order will be kept as defined by user in the configuration.
AddDNSServers []string `json:"add_dns_servers,omitempty"`
RemoveDNSServers []string `json:"remove_dns_servers,omitempty"`
}
NetworkOptions for a given container.
type OCICNIPortMapping ¶
type OCICNIPortMapping struct {
// HostPort is the port number on the host.
HostPort int32 `json:"hostPort"`
// ContainerPort is the port number inside the sandbox.
ContainerPort int32 `json:"containerPort"`
// Protocol is the protocol of the port mapping.
Protocol string `json:"protocol"`
// HostIP is the host ip to use.
HostIP string `json:"hostIP"`
}
OCICNIPortMapping maps to the standard CNI portmapping Capability. Deprecated: Do not use this struct for new fields. This only exists for backwards compatibility.
type PerNetworkOptions ¶
type PerNetworkOptions struct {
// StaticIPs for this container. Optional.
// swagger:type []string
StaticIPs []net.IP `json:"static_ips,omitempty"`
// Aliases contains a list of names which the dns server should resolve
// to this container. Should only be set when DNSEnabled is true on the Network.
// If aliases are set but there is no dns support for this network the
// network interface implementation should ignore this and NOT error.
// Optional.
Aliases []string `json:"aliases,omitempty"`
// StaticMac for this container. Optional.
// swagger:strfmt string
StaticMAC HardwareAddr `json:"static_mac,omitempty"`
// InterfaceName for this container. Required in the backend.
// Optional in the frontend. Will be filled with ethX (where X is a integer) when empty.
InterfaceName string `json:"interface_name"`
}
PerNetworkOptions are options which should be set on a per network basis.
type PortMapping ¶
type PortMapping struct {
// HostIP is the IP that we will bind to on the host.
// If unset, assumed to be 0.0.0.0 (all interfaces).
HostIP string `json:"host_ip"`
// ContainerPort is the port number that will be exposed from the
// container.
// Mandatory.
ContainerPort uint16 `json:"container_port"`
// HostPort is the port number that will be forwarded from the host into
// the container.
// If omitted, a random port on the host (guaranteed to be over 1024)
// will be assigned.
HostPort uint16 `json:"host_port"`
// Range is the number of ports that will be forwarded, starting at
// HostPort and ContainerPort and counting up.
// This is 1-indexed, so 1 is assumed to be a single port (only the
// Hostport:Containerport mapping will be added), 2 is two ports (both
// Hostport:Containerport and Hostport+1:Containerport+1), etc.
// If unset, assumed to be 1 (a single port).
// Both hostport + range and containerport + range must be less than
// 65536.
Range uint16 `json:"range"`
// Protocol is the protocol forward.
// Must be either "tcp", "udp", and "sctp", or some combination of these
// separated by commas.
// If unset, assumed to be TCP.
Protocol string `json:"protocol"`
}
PortMapping is one or more ports that will be mapped into the container.
type SetupOptions ¶
type SetupOptions struct {
NetworkOptions
}
type StatusBlock ¶
type StatusBlock struct {
// Interfaces contains the created network interface in the container.
// The map key is the interface name.
Interfaces map[string]NetInterface `json:"interfaces,omitempty"`
// DNSServerIPs nameserver addresses which should be added to
// the containers resolv.conf file.
DNSServerIPs []net.IP `json:"dns_server_ips,omitempty"`
// DNSSearchDomains search domains which should be added to
// the containers resolv.conf file.
DNSSearchDomains []string `json:"dns_search_domains,omitempty"`
}
StatusBlock contains the network information about a container connected to one Network.
type Subnet ¶
type Subnet struct {
// Subnet for this Network in CIDR form.
// swagger:strfmt string
Subnet IPNet `json:"subnet"`
// Gateway IP for this Network.
// swagger:strfmt string
Gateway net.IP `json:"gateway,omitempty"`
// LeaseRange contains the range where IP are leased. Optional.
LeaseRange *LeaseRange `json:"lease_range,omitempty"`
}
type TeardownOptions ¶
type TeardownOptions struct {
NetworkOptions
}