Skip to content

Commit 9c8cc6d

Browse files
authored
Merge pull request #96111 from openshift-cherrypick-robot/cherry-pick-95148-to-enterprise-4.20
[enterprise-4.20] OCPBUGS#49997: Enhanced the info for the k8s.v1.cni.cncf.io/policy-fo…
2 parents ef4254e + 94c41c7 commit 9c8cc6d

7 files changed

+14
-12
lines changed

modules/configuration-ovnk-multi-network-policy.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ a|
2626

2727
|====
2828

29-
For example, the following multi-network policy is valid only if the `subnets` field is defined in the secondary network CNI configuration for the secondary network named `blue2`:
29+
You can use the `k8s.v1.cni.cncf.io/policy-for` annotation on a `MultiNetworkPolicy` object to point to a `NetworkAttachmentDefinition` (NAD) custom resource (CR). The NAD CR defines the network to which the policy applies. The following example multi-network policy is valid only if the `subnets` field is defined in the secondary network CNI configuration for the secondary network named `blue2`:
3030

3131
.Example multi-network policy that uses a pod selector
3232
[source,yaml]
@@ -36,7 +36,7 @@ kind: MultiNetworkPolicy
3636
metadata:
3737
name: allow-same-namespace
3838
annotations:
39-
k8s.v1.cni.cncf.io/policy-for: blue2
39+
k8s.v1.cni.cncf.io/policy-for: blue2 <1>
4040
spec:
4141
podSelector:
4242
ingress:

modules/nw-multi-network-policy-differences.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@ kind: MultiNetworkPolicy
1818
1919
* You must use the `multi-networkpolicy` resource name when using the CLI to interact with multi-network policies. For example, you can view a multi-network policy object with the `oc get multi-networkpolicy <name>` command where `<name>` is the name of a multi-network policy.
2020
21-
* You must specify an annotation with the name of the network attachment definition that defines the secondary network:
21+
* You can use the `k8s.v1.cni.cncf.io/policy-for` annotation on a `MultiNetworkPolicy` object to point to a `NetworkAttachmentDefinition` (NAD) custom resource (CR). The NAD CR defines the network to which the policy applies.
2222
+
23+
.Example multi-network policy that includes the `k8s.v1.cni.cncf.io/policy-for` annotation
2324
[source,yaml]
2425
----
2526
apiVersion: k8s.cni.cncf.io/v1beta1
2627
kind: MultiNetworkPolicy
2728
metadata:
2829
annotations:
29-
k8s.v1.cni.cncf.io/policy-for: <network_name>
30+
k8s.v1.cni.cncf.io/policy-for:<namespace_name>/<network_name>
3031
----
3132
+
3233
--
3334
where:
3435
36+
`<namespace_name>`:: Specifies the namespace name.
3537
`<network_name>`:: Specifies the name of a network attachment definition.
3638
--

modules/nw-networkpolicy-allow-application-all-namespaces.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ metadata:
5454
namespace: default
5555
ifdef::multi[]
5656
annotations:
57-
k8s.v1.cni.cncf.io/policy-for: <network_name>
57+
k8s.v1.cni.cncf.io/policy-for:<namespace_name>/<network_name>
5858
endif::multi[]
5959
spec:
6060
podSelector:

modules/nw-networkpolicy-allow-application-particular-namespace.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ metadata:
5757
namespace: default
5858
ifdef::multi[]
5959
annotations:
60-
k8s.v1.cni.cncf.io/policy-for: <network_name>
60+
k8s.v1.cni.cncf.io/policy-for:<namespace_name>/<network_name>
6161
endif::multi[]
6262
spec:
6363
podSelector:

modules/nw-networkpolicy-allow-external-clients.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ metadata:
6161
namespace: default
6262
ifdef::multi[]
6363
annotations:
64-
k8s.v1.cni.cncf.io/policy-for: <network_name>
64+
k8s.v1.cni.cncf.io/policy-for:<namespace_name>/<network_name>
6565
endif::multi[]
6666
spec:
6767
policyTypes:

modules/nw-networkpolicy-create-cli.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ metadata:
104104
name: allow-same-namespace
105105
ifdef::multi[]
106106
annotations:
107-
k8s.v1.cni.cncf.io/policy-for: <network_name>
107+
k8s.v1.cni.cncf.io/policy-for:<namespace_name>/<network_name>
108108
endif::multi[]
109109
spec:
110110
podSelector:
@@ -139,7 +139,7 @@ metadata:
139139
name: allow-traffic-pod
140140
ifdef::multi[]
141141
annotations:
142-
k8s.v1.cni.cncf.io/policy-for: <network_name>
142+
k8s.v1.cni.cncf.io/policy-for:<namespace_name>/<network_name>
143143
endif::multi[]
144144
spec:
145145
podSelector:
@@ -186,7 +186,7 @@ metadata:
186186
name: api-allow
187187
ifdef::multi[]
188188
annotations:
189-
k8s.v1.cni.cncf.io/policy-for: <network_name>
189+
k8s.v1.cni.cncf.io/policy-for:<namespace_name>/<network_name>
190190
endif::multi[]
191191
spec:
192192
podSelector:

modules/nw-networkpolicy-deny-all-allowed.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ metadata:
4646
name: deny-by-default
4747
namespace: my-project <1>
4848
annotations:
49-
k8s.v1.cni.cncf.io/policy-for: <namespace_name>/<network_name> <2>
49+
k8s.v1.cni.cncf.io/policy-for:<namespace_name>/<network_name> <2>
5050
spec:
5151
podSelector: {} <3>
5252
policyTypes: <4>
@@ -66,7 +66,7 @@ endif::multi[]
6666
----
6767
ifdef::multi[]
6868
<1> Specifies the namespace in which to deploy the policy. For example, the `my-project` namespace.
69-
<2> Specifies the name of a network attachment definition.
69+
<2> Specifies the name of namespace project followed by the network attachment definition name.
7070
<3> If this field is empty, the configuration matches all the pods. Therefore, the policy applies to all pods in the `my-project` namespace.
7171
<4> Specifies a list of rule types that the `NetworkPolicy` relates to.
7272
<5> Specifies `Ingress` only `policyTypes`.

0 commit comments

Comments
 (0)