mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-06 06:46:26 +01:00
40 lines
1.1 KiB
Plaintext
40 lines
1.1 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * networking/network_policy/creating-network-policy.adoc
|
|
// * networking/network_policy/viewing-network-policy.adoc
|
|
// * networking/network_policy/editing-network-policy.adoc
|
|
// * networking/configuring-networkpolicy.adoc
|
|
// * post_installation_configuration/network-configuration.adoc
|
|
|
|
[id="nw-networkpolicy-object_{context}"]
|
|
|
|
= Example NetworkPolicy object
|
|
|
|
The following annotates an example NetworkPolicy object:
|
|
|
|
[source,yaml]
|
|
----
|
|
kind: NetworkPolicy
|
|
apiVersion: networking.k8s.io/v1
|
|
metadata:
|
|
name: allow-27107 <1>
|
|
spec:
|
|
podSelector: <2>
|
|
matchLabels:
|
|
app: mongodb
|
|
ingress:
|
|
- from:
|
|
- podSelector: <3>
|
|
matchLabels:
|
|
app: app
|
|
ports: <4>
|
|
- protocol: TCP
|
|
port: 27017
|
|
----
|
|
<1> The `name` of the NetworkPolicy object.
|
|
<2> A selector describing the pods the policy applies to. The policy object can
|
|
only select pods in the project that the NetworkPolicy object is defined.
|
|
<3> A selector matching the pods that the policy object allows ingress traffic
|
|
from. The selector will match pods in any project.
|
|
<4> A list of one or more destination ports to accept traffic on.
|