diff --git a/npm/cmd/start.go b/npm/cmd/start.go index 391d994f28..2eca111ff8 100644 --- a/npm/cmd/start.go +++ b/npm/cmd/start.go @@ -130,6 +130,8 @@ func start(config npmconfig.Config, flags npmconfig.Flags) error { options.FieldSelector = "spec.nodeName=" + models.GetNodeName() }), ) + npmV2DataplaneCfg.IsL1VHNode = config.Toggles.IsL1VHNode + npmV2DataplaneCfg.EnableNPMLite = config.Toggles.EnableNPMLite } k8sServerVersion := k8sServerVersion(clientset) diff --git a/npm/config/config.go b/npm/config/config.go index b725703901..5648edd04b 100644 --- a/npm/config/config.go +++ b/npm/config/config.go @@ -52,6 +52,7 @@ var DefaultConfig = Config{ // NetPolInBackground is currently used in Linux to apply NetPol controller Add events in the background NetPolInBackground: true, EnableNPMLite: false, + IsL1VHNode: false, }, } @@ -96,6 +97,7 @@ type Toggles struct { // NetPolInBackground NetPolInBackground bool EnableNPMLite bool + IsL1VHNode bool } type Flags struct { diff --git a/npm/examples/windows/azure-npm-lite-win.yaml b/npm/examples/windows/azure-npm-lite-win.yaml index f2aa5ed7bc..6bb0161de8 100644 --- a/npm/examples/windows/azure-npm-lite-win.yaml +++ b/npm/examples/windows/azure-npm-lite-win.yaml @@ -154,6 +154,7 @@ data: "ApplyIPSetsOnNeed": false, "ApplyInBackground": true, "NetPolInBackground": true - "EnableNPMLite": true + "EnableNPMLite": true, + "IsL1VHNode": true } } diff --git a/npm/pkg/dataplane/dataplane.go b/npm/pkg/dataplane/dataplane.go index 4a3ccd68ef..ec09be6209 100644 --- a/npm/pkg/dataplane/dataplane.go +++ b/npm/pkg/dataplane/dataplane.go @@ -45,6 +45,8 @@ type Config struct { NetPolInBackground bool MaxPendingNetPols int NetPolInterval time.Duration + IsL1VHNode bool + EnableNPMLite bool *ipsets.IPSetManagerCfg *policies.PolicyManagerCfg } diff --git a/npm/pkg/dataplane/dataplane_windows.go b/npm/pkg/dataplane/dataplane_windows.go index cb65bdd420..4060ce32d2 100644 --- a/npm/pkg/dataplane/dataplane_windows.go +++ b/npm/pkg/dataplane/dataplane_windows.go @@ -52,6 +52,14 @@ func (dp *DataPlane) initializeDataPlane() error { } // Filter out any endpoints that are not in "AttachedShared" State. All running Windows pods with networking must be in this state. filterMap := map[string]uint16{"State": hcnEndpointStateAttachedSharing} + klog.Info("State:hcnEndpointStateAttachedSharing ") + + // if npm lite is enabled and running on l1vh node, filter out any endpoints that are not in "Attached" State + if dp.EnableNPMLite && dp.IsL1VHNode { + klog.Info("NPM lite is running on L1VH Node") + filterMap = map[string]uint16{"State": hcnEndpointStateAttached} + } + filter, err := json.Marshal(filterMap) if err != nil { return npmerrors.SimpleErrorWrapper("failed to marshal endpoint filter map", err)