$ openstack subnet set --dns-nameserver 0.0.0.0 <subnet_id>
The following sections explain how to create and manage primary networks using the NetworkAttachmentDefinition
(NAD) resource.
You can manage the life cycle of a primary network created by NAD with one of the following two approaches:
By modifying the Cluster Network Operator (CNO) configuration. With this method, the CNO automatically creates and manages the NetworkAttachmentDefinition
object. In addition to managing the object lifecycle, the CNO ensures that a DHCP is available for a primary network that uses a DHCP assigned IP address.
By applying a YAML manifest. With this method, you can manage the primary network directly by creating an NetworkAttachmentDefinition
object. This approach allows for the invocation of multiple CNI plugins in order to attach primary network interfaces in a pod.
Each approach is mutually exclusive and you can only use one approach for managing a primary network at a time. For either approach, the primary network is managed by a Container Network Interface (CNI) plugin that you configure.
When deploying OKD nodes with multiple network interfaces on OpenStack with OVN SDN, DNS configuration of the secondary interface might take precedence over the DNS configuration of the primary interface. In this case, remove the DNS nameservers for the subnet ID that is attached to the secondary interface by running the following command:
|
The Cluster Network Operator (CNO) manages additional network definitions. When you specify a primary network to create, the CNO creates the NetworkAttachmentDefinition
CRD automatically.
Do not edit the |
Install the OpenShift CLI (oc
).
Log in as a user with cluster-admin
privileges.
Optional: Create the namespace for the primary networks:
$ oc create namespace <namespace_name>
To edit the CNO configuration, enter the following command:
$ oc edit networks.operator.openshift.io cluster
Modify the CR that you are creating by adding the configuration for the primary network that you are creating, as in the following example CR.
apiVersion: operator.openshift.io/v1
kind: Network
metadata:
name: cluster
spec:
# ...
additionalNetworks:
- name: tertiary-net
namespace: namespace2
type: Raw
rawCNIConfig: |-
{
"cniVersion": "0.3.1",
"name": "tertiary-net",
"type": "ipvlan",
"master": "eth1",
"mode": "l2",
"ipam": {
"type": "static",
"addresses": [
{
"address": "192.168.1.23/24"
}
]
}
}
Save your changes and quit the text editor to commit your changes.
Confirm that the CNO created the NetworkAttachmentDefinition
CRD by running the following command. There might be a delay before the CNO creates the CRD.
$ oc get network-attachment-definitions -n <namespace>
where:
<namespace>
Specifies the namespace for the network attachment that you added to the CNO configuration.
NAME AGE
test-network-1 14m
A primary network is configured by using the NetworkAttachmentDefinition
API in the k8s.cni.cncf.io
API group.
The configuration for the API is described in the following table:
Field | Type | Description |
---|---|---|
|
|
The name for the primary network. |
|
|
The namespace that the object is associated with. |
|
|
The CNI plugin configuration in JSON format. |
You have installed the OpenShift CLI (oc
).
You have logged in as a user with cluster-admin
privileges.
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", (1)
"type": "host-device",
"device": "eth1",
"ipam": {
"type": "dhcp"
}
}
1 | 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, this spec is not necessary. |
To create the primary network, enter the following command:
$ oc apply -f <file>.yaml
where:
<file>
Specifies the name of the file contained the YAML manifest.