You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
= Creating additional network interfaces for the first time
6
+
= Creating additional network interfaces
7
7
8
-
Additional interfaces for pods are defined in CNI configurations that are stored as Custom Resources (CRs).
8
+
Additional interfaces for Pods are defined in CNI configurations that are stored as Custom Resources (CRs).
9
9
These CRs can be created, listed, edited, and deleted using the `oc` tool.
10
10
11
-
The procedure below configures a `macvlan` interface on a pod. This configuration might not apply to all production environments, but you use the same procedure for other CNI plug-ins.
11
+
The procedure below configures a `macvlan` interface on a Pod. This configuration might not apply to all production environments, but you use the same procedure for other CNI plug-ins.
12
12
13
13
== Creating a CNI configuration for an additional interface as a CR
14
14
15
15
[NOTE]
16
16
====
17
-
If you want to attach an additional interface to a pod, the CR that defines the interface must be in the same project (namespace) as the pod.
17
+
If you want to attach an additional interface to a Pod, the CR that defines the interface must be in the same project (namespace) as the Pod.
18
18
====
19
19
20
-
. Create a project to store CNI configurations as CRs and the pods that will use the CRs.
20
+
. Create a project to store CNI configurations as CRs and the Pods that will use the CRs.
21
21
+
22
22
----
23
23
$ oc new-project multinetwork-example
24
-
$ oc project multinetwork-example
25
24
----
26
25
27
-
. Create the CR that will define an additional network interface. Create a YAML file:
26
+
. Create the CR that will define an additional network interface. Create a YAML file called `macvlan-conf.yaml` with the following contents:
28
27
+
29
28
[source,yaml]
30
29
----
31
30
apiVersion: "k8s.cni.cncf.io/v1"
32
-
kind: NetworkAttachmentDefinition <2>
31
+
kind: NetworkAttachmentDefinition <1>
33
32
metadata:
34
-
name: macvlan-conf <1>
33
+
name: macvlan-conf <2>
35
34
spec:
36
35
config: '{ <3>
37
36
"cniVersion": "0.3.0",
@@ -51,29 +50,29 @@ spec:
51
50
}'
52
51
----
53
52
+
54
-
<1> `name` maps to the annotation, which is used in the next step.
55
-
<2> `kind: NetworkAttachmentDefinition`. This is the name for the CR where this configuration will be stored. It is a custom extension of Kubernetes that defines how networks are attached to pods.
53
+
<1> `kind: NetworkAttachmentDefinition`. This is the name for the CR where this configuration will be stored. It is a custom extension of Kubernetes that defines how networks are attached to Pods.
54
+
<2> `name` maps to the annotation, which is used in the next step.
56
55
<3> `config`: The CNI configuration is packaged in the `config` field.
57
-
56
+
+
58
57
The configuration above is specific to a plug-in, which enables `macvlan`. Note the `type` line in the CNI configuration portion.
59
-
Aside from the IPAM (IP address management) parameters for networking, in this example the `master` field must reference a network interface that resides on the node(s) hosting the pod(s).
58
+
Aside from the IPAM (IP address management) parameters for networking, in this example the `master` field must reference a network interface that resides on the node(s) hosting the Pod(s).
60
59
61
60
. Run the following command to create the CR:
62
61
+
63
62
----
64
-
oc create -f macvlan-conf.yaml
63
+
$ oc create -f macvlan-conf.yaml
65
64
----
66
65
67
66
[NOTE]
68
67
====
69
68
This example is based on a `macvlan` CNI plug-in. Note that in AWS environments, macvlan traffic might be filtered and, therefore, might not reach the desired destination.
70
69
====
71
70
72
-
== Managing the CRs for Additional Interfaces
71
+
== Managing the CRs for additional interfaces
73
72
74
-
You can manage the CRs for additional interfaces using the `oc` tool.
73
+
You can manage the CRs for additional interfaces using the `oc` CLI.
75
74
76
-
To list the CRs for additional interfaces, execute:
75
+
Use the following command to list the CRs for additional interfaces:
77
76
78
77
----
79
78
$ oc get network-attachment-definitions.k8s.cni.cncf.io
@@ -85,9 +84,9 @@ Use the following command to delete CRs for additional interfaces:
To create a pod which uses the additional interface, use an `annotation` that refers to the CR, create a YAML file for a pod:
89
+
To create a Pod that uses the additional interface, use an annotation that refers to the CR. Create a YAML file called `samplepod.yaml` for a Pod with the following contents:
91
90
92
91
[source,yaml]
93
92
----
@@ -106,13 +105,13 @@ spec:
106
105
107
106
<1> The `annotations` field contains `k8s.v1.cni.cncf.io/networks: macvlan-conf`, which correlates to the `name` field in the CR defined earlier.
108
107
109
-
Run the following command to create the `samplepod` pod:
108
+
Run the following command to create the `samplepod` Pod:
110
109
111
110
----
112
-
oc create -f samplepod.yaml
111
+
$ oc create -f samplepod.yaml
113
112
----
114
113
115
-
To verify that an additional network interface has been created and attached to the pod, use the following command to list the IPv4 address information:
114
+
To verify that an additional network interface has been created and attached to the Pod, use the following command to list the IPv4 address information:
<2> `eth0`: the interface that connects to the cluster-wide default network.
138
-
<3> `net1`: the new interface that you just created.
134
+
<1> `lo`: A loopback interface.
135
+
<2> `eth0`: The interface that connects to the cluster-wide default network.
136
+
<3> `net1`: The new interface that you just created.
139
137
140
-
=== Attaching multiple interfaces to a pod
138
+
=== Attaching multiple interfaces to a Pod
141
139
142
-
To attach more than one additional interface to a pod, specify multiple names, in comma-delimited format, in the `annotation` field in the pod definition.
140
+
To attach more than one additional interface to a Pod, specify multiple names, in comma-delimited format, in the `annotations` field in the Pod definition.
143
141
144
-
The following `annotation` field in a pod definition specifies different CRs for the additional interfaces:
142
+
The following `annotations` field in a Pod definition specifies different CRs for the additional interfaces:
== View the interface configuration in a running pod
158
+
== Viewing the interface configuration in a running Pod
161
159
162
-
Once the pod is running, you can can review the configurations of the additional interfaces created.
163
-
To view the sample pod from the earlier example, execute the following command.
160
+
After the Pod is running, you can review the configurations of the additional interfaces created.
161
+
To view the sample Pod from the earlier example, execute the following command.
164
162
165
163
----
166
164
$ oc describe pod samplepod
@@ -192,16 +190,16 @@ Annotations:
192
190
----
193
191
194
192
<1> `name` refers to the custom resource name, `macvlan-conf`.
195
-
<2> `interface` refers to the name of the interface in the pod.
196
-
<3> `ips` is a list of IP addresses as assigned to the pod.
193
+
<2> `interface` refers to the name of the interface in the Pod.
194
+
<3> `ips` is a list of IP addresses as assigned to the Pod.
197
195
<4> `mac` is the MAC address of the interface.
198
196
<5> `dns` refers DNS for the interface.
199
197
200
-
The first annotation, `k8s.v1.cni.cncf.io/networks: macvlan-conf`, refers to the CR created in the example. This annotation was specified in the pod definition.
198
+
The first annotation, `k8s.v1.cni.cncf.io/networks: macvlan-conf`, refers to the CR created in the example. This annotation was specified in the Pod definition.
201
199
202
200
The second annotation is `k8s.v1.cni.cncf.io/networks-status`.
203
201
There are two interfaces listed under `k8s.v1.cni.cncf.io/networks-status`.
204
202
205
203
* The first interface describes the interface for the default network, `openshift-sdn`. This interface is created as `eth0`. It is used for communications within the cluster.
206
204
207
-
* The second interface is the additional interface that you created, `net1`. The output above lists some key values that were configured when the interface was created, for example, the IP addresses that were assigned to the pod.
205
+
* The second interface is the additional interface that you created, `net1`. The output above lists some key values that were configured when the interface was created, for example, the IP addresses that were assigned to the Pod.
. Create a YAML file for a custom resource to refer to this configuration:
27
+
. Create a YAML file called `hostdevice-example.yaml` for a custom resource to refer to this configuration:
30
28
+
31
29
[source,yaml]
32
30
----
@@ -45,11 +43,10 @@ spec:
45
43
. Run the following command to create the `hostdevice-example` CR:
46
44
+
47
45
----
48
-
oc create -f hostdevice-example.yaml
46
+
$ oc create -f hostdevice-example.yaml
49
47
----
50
48
51
-
52
-
. Create a YAML file for a pod which refers to this name in the annotation. Include `nodeSelector` to assign the pod to the machine where you created the alias.
49
+
. Create a YAML file for a Pod which refers to this name in the annotation. Include `nodeSelector` to assign the Pod to the machine where you created the alias.
53
50
+
54
51
[source,yaml]
55
52
----
@@ -68,10 +65,10 @@ spec:
68
65
exampledevice: "true"
69
66
----
70
67
71
-
. Run the following command to create the `hostdevicesamplepod` pod:
68
+
. Run the following command to create the `hostdevicesamplepod` Pod:
0 commit comments