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.Questo contenuto non è disponibile nella lingua selezionata.
Chapter 7. Multiple networks
7.1. Understanding multiple networks Copia collegamentoCollegamento copiato negli appunti!
In Kubernetes, container networking is delegated to networking plug-ins that implement the Container Network Interface (CNI).
OpenShift Container Platform uses the Multus CNI plug-in to allow chaining of CNI plug-ins. During cluster installation, you configure your default Pod network. The default network handles all ordinary network traffic for the cluster. You can define an additional network based on the available CNI plug-ins and attach one or more of these networks to your Pods. You can define more than one additional network for your cluster, depending on your needs. This gives you flexibility when you configure Pods that deliver network functionality, such as switching or routing.
7.1.1. Usage scenarios for an additional network Copia collegamentoCollegamento copiato negli appunti!
You can use an additional network in situations where network isolation is needed, including data plane and control plane separation. Isolating network traffic is useful for the following performance and security reasons:
- Performance
- You can send traffic on two different planes in order to manage how much traffic is along each plane.
- Security
- You can send sensitive traffic onto a network plane that is managed specifically for security considerations, and you can separate private data that must not be shared between tenants or customers.
All of the Pods in the cluster still use the cluster-wide default network to maintain connectivity across the cluster. Every Pod has an eth0
interface that is attached to the cluster-wide Pod network. You can view the interfaces for a Pod by using the oc exec -it <pod_name> -- ip a
command. If you add additional network interfaces that use Multus CNI, they are named net1
, net2
, …, netN
.
To attach additional network interfaces to a Pod, you must create configurations that define how the interfaces are attached. You specify each interface by using a Custom Resource (CR) that has a NetworkAttachmentDefinition
type. A CNI configuration inside each of these CRs defines how that interface is created.
7.1.2. Additional networks in OpenShift Container Platform Copia collegamentoCollegamento copiato negli appunti!
OpenShift Container Platform provides the following CNI plug-ins for creating additional networks in your cluster:
- bridge: Creating a bridge-based additional network allows Pods on the same host to communicate with each other and the host.
- host-device: Creating a host-device additional network allows Pods access to a physical Ethernet network device on the host system.
- macvlan: Creating a macvlan-based additional network allows Pods on a host to communicate with other hosts and Pods on those hosts by using a physical network interface. Each Pod that is attached to a macvlan-based additional network is provided a unique MAC address.
- ipvlan: Creating an ipvlan-based additional network allows Pods on a host to communicate with other hosts and Pods on those hosts, similar to a macvlan-based additional network. Unlike a macvlan-based additional network, each Pod shares the same MAC address as the parent physical network interface.
- SR-IOV: Creating a SR-IOV based additional network allows Pods to attach to a virtual function (VF) interface on SR-IOV capable hardware on the host system.
7.2. Attaching a Pod to an additional network Copia collegamentoCollegamento copiato negli appunti!
As a cluster user you can attach a Pod to an additional network.
7.2.1. Adding a Pod to an additional network Copia collegamentoCollegamento copiato negli appunti!
You can add a Pod to an additional network. The Pod continues to send normal cluster related network traffic over the default network.
Prerequisites
- The Pod must be in the same namespace as the additional network.
-
Install the OpenShift Command-line Interface (CLI), commonly known as
oc
. - You must log in to the cluster.
Procedure
To add a Pod with additional networks, complete the following steps:
Create the Pod resource definition and add the
k8s.v1.cni.cncf.io/networks
parameter to the Podmetadata
mapping. Thek8s.v1.cni.cncf.io/networks
accepts a comma separated string of one or more NetworkAttachmentDefinition Custom Resource (CR) names:metadata: annotations: k8s.v1.cni.cncf.io/networks: <network>[,<network>,...]
metadata: annotations: k8s.v1.cni.cncf.io/networks: <network>[,<network>,...]
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<network>
with the name of the additional network to associate with the Pod. To specify more than one additional network, separate each network with a comma. Do not include whitespace between the comma. If you specify the same additional network multiple times, that Pod will have multiple network interfaces attached to that network.
In the following example, two additional networks are attached to the Pod:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the Pod by running the following command:
oc create -f pod.yaml
$ oc create -f pod.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Confirm that the annotation exists in the Pod CR by running the following command. Replace
<name>
with the name of the Pod.oc get pod <name> -o yaml
$ oc get pod <name> -o yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the following example, the
example-pod
Pod is attached to thenet1
additional network:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
k8s.v1.cni.cncf.io/networks-status
parameter is a JSON array of objects. Each object describes the status of an additional network attached to the Pod. The annotation value is stored as a plain text value.
7.3. Removing a Pod from an additional network Copia collegamentoCollegamento copiato negli appunti!
As a cluster user you can remove a Pod from an additional network.
7.3.1. Removing a Pod from an additional network Copia collegamentoCollegamento copiato negli appunti!
You can remove a Pod from an additional network.
Prerequisites
- You have configured an additional network for your cluster.
- You have an additional network attached to the Pod.
-
Install the OpenShift Command-line Interface (CLI), commonly known as
oc
. - You must log in to the cluster.
Procedure
To remove a Pod from an additional network, complete the following steps:
Edit the Pod resource definition by running the following command. Replace
<name>
with the name of the Pod to edit.oc edit pod <name>
$ oc edit pod <name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the
annotations
mapping to remove the additional network from the Pod by performing one of the following actions:To remove all additional networks from a Pod, remove the
k8s.v1.cni.cncf.io/networks
parameter from the Pod resource definition as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
To remove a specific additional network from a Pod, update the
k8s.v1.cni.cncf.io/networks
parameter by removing the name of the NetworkAttachmentDefinition for the additional network.
Optional: Confirm that the Pod is no longer attached to the additional network by running the following command. Replace
<name>
with the name of the Pod.oc describe pod <name>
$ oc describe pod <name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the following example, the
example-pod
Pod is attached only to the default cluster network.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Only the default cluster network is attached to the Pod.
7.4. Configuring a bridge network Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator, you can configure an additional network for your cluster using the bridge Container Network Interface (CNI) plug-in. When configured, all Pods on a node are connected to a virtual switch. Each Pod is assigned an IP address on the additional network.
7.4.1. Creating an additional network attachment with the bridge CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
The Cluster Network Operator (CNO) manages additional network definitions. When you specify an additional network to create, the CNO creates the NetworkAttachmentDefinition Custom Resource (CR) automatically.
Do not edit the NetworkAttachmentDefinition CRs that the Cluster Network Operator manages. Doing so might disrupt network traffic on your additional network.
Prerequisites
-
Install the OpenShift Command-line Interface (CLI), commonly known as
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 bridge 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.
Optional: Confirm that the CNO created the NetworkAttachmentDefinition CR by running the following command. There might be a delay before the CNO creates the CR.
oc get network-attachment-definitions -n <namespace>
$ oc get network-attachment-definitions -n <namespace> NAME AGE test-network-1 14m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.4.1.1. Configuration for bridge Copia collegamentoCollegamento copiato negli appunti!
The configuration for an additional network attachment that uses the bridge Container Network Interface (CNI) plug-in is provided in two parts:
- Cluster Network Operator (CNO) configuration
- CNI plug-in configuration
The CNO configuration specifies the name for the additional network attachment and the namespace to create the attachment in. The plug-in is configured by a JSON object specified by the rawCNIConfig
parameter in the CNO configuration.
The following YAML describes the configuration parameters for the CNO:
Cluster Network Operator 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 you do not specify a value, then the
default
namespace is used. - 3
- Specify the CNI plug-in configuration in JSON format, which is based on the following template.
The following object describes the configuration parameters for the bridge CNI plug-in:
bridge CNI plug-in JSON configuration object
- 1
- Specify the value for the
name
parameter you provided previously for the CNO configuration. - 2
- Specify the name of the virtual bridge to use. If the bridge interface does not exist on the host, it is created. The default value is
cni0
. - 3
- Specify a configuration object for the ipam CNI plug-in. The plug-in manages IP address assignment for the network attachment definition.
- 4
- Set to
true
to enable IP masquerading for traffic that leaves the virtual network. The source IP address for all traffic is rewritten to the bridge’s IP address. If the bridge does not have an IP address, this setting has no effect. The default value isfalse
. - 5
- Set to
true
to assign an IP address to the bridge. The default value isfalse
. - 6
- Set to
true
to configure the bridge as the default gateway for the virtual network. The default value isfalse
. IfisDefaultGateway
is set totrue
, thenisGateway
is also set totrue
automatically. - 7
- Set to
true
to allow assignment of a previously assigned IP address to the virtual bridge. When set tofalse
, if an IPv4 address or an IPv6 address from overlapping subsets is assigned to the virtual bridge, an error occurs. The default value isfalse
. - 8
- Set to
true
to allow the virtual bridge to send an ethernet frame back through the virtual port it was received on. This mode is also known as reflective relay. The default value isfalse
. - 9
- Set to
true
to enable promiscuous mode on the bridge. The default value isfalse
. - 10
- Specify a virtual LAN (VLAN) tag as an integer value. By default, no VLAN tag is assigned.
- 11
- Set the maximum transmission unit (MTU) to the specified value. The default value is automatically set by the kernel.
7.4.1.1.1. bridge configuration example Copia collegamentoCollegamento copiato negli appunti!
The following example configures an additional network named bridge-net
:
- 1
- The CNI configuration object is specified as a YAML string.
7.4.1.2. Configuration for ipam CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
The ipam Container Network Interface (CNI) plug-in provides IP address management (IPAM) for other CNI plug-ins. You can configure ipam for either static IP address assignment or dynamic IP address assignment by using DHCP. The DHCP server you specify must be reachable from the additional network.
In OpenShift Container Platform 4.2.0, if you attach a Pod to an additional network that uses DHCP for IP address management, the Pod will fail to start. This is fixed in OpenShift Container Platform 4.2.1. For more information, see BZ#1754686.
The following JSON configuration object describes the parameters that you can set.
7.4.1.2.1. Static IP address assignment configuration Copia collegamentoCollegamento copiato negli appunti!
The following JSON describes the configuration for static IP address assignment:
Static assignment configuration
- 1
- An array describing IP addresses to assign to the virtual interface. Both IPv4 and IPv6 IP addresses are supported.
- 2
- An IP address that you specify.
- 3
- The default gateway to route egress network traffic to.
- 4
- An array describing routes to configure inside the Pod.
- 5
- The IP address range in CIDR format.
- 6
- The gateway where network traffic is routed.
- 7
- Optional: DNS configuration.
- 8
- An of array 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.
7.4.1.2.2. Dynamic IP address assignment configuration Copia collegamentoCollegamento copiato negli appunti!
The following JSON describes the configuration for dynamic IP address assignment with DHCP:
DHCP assignment configuration
{ "ipam": { "type": "dhcp" } }
{
"ipam": {
"type": "dhcp"
}
}
7.4.1.2.3. Static IP address assignment configuration example Copia collegamentoCollegamento copiato negli appunti!
You can configure ipam for static IP address assignment:
7.4.1.2.4. Dynamic IP address assignment configuration example using DHCP Copia collegamentoCollegamento copiato negli appunti!
You can configure ipam for DHCP:
{ "ipam": { "type": "dhcp" } }
{
"ipam": {
"type": "dhcp"
}
}
Next steps
7.5. Configuring a macvlan network Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator, you can configure an additional network for your cluster using the macvlan 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.
7.5.1. Creating an additional network attachment with the macvlan CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
The Cluster Network Operator (CNO) manages additional network definitions. When you specify an additional network to create, the CNO creates the NetworkAttachmentDefinition Custom Resource (CR) automatically.
Do not edit the NetworkAttachmentDefinition CRs that the Cluster Network Operator manages. Doing so might disrupt network traffic on your additional network.
Prerequisites
-
Install the OpenShift Command-line Interface (CLI), commonly known as
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.
Optional: Confirm that the CNO created the NetworkAttachmentDefinition CR by running the following command. There might be a delay before the CNO creates the CR.
oc get network-attachment-definitions -n <namespace>
$ oc get network-attachment-definitions -n <namespace> NAME AGE test-network-1 14m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.5.1.1. Configuration for macvlan CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
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.
7.5.1.1.1. macvlan configuration example Copia collegamentoCollegamento copiato negli appunti!
The following example configures an additional network named macvlan-net
:
7.5.1.2. Configuration for ipam CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
The ipam Container Network Interface (CNI) plug-in provides IP address management (IPAM) for other CNI plug-ins. You can configure ipam for either static IP address assignment or dynamic IP address assignment by using DHCP. The DHCP server you specify must be reachable from the additional network.
In OpenShift Container Platform 4.2.0, if you attach a Pod to an additional network that uses DHCP for IP address management, the Pod will fail to start. This is fixed in OpenShift Container Platform 4.2.1. For more information, see BZ#1754686.
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.
7.5.1.2.1. Static ipam configuration YAML Copia collegamentoCollegamento copiato negli appunti!
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 that you specify.
- 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.
- 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.
7.5.1.2.2. Dynamic ipam configuration YAML Copia collegamentoCollegamento copiato negli appunti!
The following YAML describes a configuration for static IP address assignment:
Dynamic ipam configuration YAML
ipamConfig: type: DHCP
ipamConfig:
type: DHCP
7.5.1.2.3. Static IP address assignment configuration example Copia collegamentoCollegamento copiato negli appunti!
The following example shows an ipam configuration for static IP addresses:
7.5.1.2.4. Dynamic IP address assignment configuration example Copia collegamentoCollegamento copiato negli appunti!
The following example shows an ipam configuration for DHCP:
ipamConfig: type: DHCP
ipamConfig:
type: DHCP
Next steps
7.6. Configuring an ipvlan network Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator, you can configure an additional network for your cluster by using the ipvlan Container Network Interface (CNI) plug-in. The virtual network created by this plug-in is associated with a physical interface that you specify.
7.6.1. Creating an additional network attachment with the ipvlan CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
The Cluster Network Operator (CNO) manages additional network definitions. When you specify an additional network to create, the CNO creates the NetworkAttachmentDefinition Custom Resource (CR) automatically.
Do not edit the NetworkAttachmentDefinition CRs that the Cluster Network Operator manages. Doing so might disrupt network traffic on your additional network.
Prerequisites
-
Install the OpenShift Command-line Interface (CLI), commonly known as
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 ipvlan 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.
Optional: Confirm that the CNO created the NetworkAttachmentDefinition CR by running the following command. There might be a delay before the CNO creates the CR.
oc get network-attachment-definitions -n <namespace>
$ oc get network-attachment-definitions -n <namespace> NAME AGE test-network-1 14m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.6.1.1. Configuration for ipvlan Copia collegamentoCollegamento copiato negli appunti!
The configuration for an additional network attachment that uses the ipvlan Container Network Interface (CNI) plug-in is provided in two parts:
- Cluster Network Operator (CNO) configuration
- CNI plug-in configuration
The CNO configuration specifies the name for the additional network attachment and the namespace to create the attachment in. The plug-in is configured by a JSON object specified by the rawCNIConfig
parameter in the CNO configuration.
The following YAML describes the configuration parameters for the CNO:
Cluster Network Operator 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 you do not specify a value, then the
default
namespace is used. - 3
- Specify the CNI plug-in configuration in JSON format, which is based on the following template.
The following object describes the configuration parameters for the ipvlan CNI plug-in:
ipvlan CNI plug-in JSON configuration object
- 1
- Specify the value for the
name
parameter you provided previously for the CNO configuration. - 2
- Specify the operating mode for the virtual network. The value must be
l2
,l3
, orl3s
. The default value isl2
. - 3
- Specify the ethernet interface to associate with the network attachment. If a
master
is not specified, the interface for the default network route is used. - 4
- Set the maximum transmission unit (MTU) to the specified value. The default value is automatically set by the kernel.
- 5
- Specify a configuration object for the ipam CNI plug-in. The plug-in manages IP address assignment for the attachment definition.
7.6.1.1.1. ipvlan configuration example Copia collegamentoCollegamento copiato negli appunti!
The following example configures an additional network named ipvlan-net
:
- 1
- The CNI configuration object is specified as a YAML string.
7.6.1.2. Configuration for ipam CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
The ipam Container Network Interface (CNI) plug-in provides IP address management (IPAM) for other CNI plug-ins. You can configure ipam for either static IP address assignment or dynamic IP address assignment by using DHCP. The DHCP server you specify must be reachable from the additional network.
In OpenShift Container Platform 4.2.0, if you attach a Pod to an additional network that uses DHCP for IP address management, the Pod will fail to start. This is fixed in OpenShift Container Platform 4.2.1. For more information, see BZ#1754686.
The following JSON configuration object describes the parameters that you can set.
7.6.1.2.1. Static IP address assignment configuration Copia collegamentoCollegamento copiato negli appunti!
The following JSON describes the configuration for static IP address assignment:
Static assignment configuration
- 1
- An array describing IP addresses to assign to the virtual interface. Both IPv4 and IPv6 IP addresses are supported.
- 2
- An IP address that you specify.
- 3
- The default gateway to route egress network traffic to.
- 4
- An array describing routes to configure inside the Pod.
- 5
- The IP address range in CIDR format.
- 6
- The gateway where network traffic is routed.
- 7
- Optional: DNS configuration.
- 8
- An of array 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.
7.6.1.2.2. Dynamic IP address assignment configuration Copia collegamentoCollegamento copiato negli appunti!
The following JSON describes the configuration for dynamic IP address assignment with DHCP:
DHCP assignment configuration
{ "ipam": { "type": "dhcp" } }
{
"ipam": {
"type": "dhcp"
}
}
7.6.1.2.3. Static IP address assignment configuration example Copia collegamentoCollegamento copiato negli appunti!
You can configure ipam for static IP address assignment:
7.6.1.2.4. Dynamic IP address assignment configuration example using DHCP Copia collegamentoCollegamento copiato negli appunti!
You can configure ipam for DHCP:
{ "ipam": { "type": "dhcp" } }
{
"ipam": {
"type": "dhcp"
}
}
Next steps
7.7. Configuring a host-device network Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator, you can configure an additional network for your cluster by using the host-device Container Network Interface (CNI) plug-in. The plug-in allows you to move the specified network device from the host’s network namespace into the Pod’s network namespace.
7.7.1. Creating an additional network attachment with the host-device CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
The Cluster Network Operator (CNO) manages additional network definitions. When you specify an additional network to create, the CNO creates the NetworkAttachmentDefinition Custom Resource (CR) automatically.
Do not edit the NetworkAttachmentDefinition CRs that the Cluster Network Operator manages. Doing so might disrupt network traffic on your additional network.
Prerequisites
-
Install the OpenShift Command-line Interface (CLI), commonly known as
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 host-device 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.
Optional: Confirm that the CNO created the NetworkAttachmentDefinition CR by running the following command. There might be a delay before the CNO creates the CR.
oc get network-attachment-definitions -n <namespace>
$ oc get network-attachment-definitions -n <namespace> NAME AGE test-network-1 14m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.7.1.1. Configuration for host-device Copia collegamentoCollegamento copiato negli appunti!
The configuration for an additional network attachment that uses the host-device Container Network Interface (CNI) plug-in is provided in two parts:
- Cluster Network Operator (CNO) configuration
- CNI plug-in configuration
The CNO configuration specifies the name for the additional network attachment and the namespace to create the attachment in. The plug-in is configured by a JSON object specified by the rawCNIConfig
parameter in the CNO configuration.
The following YAML describes the configuration parameters for the CNO:
Cluster Network Operator 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 you do not specify a value, then the
default
namespace is used. - 3
- Specify the CNI plug-in configuration in JSON format, which is based on the following template.
Specify your network device by setting only one of the following parameters: device
, hwaddr
, kernelpath
, or pciBusID
.
The following object describes the configuration parameters for the host-device CNI plug-in:
host-device CNI plug-in JSON configuration object
- 1
- Specify the value for the
name
parameter you provided previously for the CNO configuration. - 2
- Specify the name of the device, such as
eth0
. - 3
- Specify the device hardware MAC address.
- 4
- Specify the Linux kernel device path, such as
/sys/devices/pci0000:00/0000:00:1f.6
. - 5
- Specify the PCI address of the network device, such as
0000:00:1f.6
. - 6
- Specify a configuration object for the ipam CNI plug-in. The plug-in manages IP address assignment for the attachment definition.
7.7.1.1.1. host-device configuration example Copia collegamentoCollegamento copiato negli appunti!
The following example configures an additional network named hostdev-net
:
- 1
- The CNI configuration object is specified as a YAML string.
7.7.1.2. Configuration for ipam CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
The ipam Container Network Interface (CNI) plug-in provides IP address management (IPAM) for other CNI plug-ins. You can configure ipam for either static IP address assignment or dynamic IP address assignment by using DHCP. The DHCP server you specify must be reachable from the additional network.
In OpenShift Container Platform 4.2.0, if you attach a Pod to an additional network that uses DHCP for IP address management, the Pod will fail to start. This is fixed in OpenShift Container Platform 4.2.1. For more information, see BZ#1754686.
The following JSON configuration object describes the parameters that you can set.
7.7.1.2.1. Static IP address assignment configuration Copia collegamentoCollegamento copiato negli appunti!
The following JSON describes the configuration for static IP address assignment:
Static assignment configuration
- 1
- An array describing IP addresses to assign to the virtual interface. Both IPv4 and IPv6 IP addresses are supported.
- 2
- An IP address that you specify.
- 3
- The default gateway to route egress network traffic to.
- 4
- An array describing routes to configure inside the Pod.
- 5
- The IP address range in CIDR format.
- 6
- The gateway where network traffic is routed.
- 7
- Optional: DNS configuration.
- 8
- An of array 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.
7.7.1.2.2. Dynamic IP address assignment configuration Copia collegamentoCollegamento copiato negli appunti!
The following JSON describes the configuration for dynamic IP address assignment with DHCP:
DHCP assignment configuration
{ "ipam": { "type": "dhcp" } }
{
"ipam": {
"type": "dhcp"
}
}
7.7.1.2.3. Static IP address assignment configuration example Copia collegamentoCollegamento copiato negli appunti!
You can configure ipam for static IP address assignment:
7.7.1.2.4. Dynamic IP address assignment configuration example using DHCP Copia collegamentoCollegamento copiato negli appunti!
You can configure ipam for DHCP:
{ "ipam": { "type": "dhcp" } }
{
"ipam": {
"type": "dhcp"
}
}
Next steps
7.8. Configuring an additional network for SR-IOV Copia collegamentoCollegamento copiato negli appunti!
Network Interface Card (NIC) SR-IOV hardware is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview/.
7.8.1. About SR-IOV hardware on OpenShift Container Platform Copia collegamentoCollegamento copiato negli appunti!
OpenShift Container Platform includes the capability to use SR-IOV hardware on your nodes. You can attach SR-IOV virtual function (VF) interfaces to Pods on nodes with SR-IOV hardware.
You can use the OpenShift Container Platform console to install SR-IOV by deploying the SR-IOV Network Operator. The SR-IOV Network Operator creates and manages the components of the SR-IOV stack. The Operator provides following features:
- Discover the SR-IOV network device in cluster.
- Initialize the supported SR-IOV NIC models on nodes.
- Provision the SR-IOV network device plug-in on nodes.
- Provision the SR-IOV CNI plug-in executable on nodes.
- Provision the Network Resources Injector in cluster.
- Manage configuration of SR-IOV network device plug-in.
- Generate NetworkAttachmentDefinition custom resources (CR) for the SR-IOV CNI plug-in.
Here’s the function of each above mentioned SR-IOV components.
- The SR-IOV network device plug-in is a Kubernetes device plug-in for discovering, advertising, and allocating SR-IOV network virtual function (VF) resources. Device plug-ins are used in Kubernetes to enable the use of limited resources, typically in physical devices. Device plug-ins give the Kubernetes scheduler awareness of resource availability, so the scheduler can schedule Pods on nodes with sufficient resources.
- The SR-IOV CNI plug-in plumbs VF interfaces allocated from the SR-IOV device plug-in directly into a Pod.
- The Network Resources Injector is a Kubernetes Dynamic Admission Controller Webhook that provides functionality for patching Kubernetes Pod specifications with requests and limits for custom network resources such as SR-IOV VFs.
The Network Resources Injector is enabled by default and cannot be disabled.
7.8.1.1. Supported devices Copia collegamentoCollegamento copiato negli appunti!
The following Network Interface Card (NIC) models are supported in OpenShift Container Platform:
-
Intel XXV710-DA2 25G card with vendor ID
0x8086
and device ID0x158b
-
Mellanox MT27710 Family [ConnectX-4 Lx] 25G card with vendor ID
0x15b3
and device ID0x1015
-
Mellanox MT27800 Family [ConnectX-5] 100G card with vendor ID
0x15b3
and device ID0x1017
7.8.1.2. Automated discovery of SR-IOV network devices Copia collegamentoCollegamento copiato negli appunti!
The SR-IOV Network Operator will search your cluster for SR-IOV capable network devices on worker nodes. The Operator creates and updates a SriovNetworkNodeState Custom Resource (CR) for each worker node that provides a compatible SR-IOV network device.
One CR is created for each worker node, and shares the same name as the node. The .spec.interfaces
list provides information about the network devices on a node.
Do not modify a SriovNetworkNodeState CR. The Operator creates and manages these resources automatically.
The following is an example of a SriovNetworkNodeState CR created by the SR-IOV Network Operator:
7.8.1.3. Example use of virtual function (VF) in a Pod Copia collegamentoCollegamento copiato negli appunti!
You can run a remote direct memory access (RDMA) or a Data Plane Development Kit (DPDK) application in a Pod with SR-IOV VF attached. In the following example, a Pod is using a VF in RDMA mode:
The following example shows a Pod with VF in DPDK mode:
7.8.2. Installing SR-IOV Network Operator Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator, you can install the SR-IOV Network Operator using the OpenShift Container Platform CLI or the web console.
7.8.2.1. Installing the Operator using the CLI Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator, you can install the Operator using the CLI.
Prerequisites
- A cluster installed on bare-metal hardware with nodes that have hardware that supports SR-IOV.
-
The OpenShift Container Platform Command-line Interface (CLI), commonly known as
oc
. -
Log in as a user with
cluster-admin
privileges.
Procedure
Create a namespace for the SR-IOV Network Operator by completing the following actions:
Create the following Namespace Custom Resource (CR) that defines the
sriov-network-operator
namespace, and then save the YAML in thesriov-namespace.yaml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the namespace by running the following command:
oc create -f sriov-namespace.yaml
$ oc create -f sriov-namespace.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Install the SR-IOV Network Operator in the namespace you created in the previous step by creating the following objects:
Create the following OperatorGroup CR and save the YAML in the
sriov-operatorgroup.yaml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the OperatorGroup CR by running the following command:
oc create -f sriov-operatorgroup.yaml
$ oc create -f sriov-operatorgroup.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to get the
channel
value required for the next step.oc get packagemanifest sriov-network-operator -n openshift-marketplace -o jsonpath='{.status.defaultChannel}'
$ oc get packagemanifest sriov-network-operator -n openshift-marketplace -o jsonpath='{.status.defaultChannel}' 4.2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the following Subscription CR and save the YAML in the
sriov-sub.yaml
file:Example Subscription
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the Subscription object by running the following command:
oc create -f sriov-sub.yaml
$ oc create -f sriov-sub.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change to the
sriov-network-operator
project:oc project sriov-network-operator
$ oc project sriov-network-operator Now using project "sriov-network-operator"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.8.2.2. Installing the Operator using the web console Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator, you can install the Operator using the web console.
You have to create the Namespace CR and OperatorGroup CR as mentioned in the previous section.
Procedure
Install the SR-IOV Network Operator using the OpenShift Container Platform web console:
-
In the OpenShift Container Platform web console, click Operators
OperatorHub. - Choose SR-IOV Network Operator from the list of available Operators, and then click Install.
- On the Create Operator Subscription page, under A specific namespace on the cluster select sriov-network-operator. Then, click Subscribe.
-
In the OpenShift Container Platform web console, click Operators
Optional: Verify that the SR-IOV Network Operator installed successfully:
-
Switch to the Operators
Installed Operators page. Ensure that SR-IOV Network Operator is listed in the sriov-network-operator project with a Status of InstallSucceeded.
NoteDuring installation an Operator might display a Failed status. If the installation later succeeds with an InstallSucceeded message, you can ignore the Failed message.
If the operator does not appear as installed, to troubleshoot further:
-
Go to the Operators
Installed Operators page and inspect the Operator Subscriptions and Install Plans tabs for any failure or errors under Status. -
Go to the Workloads
Pods page and check the logs for Pods in the sriov-network-operator
project.
-
Go to the Operators
-
Switch to the Operators
7.8.3. Configuring SR-IOV network devices Copia collegamentoCollegamento copiato negli appunti!
The SR-IOV Network Operator adds the SriovNetworkNodePolicy.sriovnetwork.openshift.io
Custom Resource Definition (CRD) to OpenShift Container Platform. You can configure the SR-IOV network device by creating a SriovNetworkNodePolicy Custom Resource (CR).
When applying the configuration specified in a SriovNetworkNodePolicy CR, the SR-IOV Operator may drain the nodes, and in some cases, reboot nodes. It may take several minutes for a configuration change to apply. Ensure that there are enough available nodes in your cluster to handle the evicted workload beforehand.
After the configuration update is applied, all the Pods in sriov-network-operator
namespace will change to a Running
status.
Prerequisites
-
Install the OpenShift Command-line Interface (CLI), commonly known as
oc
. -
Log in as a user with
cluster-admin
privileges. - You must have installed the SR-IOV Operator.
Procedure
Create the following SriovNetworkNodePolicy CR, and then save the YAML in the
<name>-sriov-node-network.yaml
file. Replace<name>
with the name for this configuration.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify a name for the CR.
- 2
- Specify the namespace where the SR-IOV Operator is installed.
- 3
- Specify the resource name of the SR-IOV device plug-in. The prefix
openshift.io/
will be added when it’s referred in Pod spec. You can create multiple SriovNetworkNodePolicy CRs for a resource name. - 4
- Specify the node selector to select which node to be configured. User can choose to label the nodes manually or with tools like Kubernetes Node Feature Discovery. Only SR-IOV network devices on selected nodes will be configured. The SR-IOV CNI plug-in and device plug-in will be only deployed on selected nodes.
- 5
- Specify an integer value between
0
and99
. A larger number gets lower priority, so a priority of99
is lower than a priority of10
. - 6
- Specify a value for the maximum transmission unit (MTU) of the virtual function. The value for MTU must be in the range from
1
to9000
. If you do not need to specify the MTU, specify a value of''
. - 7
- Specify the number of the virtual functions (VF) to create for the SR-IOV physical network device. For an Intel Network Interface Card (NIC), the number of VFs cannot be larger than the total VFs supported by the device. For a Mellanox NIC, the number of VFs cannot be larger than
128
. - 8
- The
nicSelector
mapping selects the Ethernet device for the Operator to configure. You do not need to specify values for all the parameters. It is recommended to identify the Ethernet adapter with enough precision to minimize the possibility of selecting an Ethernet device unintentionally. If you specifyrootDevices
, you must also specify a value forvendor
,deviceID
, orpfNames
. If you specify bothpfNames
androotDevices
at the same time, ensure that they point to an identical device. - 9
- Specify the vendor hex code of the SR-IOV network device. The only allowed values are either
8086
or15b3
. - 10
- Specify the device hex code of SR-IOV network device. The only allowed values are
158b
,1015
,1017
. - 11
- The parameter accepts an array of one or more physical function (PF) names for the Ethernet device.
- 12
- The parameter accepts an array of one or more PCI bus addresses for the physical function of the Ethernet device. Provide the address in the following format:
0000:02:00.1
. - 13
- Specify the driver type for the virtual functions. You can specify one of the following values:
netdevice
orvfio-pci
. The default value isnetdevice
. - 14
- Specify whether to enable RDMA mode. The default value is
false
. Only RDMA over Converged Ethernet (RoCE) mode is supported on Mellanox Ethernet adapters.
NoteIf
RDMA
flag is set totrue
, you can continue to use the RDMA enabled VF as a normal network device. A device can be used in either mode.Create the CR by running the following command:
oc create -f <filename>
$ oc create -f <filename>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<filename>
with the name of the file you created in the previous step.
7.8.4. Configuring SR-IOV additional network Copia collegamentoCollegamento copiato negli appunti!
You can configure an additional network that uses SR-IOV hardware by creating a SriovNetwork Custom Resource (CR). When you create a SriovNetwork CR, the SR-IOV Operator automatically creates a NetworkAttachmentDefinition CR.
Do not modify or delete a SriovNetwork Custom Resource (CR) if it is attached to any Pods in the running
state.
Prerequisites
-
Install the OpenShift Command-line Interface (CLI), commonly known as
oc
. -
Log in as a user with
cluster-admin
privileges.
Procedure
Create the following SriovNetwork CR, and then save the YAML in the
<name>-sriov-network.yaml
file. Replace<name>
with a name for this additional network.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<name>
with a name for the CR. The Operator will create a NetworkAttachmentDefinition CR with same name. - 2
- Specify the namespace where the SR-IOV Operator is installed.
- 3
- Replace
<target_namespace>
with the namespace where the NetworkAttachmentDefinition CR will be created. - 4
- Specify a configuration object for the ipam CNI plug-in as a YAML block scalar. The plug-in manages IP address assignment for the attachment definition.
- 5
- Replace
<vlan>
with a Virtual LAN (VLAN) ID for the additional network. The integer value must be from0
to4095
. The default value is0
. - 6
- Replace
<sriov_resource_name>
with the value for the.spec.resourceName
parameter from the SriovNetworkNodePolicy CR that defines the SR-IOV hardware for this additional network.
Create the CR by running the following command:
oc create -f <filename>
$ oc create -f <filename>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<filename>
with the name of the file you created in the previous step.
Optional: Confirm that the NetworkAttachmentDefinition CR associated with the SriovNetwork CR that you created in the previous step exists by running the following command. Replace
<namespace>
with the namespace you specified in the SriovNetwork CR.oc get net-attach-def -n <namespace>
oc get net-attach-def -n <namespace>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.8.4.1. Configuration for ipam CNI plug-in Copia collegamentoCollegamento copiato negli appunti!
The ipam Container Network Interface (CNI) plug-in provides IP address management (IPAM) for other CNI plug-ins. You can configure ipam for either static IP address assignment or dynamic IP address assignment by using DHCP. The DHCP server you specify must be reachable from the additional network.
In OpenShift Container Platform 4.2.0, if you attach a Pod to an additional network that uses DHCP for IP address management, the Pod will fail to start. This is fixed in OpenShift Container Platform 4.2.1. For more information, see BZ#1754686.
The following JSON configuration object describes the parameters that you can set.
7.8.4.1.1. Static IP address assignment configuration Copia collegamentoCollegamento copiato negli appunti!
The following JSON describes the configuration for static IP address assignment:
Static assignment configuration
- 1
- An array describing IP addresses to assign to the virtual interface. Both IPv4 and IPv6 IP addresses are supported.
- 2
- An IP address that you specify.
- 3
- The default gateway to route egress network traffic to.
- 4
- An array describing routes to configure inside the Pod.
- 5
- The IP address range in CIDR format.
- 6
- The gateway where network traffic is routed.
- 7
- Optional: DNS configuration.
- 8
- An of array 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.
7.8.4.1.2. Dynamic IP address assignment configuration Copia collegamentoCollegamento copiato negli appunti!
The following JSON describes the configuration for dynamic IP address assignment with DHCP:
DHCP assignment configuration
{ "ipam": { "type": "dhcp" } }
{
"ipam": {
"type": "dhcp"
}
}
7.8.4.1.3. Static IP address assignment configuration example Copia collegamentoCollegamento copiato negli appunti!
You can configure ipam for static IP address assignment:
7.8.4.1.4. Dynamic IP address assignment configuration example using DHCP Copia collegamentoCollegamento copiato negli appunti!
You can configure ipam for DHCP:
{ "ipam": { "type": "dhcp" } }
{
"ipam": {
"type": "dhcp"
}
}
7.8.5. Adding a Pod to an additional network Copia collegamentoCollegamento copiato negli appunti!
You can add a Pod to an additional network. The Pod continues to send normal cluster related network traffic over the default network.
The Network Resources Injector will inject the resource
parameter into the Pod CR automatically if a NetworkAttachmentDefinition CR associated with the SR-IOV CNI plug-in is specified.
Prerequisites
- The Pod must be in the same namespace as the additional network.
-
Install the OpenShift Command-line Interface (CLI), commonly known as
oc
. - You must log in to the cluster.
- You must have the SR-IOV Operator installed and a SriovNetwork CR defined.
Procedure
To add a Pod with additional networks, complete the following steps:
Create the Pod resource definition and add the
k8s.v1.cni.cncf.io/networks
parameter to the Podmetadata
mapping. Thek8s.v1.cni.cncf.io/networks
accepts a comma separated string of one or more NetworkAttachmentDefinition Custom Resource (CR) names:metadata: annotations: k8s.v1.cni.cncf.io/networks: <network>[,<network>,...]
metadata: annotations: k8s.v1.cni.cncf.io/networks: <network>[,<network>,...]
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<network>
with the name of the additional network to associate with the Pod. To specify more than one additional network, separate each network with a comma. Do not include whitespace between the comma. If you specify the same additional network multiple times, that Pod will have multiple network interfaces attached to that network.
In the following example, two additional networks are attached to the Pod:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the Pod by running the following command:
oc create -f pod.yaml
$ oc create -f pod.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Confirm that the annotation exists in the Pod CR by running the following command. Replace
<name>
with the name of the Pod.oc get pod <name> -o yaml
$ oc get pod <name> -o yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the following example, the
example-pod
Pod is attached to thenet1
additional network:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
k8s.v1.cni.cncf.io/networks-status
parameter is a JSON array of objects. Each object describes the status of an additional network attached to the Pod. The annotation value is stored as a plain text value.
7.9. Editing an additional network Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator you can modify the configuration for an existing additional network.
7.9.1. Modifying an additional network attachment definition Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator, you can make changes to an existing additional network. Any existing Pods attached to the additional network will not be updated.
Prerequisites
- You have configured an additional network for your cluster.
-
Install the OpenShift Command-line Interface (CLI), commonly known as
oc
. -
Log in as a user with
cluster-admin
privileges.
Procedure
To edit an additional network for your cluster, complete the following steps:
Run the following command to edit the Cluster Network Operator (CNO) CR in your default text editor:
oc edit networks.operator.openshift.io cluster
$ oc edit networks.operator.openshift.io cluster
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
In the
additionalNetworks
collection, update the additional network with your changes. - Save your changes and quit the text editor to commit your changes.
Optional: Confirm that the CNO updated the NetworkAttachmentDefinition CR by running the following command. Replace
<network-name>
with the name of the additional network to display. There might be a delay before the CNO updates the NetworkAttachmentDefinition CR to reflect your changes.oc get network-attachment-definitions <network-name> -o yaml
$ oc get network-attachment-definitions <network-name> -o yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, the following console output displays a NetworkAttachmentDefinition that is named
net1
:oc get network-attachment-definitions net1 -o go-template='{{printf "%s\n" .spec.config}}'
$ oc get network-attachment-definitions net1 -o go-template='{{printf "%s\n" .spec.config}}' { "cniVersion": "0.3.1", "type": "macvlan", "master": "ens5", "mode": "bridge", "ipam": {"type":"static","routes":[{"dst":"0.0.0.0/0","gw":"10.128.2.1"}],"addresses":[{"address":"10.128.2.100/23","gateway":"10.128.2.1"}],"dns":{"nameservers":["172.30.0.10"],"domain":"us-west-2.compute.internal","search":["us-west-2.compute.internal"]}} }
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.10. Removing an additional network Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator you can remove an additional network attachment.
7.10.1. Removing an additional network attachment definition Copia collegamentoCollegamento copiato negli appunti!
As a cluster administrator, you can remove an additional network from your OpenShift Container Platform cluster. The additional network is not removed from any Pods it is attached to.
In OpenShift Container Platform 4.2.0 you must manually delete the additional network CR after removing it from the Cluster Network Operator configuration. This will be fixed in a future release. For more information, see BZ#1755908.
Prerequisites
-
Install the OpenShift Command-line Interface (CLI), commonly known as
oc
. -
Log in as a user with
cluster-admin
privileges.
Procedure
To remove an additional network from your cluster, complete the following steps:
Edit the Cluster Network Operator (CNO) in your default text editor 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 by removing the configuration from the
additionalNetworks
collection for the network attachment definition you are removing.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- If you are removing the configuration mapping for the only additional network attachment definition in the
additionalNetworks
collection, you must specify an empty collection.
- Save your changes and quit the text editor to commit your changes.
Delete the NetworkAttachmentDefinition CR for the additional network by running the following command. Replace
<name>
with the name of the additional network to remove.oc delete network-attachment-definition <name>
$ oc delete network-attachment-definition <name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Confirm that the additional network CR was deleted by running the following command:
oc get network-attachment-definition --all-namespaces
$ oc get network-attachment-definition --all-namespaces
Copy to Clipboard Copied! Toggle word wrap Toggle overflow