This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.10.7. Configuring a macvlan network with basic customizations
As a cluster administrator, you can configure an additional network for your cluster using the macvlan Container Network Interface (CNI) plug-in. When a pod is attached to the network, the plug-in creates a sub-interface from the parent interface on the host. A unique hardware mac address is generated for each sub-device.
The unique MAC addresses this plug-in generates for sub-interfaces might not be compatible with the security polices of your cloud provider.
You specify a basic configuration directly in YAML. This approach offers fewer configuration options than by specifying a macvlan configuration by using a CNI object directly in JSON.
The Cluster Network Operator (CNO) manages additional network definitions. When you specify an additional network to create, the CNO creates the NetworkAttachmentDefinition
object automatically.
Do not edit the NetworkAttachmentDefinition
objects that the Cluster Network Operator manages. Doing so might disrupt network traffic on your additional network.
Prerequisites
-
Install the OpenShift CLI (
oc
). -
Log in as a user with
cluster-admin
privileges.
Procedure
To create an additional network for your cluster, complete the following steps:
Edit the CNO CR by running the following command:
oc edit networks.operator.openshift.io cluster
$ oc edit networks.operator.openshift.io cluster
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Modify the CR that you are creating by adding the configuration for the additional network you are creating, as in the following example CR.
The following YAML configures the macvlan CNI plug-in:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the configuration for the additional network attachment definition.
- Save your changes and quit the text editor to commit your changes.
Confirm that the CNO created the NetworkAttachmentDefinition object by running the following command. Replace
<namespace>
with the namespace that you specified when configuring the network attachment. There might be a delay before the CNO creates the object.oc get network-attachment-definitions -n <namespace>
$ oc get network-attachment-definitions -n <namespace>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME AGE test-network-1 14m
NAME AGE test-network-1 14m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
10.7.1.1. Configuration for macvlan CNI plug-in 复制链接链接已复制到粘贴板!
The following YAML describes the configuration parameters for the macvlan Container Network Interface (CNI) plug-in:
macvlan YAML configuration
- 1
- Specify a name for the additional network attachment that you are creating. The name must be unique within the specified
namespace
. - 2
- Specify the namespace to create the network attachment in. If a value is not specified, the
default
namespace is used. - 3
- The ethernet interface to associate with the virtual interface. If a value for
master
is not specified, then the host system’s primary ethernet interface is used. - 4
- Configures traffic visibility on the virtual network. Must be either
bridge
,passthru
,private
, orvepa
. If a value formode
is not provided, the default value isbridge
. - 5
- Set the maximum transmission unit (MTU) to the specified value. The default value is automatically set by the kernel.
- 6
- Specify a configuration object for the ipam CNI plug-in. The plug-in manages IP address assignment for the attachment definition.
10.7.1.1.1. macvlan configuration example 复制链接链接已复制到粘贴板!
The following example configures an additional network named macvlan-net
:
10.7.1.2. Configuration for ipam CNI plug-in 复制链接链接已复制到粘贴板!
The ipam Container Network Interface (CNI) plug-in provides IP address management (IPAM) for other CNI plug-ins.
The following YAML configuration describes the parameters that you can set.
ipam CNI plug-in YAML configuration object
ipamConfig: type: <type> ...
ipamConfig:
type: <type>
...
- 1
- Specify
static
to configure the plug-in to manage IP address assignment. SpecifyDHCP
to allow a DHCP server to manage IP address assignment. You cannot specify any additional parameters if you specify a value ofDHCP
. - 2
- If you set the
type
parameter tostatic
, then provide thestaticIPAMConfig
parameter.
10.7.1.2.1. Static ipam configuration YAML 复制链接链接已复制到粘贴板!
The following YAML describes a configuration for static IP address assignment:
Static ipam configuration YAML
- 1
- A collection of mappings that define IP addresses to assign to the virtual interface. Both IPv4 and IPv6 IP addresses are supported.
- 2
- An IP address and network prefix that you specify. For example, if you specify
10.10.21.10/24
, then the additional network is assigned an IP address of10.10.21.10
and the netmask is255.255.255.0
. - 3
- The default gateway to route egress network traffic to.
- 4
- A collection of mappings describing routes to configure inside the pod.
- 5
- The IP address range in CIDR format, such as
192.168.17.0/24
, or0.0.0.0/0
for the default route. - 6
- The gateway where network traffic is routed.
- 7
- Optional: The DNS configuration.
- 8
- A collection of one or more IP addresses for to send DNS queries to.
- 9
- The default domain to append to a host name. For example, if the domain is set to
example.com
, a DNS lookup query forexample-host
is rewritten asexample-host.example.com
. - 10
- An array of domain names to append to an unqualified host name, such as
example-host
, during a DNS lookup query.
10.7.1.2.2. Dynamic ipam configuration YAML 复制链接链接已复制到粘贴板!
The following YAML describes a configuration for static IP address assignment:
Dynamic ipam configuration YAML
ipamConfig: type: DHCP
ipamConfig:
type: DHCP
The following example shows an ipam configuration for static IP addresses:
The following example shows an ipam configuration for DHCP:
ipamConfig: type: DHCP
ipamConfig:
type: DHCP