Creating a primary network attachment by applying a YAML manifest
Create a primary network attachment by directly applying a NetworkAttachmentDefinition YAML manifest. This gives you full control over the network configuration without relying on the Cluster Network Operator to manage the resource automatically.
-
You have installed the OpenShift CLI (
oc). -
You have logged in as a user with
cluster-adminprivileges. -
You are working in the namespace where the NAD is to be deployed.
-
Create a YAML file with your primary network configuration, such as in the following example:
apiVersion: k8s.cni.cncf.io/v1 kind: NetworkAttachmentDefinition metadata: name: next-net spec: config: |- { "cniVersion": "0.3.1", "name": "work-network", "namespace": "namespace2", "type": "host-device", "device": "eth1", "ipam": { "type": "dhcp" } }-
Optional: You can specify a namespace to which the NAD is applied. If you are working in the namespace where the NAD is to be deployed, the
namespacespecification is not necessary.
-
-
To create the primary network, enter the following command:
$ oc apply -f <file>.yamlwhere:
<file>-
Specifies the name of the file contained the YAML manifest.