File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -595,9 +595,19 @@ func (npc *NetworkPolicyController) getFirewallEnabledPods(nodeIp string) (*map[
595595			podNeedsFirewall  :=  false 
596596			for  _ , policy_obj  :=  range  watchers .NetworkPolicyWatcher .List () {
597597				policy , _  :=  policy_obj .(* networking.NetworkPolicy )
598+ 
599+ 				// we are only interested in the network policies in same namespace that of pod 
598600				if  policy .Namespace  !=  pod .ObjectMeta .Namespace  {
599601					continue 
600602				}
603+ 
604+ 				// An empty podSelector matches all pods in this namespace. 
605+ 				if  len (policy .Spec .PodSelector .MatchLabels ) ==  0  ||  len (policy .Spec .PodSelector .MatchExpressions ) ==  0  {
606+ 					podNeedsFirewall  =  true 
607+ 					break 
608+ 				}
609+ 
610+ 				// if pod matches atleast on network policy labels then pod needs firewall 
601611				matchingPods , err  :=  watchers .PodWatcher .ListByNamespaceAndLabels (policy .Namespace ,
602612					policy .Spec .PodSelector .MatchLabels )
603613				if  err  !=  nil  {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments