kubernetes / website

Kubernetes website and documentation repo:
https://kubernetes.io
Creative Commons Attribution 4.0 International
4.47k stars 14.39k forks source link

Enhance Network Policies docs #45615

Open giuliano-scassaioli opened 7 months ago

giuliano-scassaioli commented 7 months ago

Please if possible add here: https://kubernetes.io/docs/concepts/services-networking/network-policies/ at this paragraph: "Behavior of to and from selectors" a small working yaml example which shows that also with egress -to (now it's only shown with ingress -from) the - namespaceSelector: and - podSelector: specs can be added making simpler for developers and students to quickly pick up an example and use it. Thank you.

dipesh-rawat commented 7 months ago

Page mentioned in the issue: https://kubernetes.io/docs/concepts/services-networking/network-policies /language en

sftim commented 7 months ago

/retitle Enhance Network Policies docs /kind feature /sig network

/priority backlog We definitely have higher priorities than this (if we accept it)

tengqm commented 6 months ago

/triage accepted

Codecollab-go commented 5 months ago

Hi @giuliano-scassaioli, do you mean something like this ?

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-ingress
spec:
  podSelector:
    matchLabels:
      app: my-app
  policyTypes:
    - Ingress
  ingress:
    - from:
        - namespaceSelector:
            matchLabels:
              user: alice
        - podSelector:
            matchLabels:
              role: client