Skip to content

Commit

Permalink
fix: conditionally enable migration controllers based on webhook enab…
Browse files Browse the repository at this point in the history
…lement (#1723)
  • Loading branch information
rschalo authored Sep 30, 2024
1 parent a17acfe commit ced4d37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions kwok/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func main() {
op.
WithWebhooks(ctx, webhooks.NewWebhooks()...).
WithControllers(ctx, controllers.NewControllers(
ctx,
op.Manager,
op.Clock,
op.GetClient(),
Expand Down
17 changes: 13 additions & 4 deletions pkg/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ limitations under the License.
package controllers

import (
"context"

"github.com/awslabs/operatorpkg/controller"
"github.com/awslabs/operatorpkg/status"
"k8s.io/utils/clock"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"

v1 "sigs.k8s.io/karpenter/pkg/apis/v1"
"sigs.k8s.io/karpenter/pkg/operator/options"

migrationcrd "sigs.k8s.io/karpenter/pkg/controllers/migration/crd"
migration "sigs.k8s.io/karpenter/pkg/controllers/migration/resource"
Expand Down Expand Up @@ -55,6 +58,7 @@ import (
)

func NewControllers(
ctx context.Context,
mgr manager.Manager,
clock clock.Clock,
kubeClient client.Client,
Expand All @@ -67,7 +71,7 @@ func NewControllers(
evictionQueue := terminator.NewQueue(kubeClient, recorder)
disruptionQueue := orchestration.NewQueue(kubeClient, recorder, cluster, clock, p)

return []controller.Controller{
controllers := []controller.Controller{
p, evictionQueue, disruptionQueue,
disruption.NewController(clock, kubeClient, p, cloudProvider, recorder, cluster, disruptionQueue),
provisioning.NewPodController(kubeClient, p),
Expand Down Expand Up @@ -95,8 +99,13 @@ func NewControllers(
leasegarbagecollection.NewController(kubeClient),
status.NewController[*v1.NodeClaim](kubeClient, mgr.GetEventRecorderFor("karpenter")),
status.NewController[*v1.NodePool](kubeClient, mgr.GetEventRecorderFor("karpenter")),
migration.NewController[*v1.NodeClaim](kubeClient),
migration.NewController[*v1.NodePool](kubeClient),
migrationcrd.NewController(kubeClient, cloudProvider),
}

if !options.FromContext(ctx).DisableWebhook {
controllers = append(controllers, migration.NewController[*v1.NodeClaim](kubeClient))
controllers = append(controllers, migration.NewController[*v1.NodePool](kubeClient))
controllers = append(controllers, migrationcrd.NewController(kubeClient, cloudProvider))
}

return controllers
}

0 comments on commit ced4d37

Please sign in to comment.