diff --git a/pkg/controllers/cisnetworkpolicy/controller.go b/pkg/controllers/cisnetworkpolicy/controller.go index ae39b289de7..b8e20f9bf61 100644 --- a/pkg/controllers/cisnetworkpolicy/controller.go +++ b/pkg/controllers/cisnetworkpolicy/controller.go @@ -34,7 +34,7 @@ func register(ctx context.Context, ctx: ctx, k8s: k8s, } - logrus.Debugf("CISNetworkPolicyController: Registering controller hooks") + logrus.Debugf("CISNetworkPolicyController: Registering controller hooks for NetworkPolicy %s", flannelHostNetworkPolicyName) nodes.OnChange(ctx, "cisnetworkpolicy-node", h.handle) nodes.OnRemove(ctx, "cisnetworkpolicy-node", h.handle) return nil diff --git a/pkg/rke2/rke2.go b/pkg/rke2/rke2.go index ef38e92c9ea..18f87a330a5 100644 --- a/pkg/rke2/rke2.go +++ b/pkg/rke2/rke2.go @@ -20,6 +20,7 @@ import ( rawServer "github.com/k3s-io/k3s/pkg/server" "github.com/natefinch/lumberjack" "github.com/pkg/errors" + "github.com/rancher/norman/types/slice" "github.com/rancher/rke2/pkg/controllers/cisnetworkpolicy" "github.com/rancher/rke2/pkg/images" "github.com/sirupsen/logrus" @@ -114,7 +115,8 @@ func Server(clx *cli.Context, cfg Config) error { var leaderControllers rawServer.CustomControllers - if cisMode { + cnis := clx.StringSlice("cni") + if cisMode && (len(cnis) == 0 || slice.ContainsString(cnis, "canal")) { leaderControllers = append(leaderControllers, cisnetworkpolicy.Controller) }