@@ -39,10 +39,6 @@ import (
3939 networking "k8s.io/api/networking/v1"
4040)
4141
42- const (
43- defaultLocalConntrackCacheCleanupPeriodInSeconds = 300
44- )
45-
4642func log () logger.Logger {
4743 return logger .Get ()
4844}
@@ -84,11 +80,12 @@ func prometheusRegister() {
8480}
8581
8682// NewPolicyEndpointsReconciler constructs new PolicyEndpointReconciler
87- func NewPolicyEndpointsReconciler (k8sClient client.Client , nodeIP string , ebpfClient ebpf.BpfClient ) * PolicyEndpointsReconciler {
83+ func NewPolicyEndpointsReconciler (k8sClient client.Client , nodeIP string , ebpfClient ebpf.BpfClient , enableIPv6 bool ) * PolicyEndpointsReconciler {
8884 r := & PolicyEndpointsReconciler {
8985 k8sClient : k8sClient ,
9086 nodeIP : nodeIP ,
9187 ebpfClient : ebpfClient ,
88+ enableIPv6 : enableIPv6 ,
9289 }
9390
9491 prometheusRegister ()
@@ -111,6 +108,7 @@ type PolicyEndpointsReconciler struct {
111108 networkPolicyToPodIdentifierMap sync.Map
112109 //BPF Client instance
113110 ebpfClient ebpf.BpfClient
111+ enableIPv6 bool
114112}
115113
116114//+kubebuilder:rbac:groups=networking.k8s.aws,resources=policyendpoints,verbs=get;list;watch
@@ -244,13 +242,13 @@ func (r *PolicyEndpointsReconciler) reconcilePolicyEndpoint(ctx context.Context,
244242 if len (ingressRules ) == 0 && ! isIngressIsolated {
245243 //Add allow-all entry to Ingress rule set
246244 log ().Info ("No Ingress rules and no ingress isolation - Appending catch all entry" )
247- r .addCatchAllEntry (ctx , & ingressRules )
245+ r .addCatchAllEntry (& ingressRules )
248246 }
249247
250248 if len (egressRules ) == 0 && ! isEgressIsolated {
251249 //Add allow-all entry to Egress rule set
252250 log ().Info ("No Egress rules and no egress isolation - Appending catch all entry" )
253- r .addCatchAllEntry (ctx , & egressRules )
251+ r .addCatchAllEntry (& egressRules )
254252 }
255253
256254 // Setup/configure eBPF probes/maps for local pods
@@ -339,14 +337,14 @@ func (r *PolicyEndpointsReconciler) cleanupPod(ctx context.Context, targetPod ty
339337 // No active ingress rules for this pod, but we only should land here
340338 // if there are active egress rules. So, we need to add an allow-all entry to ingress rule set
341339 log ().Info ("No Ingress rules and no ingress isolation - Appending catch all entry" )
342- r .addCatchAllEntry (ctx , & ingressRules )
340+ r .addCatchAllEntry (& ingressRules )
343341 }
344342
345343 if noActiveEgressPolicies {
346344 // No active egress rules for this pod but we only should land here
347345 // if there are active ingress rules. So, we need to add an allow-all entry to egress rule set
348346 log ().Info ("No Egress rules and no egress isolation - Appending catch all entry" )
349- r .addCatchAllEntry (ctx , & egressRules )
347+ r .addCatchAllEntry (& egressRules )
350348 }
351349
352350 err = r .updateeBPFMaps (ctx , podIdentifier , ingressRules , egressRules )
@@ -647,18 +645,18 @@ func (r *PolicyEndpointsReconciler) deletePolicyEndpointFromPodIdentifierMap(ctx
647645 }
648646}
649647
650- func (r * PolicyEndpointsReconciler ) addCatchAllEntry (ctx context. Context , firewallRules * []fwrp.EbpfFirewallRules ) {
648+ func (r * PolicyEndpointsReconciler ) addCatchAllEntry (firewallRules * []fwrp.EbpfFirewallRules ) {
651649 //Add allow-all entry to firewall rule set
652- catchAllRule := policyk8sawsv1.EndpointInfo {
653- CIDR : "0.0.0.0/0" ,
650+ var catchAllCIDR string
651+ if r .enableIPv6 {
652+ catchAllCIDR = "::/0"
653+ } else {
654+ catchAllCIDR = "0.0.0.0/0"
654655 }
655656 * firewallRules = append (* firewallRules ,
656657 fwrp.EbpfFirewallRules {
657- IPCidr : catchAllRule .CIDR ,
658- L4Info : catchAllRule .Ports ,
658+ IPCidr : policyk8sawsv1 .NetworkAddress (catchAllCIDR ),
659659 })
660-
661- return
662660}
663661
664662// SetupWithManager sets up the controller with the Manager.
@@ -706,14 +704,14 @@ func (r *PolicyEndpointsReconciler) DeriveFireWallRulesPerPodIdentifier(podIdent
706704 // No active ingress rules for this pod, but we only should land here
707705 // if there are active egress rules. So, we need to add an allow-all entry to ingress rule set
708706 log ().Info ("No Ingress rules and no ingress isolation - Appending catch all entry" )
709- r .addCatchAllEntry (context . Background (), & ingressRules )
707+ r .addCatchAllEntry (& ingressRules )
710708 }
711709
712710 if len (egressRules ) == 0 && ! isEgressIsolated {
713711 // No active egress rules for this pod but we only should land here
714712 // if there are active ingress rules. So, we need to add an allow-all entry to egress rule set
715713 log ().Info ("No Egress rules and no egress isolation - Appending catch all entry" )
716- r .addCatchAllEntry (context . Background (), & egressRules )
714+ r .addCatchAllEntry (& egressRules )
717715 }
718716
719717 return ingressRules , egressRules , nil
0 commit comments