mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
246 lines
5.4 KiB
Plaintext
246 lines
5.4 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * networking/multiple_networks/configuring-macvlan.adoc
|
|
// * networking/multiple_networks/configuring-ipvlan.adoc
|
|
// * networking/multiple_networks/configuring-bridge.adoc
|
|
// * networking/multiple_networks/configuring-host-device.adoc
|
|
|
|
// Configuring Multus plug-ins using the Cluster Network Operator
|
|
// is nearly identical in each case.
|
|
|
|
ifeval::["{context}" == "configuring-macvlan-basic"]
|
|
:plugin: macvlan
|
|
:macvlan:
|
|
:yaml:
|
|
endif::[]
|
|
// This is necessary for Whereabouts CNI which is JSON-only
|
|
ifeval::["{context}" == "configuring-macvlan"]
|
|
:plugin: macvlan
|
|
:macvlan:
|
|
:json:
|
|
endif::[]
|
|
ifeval::["{context}" == "configuring-ipvlan"]
|
|
:plugin: ipvlan
|
|
:json:
|
|
endif::[]
|
|
ifeval::["{context}" == "configuring-bridge"]
|
|
:plugin: bridge
|
|
:json:
|
|
endif::[]
|
|
ifeval::["{context}" == "configuring-host-device"]
|
|
:plugin: host-device
|
|
:json:
|
|
endif::[]
|
|
|
|
[id="nw-multus-create-network_{context}"]
|
|
= Creating an additional network attachment with the {plugin} CNI plug-in
|
|
|
|
The Cluster Network Operator (CNO) manages additional network definitions. When
|
|
you specify an additional network to create, the CNO creates the
|
|
`NetworkAttachmentDefinition` object automatically.
|
|
|
|
[IMPORTANT]
|
|
====
|
|
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:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc edit networks.operator.openshift.io cluster
|
|
----
|
|
|
|
. Modify the CR that you are creating by adding the configuration for the
|
|
additional network you are creating, as in the following example CR.
|
|
+
|
|
ifdef::yaml[]
|
|
The following YAML configures the {plugin} CNI plug-in:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: operator.openshift.io/v1
|
|
kind: Network
|
|
metadata:
|
|
name: cluster
|
|
spec:
|
|
additionalNetworks: <1>
|
|
- name: test-network-1
|
|
namespace: test-1
|
|
type: SimpleMacvlan
|
|
simpleMacvlanConfig:
|
|
ipamConfig:
|
|
type: static
|
|
staticIPAMConfig:
|
|
addresses:
|
|
- address: 10.1.1.7/24
|
|
----
|
|
endif::yaml[]
|
|
ifdef::json[]
|
|
The following YAML configures the {plugin} CNI plug-in:
|
|
endif::json[]
|
|
+
|
|
ifeval::["{plugin}" == "bridge"]
|
|
[source,yaml,subs="attributes+"]
|
|
----
|
|
apiVersion: operator.openshift.io/v1
|
|
kind: Network
|
|
metadata:
|
|
name: cluster
|
|
spec:
|
|
additionalNetworks: <1>
|
|
- name: test-network-1
|
|
namespace: test-1
|
|
type: Raw
|
|
rawCNIConfig: '{
|
|
"cniVersion": "0.3.1",
|
|
"name": "test-network-1",
|
|
"type": "{plugin}",
|
|
"ipam": {
|
|
"type": "static",
|
|
"addresses": [
|
|
{
|
|
"address": "192.168.1.23/24"
|
|
}
|
|
]
|
|
}
|
|
}'
|
|
----
|
|
endif::[]
|
|
ifeval::["{plugin}" == "host-device"]
|
|
[source,yaml,subs="attributes+"]
|
|
----
|
|
apiVersion: operator.openshift.io/v1
|
|
kind: Network
|
|
metadata:
|
|
name: cluster
|
|
spec:
|
|
additionalNetworks: <1>
|
|
- name: test-network-1
|
|
namespace: test-1
|
|
type: Raw
|
|
rawCNIConfig: '{
|
|
"cniVersion": "0.3.1",
|
|
"name": "test-network-1",
|
|
"type": "{plugin}",
|
|
"device": "eth1",
|
|
"ipam": {
|
|
"type": "static",
|
|
"addresses": [
|
|
{
|
|
"address": "192.168.1.23/24"
|
|
}
|
|
]
|
|
}
|
|
}'
|
|
----
|
|
endif::[]
|
|
ifeval::["{plugin}" == "ipvlan"]
|
|
[source,yaml,subs="attributes+"]
|
|
----
|
|
apiVersion: operator.openshift.io/v1
|
|
kind: Network
|
|
metadata:
|
|
name: cluster
|
|
spec:
|
|
additionalNetworks: <1>
|
|
- name: test-network-1
|
|
namespace: test-1
|
|
type: Raw
|
|
rawCNIConfig: '{
|
|
"cniVersion": "0.3.1",
|
|
"name": "test-network-1",
|
|
"type": "{plugin}",
|
|
"master": "eth1",
|
|
"mode": "l2",
|
|
"ipam": {
|
|
"type": "static",
|
|
"addresses": [
|
|
{
|
|
"address": "192.168.1.23/24"
|
|
}
|
|
]
|
|
}
|
|
}'
|
|
----
|
|
endif::[]
|
|
ifdef::macvlan+json[]
|
|
[source,yaml,subs="attributes+"]
|
|
----
|
|
apiVersion: operator.openshift.io/v1
|
|
kind: Network
|
|
metadata:
|
|
name: cluster
|
|
spec:
|
|
additionalNetworks: <1>
|
|
- name: test-network-1
|
|
namespace: test-1
|
|
type: Raw
|
|
rawCNIConfig: '{
|
|
"cniVersion": "0.3.1",
|
|
"name": "test-network-1",
|
|
"type": "{plugin}",
|
|
"master": "eth1",
|
|
"ipam": {
|
|
"type": "static",
|
|
"addresses": [
|
|
{
|
|
"address": "192.168.1.23/24"
|
|
}
|
|
]
|
|
}
|
|
}'
|
|
----
|
|
endif::[]
|
|
<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.
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc get network-attachment-definitions -n <namespace>
|
|
----
|
|
+
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
NAME AGE
|
|
test-network-1 14m
|
|
----
|
|
|
|
ifeval::["{context}" == "configuring-macvlan-basic"]
|
|
:!macvlan:
|
|
:!plugin:
|
|
:!yaml:
|
|
endif::[]
|
|
ifeval::["{context}" == "configuring-macvlan"]
|
|
:!macvlan:
|
|
:!plugin:
|
|
:!json:
|
|
endif::[]
|
|
ifeval::["{context}" == "configuring-ipvlan"]
|
|
:!plugin:
|
|
:!json:
|
|
endif::[]
|
|
ifeval::["{context}" == "configuring-bridge"]
|
|
:!plugin:
|
|
:!json:
|
|
endif::[]
|
|
ifeval::["{context}" == "configuring-host-device"]
|
|
:!plugin:
|
|
:!json:
|
|
endif::[]
|