@@ -358,9 +358,10 @@ func (c *Controller) handleInitVpcNatGw(key string) error {
358358 }
359359 }
360360 if err = c .execNatGwRules (pod , natGwInit , interfaces ); err != nil {
361- err = fmt .Errorf ("failed to init vpc nat gateway, %w" , err )
362- klog .Error (err )
363- return err
361+ // Check if this is a transient initialization error (e.g., first attempt before iptables chains are created)
362+ // The init script may fail on first run but succeed on retry after chains are established
363+ klog .Warningf ("vpc nat gateway %s init attempt failed (will retry): %v" , key , err )
364+ return fmt .Errorf ("failed to init vpc nat gateway, %w" , err )
364365 }
365366
366367 if gw .Spec .QoSPolicy != "" {
@@ -731,21 +732,21 @@ func (c *Controller) execNatGwRules(pod *corev1.Pod, operation string, rules []s
731732 }()
732733
733734 cmd := fmt .Sprintf ("bash /kube-ovn/nat-gateway.sh %s %s" , operation , strings .Join (rules , " " ))
734- klog .V (3 ).Info ( cmd )
735+ klog .V (3 ).Infof ( "executing NAT gateway command: %s" , cmd )
735736 stdOutput , errOutput , err := util .ExecuteCommandInContainer (c .config .KubeClient , c .config .KubeRestConfig , pod .Namespace , pod .Name , "vpc-nat-gw" , []string {"/bin/bash" , "-c" , cmd }... )
736737 if err != nil {
737738 if len (errOutput ) > 0 {
738- klog .Errorf ("failed to ExecuteCommandInContainer, errOutput : %v" , errOutput )
739+ klog .Errorf ("NAT gateway command failed - stderr : %v" , errOutput )
739740 }
740741 if len (stdOutput ) > 0 {
741- klog .V ( 3 ). Infof ("failed to ExecuteCommandInContainer, stdOutput : %v" , stdOutput )
742+ klog .Infof ("NAT gateway command failed - stdout : %v" , stdOutput )
742743 }
743- klog .Error ( err )
744+ klog .Errorf ( "NAT gateway command execution error: %v" , err )
744745 return err
745746 }
746747
747748 if len (stdOutput ) > 0 {
748- klog .V (3 ).Infof ("ExecuteCommandInContainer stdOutput : %v" , stdOutput )
749+ klog .V (3 ).Infof ("NAT gateway command succeeded - stdout : %v" , stdOutput )
749750 }
750751
751752 if len (errOutput ) > 0 {
@@ -978,12 +979,16 @@ func (c *Controller) genNatGwStatefulSet(gw *kubeovnv1.VpcNatGateway, oldSts *v1
978979 if v6Gateway != "" {
979980 routes = append (routes , request.Route {Destination : "::/0" , Gateway : v6Gateway })
980981 }
982+ // TODO:// check NAD if has ipam to disable ipam
981983 if ! gw .Spec .NoDefaultEIP {
982984 if err = setPodRoutesAnnotation (annotations , subnet .Spec .Provider , routes ); err != nil {
983985 klog .Error (err )
984986 return nil , err
985987 }
986988 } else {
989+ // NAT gateway uses no-IPAM mode in network attachment definition when NoDefaultEIP is enabled
990+ // This allows macvlan/other CNI plugins to work without IP allocation from Kube-OVN
991+ klog .Infof ("skipping IP allocation for NAT gateway %s (NoDefaultEIP enabled)" , gw .Name )
987992 annotations [fmt .Sprintf (util .AllocatedAnnotationTemplate , subnet .Spec .Provider )] = "true"
988993 }
989994
0 commit comments