|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/setting-interface-level-network-sysctls.adoc |
| 4 | +:_mod-docs-content-type: PROCEDURE |
| 5 | +[id="nw-enabling-all-multi-cni_{context}"] |
| 6 | += Enabling all-multicast mode by using the tuning CNI |
| 7 | + |
| 8 | +You can enable all-multicast mode by using the tuning Container Network Interface (CNI) meta plugin. |
| 9 | + |
| 10 | +The following procedure describes how to configure the tuning CNI to enable the all-multicast mode. |
| 11 | + |
| 12 | +.Procedure |
| 13 | + |
| 14 | +. Create a network attachment definition, such as `tuning-example.yaml`, with the following content: |
| 15 | ++ |
| 16 | +[source,yaml] |
| 17 | +---- |
| 18 | +apiVersion: "k8s.cni.cncf.io/v1" |
| 19 | +kind: NetworkAttachmentDefinition |
| 20 | +metadata: |
| 21 | + name: <name> <1> |
| 22 | + namespace: default <2> |
| 23 | +spec: |
| 24 | + config: '{ |
| 25 | + "cniVersion": "0.4.0", <3> |
| 26 | + "name": "<name>", <4> |
| 27 | + "plugins": [{ |
| 28 | + "type": "<main_CNI_plugin>" <5> |
| 29 | + }, |
| 30 | + { |
| 31 | + "type": "tuning", <6> |
| 32 | + "allmulti": true <7> |
| 33 | + } |
| 34 | + } |
| 35 | + ] |
| 36 | +} |
| 37 | +---- |
| 38 | +<1> Specifies the name for the additional network attachment to create. The name must be unique within the specified namespace. |
| 39 | +<2> Specifies the namespace that the object is associated with. |
| 40 | +<3> Specifies the CNI specification version. |
| 41 | +<4> Specifies the name for the configuration. Match the configuration name to the name value of the network attachment definition. |
| 42 | +<5> Specifies the name of the main CNI plugin to configure. |
| 43 | +<6> Specifies the name of the CNI meta plugin. |
| 44 | +<7> Changes the all-multicast mode of interface. If enabled, all multicast packets on the network will be received by the interface. |
| 45 | ++ |
| 46 | +An example YAML file is shown here: |
| 47 | ++ |
| 48 | +[source,yaml] |
| 49 | +---- |
| 50 | +apiVersion: "k8s.cni.cncf.io/v1" |
| 51 | +kind: NetworkAttachmentDefinition |
| 52 | +metadata: |
| 53 | + name: setallmulti |
| 54 | + namespace: default |
| 55 | +spec: |
| 56 | + config: '{ |
| 57 | + "cniVersion": "0.4.0", |
| 58 | + "name": "setallmulti", |
| 59 | + "plugins": [ |
| 60 | + { |
| 61 | + "type": "bridge" |
| 62 | + }, |
| 63 | + { |
| 64 | + "type": "tuning", |
| 65 | + "allmulti": true |
| 66 | + } |
| 67 | + ] |
| 68 | + }' |
| 69 | +---- |
| 70 | + |
| 71 | +. Apply the settings specified in the YAML file by running the following command: |
| 72 | ++ |
| 73 | +[source,terminal] |
| 74 | +---- |
| 75 | +$ oc apply -f tuning-allmulti.yaml |
| 76 | +---- |
| 77 | ++ |
| 78 | +.Example output |
| 79 | +[source,terminal] |
| 80 | +---- |
| 81 | +networkattachmentdefinition.k8s.cni.cncf.io/setallmulti created |
| 82 | +---- |
| 83 | + |
| 84 | +. Create a pod with a network attachment definition similar to that specified in the following `examplepod.yaml` sample file: |
| 85 | ++ |
| 86 | +[source,yaml] |
| 87 | +---- |
| 88 | +apiVersion: v1 |
| 89 | +kind: Pod |
| 90 | +metadata: |
| 91 | + name: allmultipod |
| 92 | + namespace: default |
| 93 | + annotations: |
| 94 | + k8s.v1.cni.cncf.io/networks: setallmulti <1> |
| 95 | +spec: |
| 96 | + containers: |
| 97 | + - name: podexample |
| 98 | + image: centos |
| 99 | + command: ["/bin/bash", "-c", "sleep INF"] |
| 100 | + securityContext: |
| 101 | + runAsUser: 2000 <2> |
| 102 | + runAsGroup: 3000 <3> |
| 103 | + allowPrivilegeEscalation: false <4> |
| 104 | + capabilities: <5> |
| 105 | + drop: ["ALL"] |
| 106 | + securityContext: |
| 107 | + runAsNonRoot: true <6> |
| 108 | + seccompProfile: <7> |
| 109 | + type: RuntimeDefault |
| 110 | +---- |
| 111 | +<1> Specifies the name of the configured `NetworkAttachmentDefinition`. |
| 112 | +<2> Specifies the user ID the container is run with. |
| 113 | +<3> Specifies which primary group ID the containers is run with. |
| 114 | +<4> Specifies if a pod can request privilege escalation. If unspecified, it defaults to `true`. This boolean directly controls whether the `no_new_privs` flag gets set on the container process. |
| 115 | +<5> Specifies the container capabilities. The `drop: ["ALL"]` statement indicates that all Linux capabilities are dropped from the pod, providing a more restrictive security profile. |
| 116 | +<6> Specifies that the container will run with a user with any UID other than 0. |
| 117 | +<7> Specifies the container's seccomp profile. In this case, the type is set to `RuntimeDefault`. Seccomp is a Linux kernel feature that restricts the system calls available to a process, enhancing security by minimizing the attack surface. |
| 118 | + |
| 119 | +. Apply the settings specified in the YAML file by running the following command: |
| 120 | ++ |
| 121 | +[source,terminal] |
| 122 | +---- |
| 123 | +$ oc apply -f examplepod.yaml |
| 124 | +---- |
| 125 | + |
| 126 | +. Verify that the pod is created by running the following command: |
| 127 | ++ |
| 128 | +[source,terminal] |
| 129 | +---- |
| 130 | +$ oc get pod |
| 131 | +---- |
| 132 | ++ |
| 133 | +.Example output |
| 134 | +[source,terminal] |
| 135 | +---- |
| 136 | +NAME READY STATUS RESTARTS AGE |
| 137 | +allmultipod 1/1 Running 0 23s |
| 138 | +---- |
| 139 | + |
| 140 | +. Log in to the pod by running the following command: |
| 141 | ++ |
| 142 | +[source,terminal] |
| 143 | +---- |
| 144 | +$ oc rsh allmultipod |
| 145 | +---- |
| 146 | + |
| 147 | +. List all the interfaces associated with the pod by running the following command: |
| 148 | ++ |
| 149 | +[source,terminal] |
| 150 | +---- |
| 151 | +sh-4.4# ip link |
| 152 | +---- |
| 153 | ++ |
| 154 | +.Example output |
| 155 | +[source,terminal] |
| 156 | +---- |
| 157 | +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 |
| 158 | + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 |
| 159 | +2: eth0@if22: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8901 qdisc noqueue state UP mode DEFAULT group default |
| 160 | + link/ether 0a:58:0a:83:00:10 brd ff:ff:ff:ff:ff:ff link-netnsid 0 <1> |
| 161 | +3: net1@if24: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default |
| 162 | + link/ether ee:9b:66:a4:ec:1d brd ff:ff:ff:ff:ff:ff link-netnsid 0 <2> |
| 163 | +---- |
| 164 | +<1> `eth0@if22` is the primary interface |
| 165 | +<2> `net1@if24` is the secondary interface configured with the network-attachment-definition that supports the all-multicast mode (ALLMULTI flag) |
0 commit comments