Skip to content

Latest commit

 

History

History
75 lines (49 loc) · 1.42 KB

File metadata and controls

75 lines (49 loc) · 1.42 KB

Network Policies

Trafic flowing through a webserver serving frontend to users an app server serving backend API and a database server

traffic

  • There are two types of traffic

    • Ingress
    • Egress

    ing1

    ing2

Network Security

nsec

Network Policy

npol

npol1

Network Policy Selectors

npolsec

Network Policy Rules

npol2

Create network policy

  • To create a network policy
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
     name: db-policy
    spec:
      podSelector:
        matchLabels:
          role: db
      policyTypes:
      - Ingress
      ingress:
      - from:
        - podSelector:
            matchLabels:
              role: api-pod
        ports:
        - protocol: TCP
          port: 3306
    
    $ kubectl create -f policy-definition.yaml
    
    ![npol3](../../images/npol3.PNG)
    
    ![npol4](../../images/npol4.PNG)
    
    

Note

note1

K8s Reference Docs