Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable migration controllers if webhooks are enabled #7128

Merged
merged 9 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions charts/karpenter/templates/clusterrole-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ rules:
{{- if .Values.webhook.enabled }}
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["watch", "list"]
verbs: ["get", "watch", "list"]
{{- end }}
- apiGroups: ["policy"]
resources: ["poddisruptionbudgets"]
Expand All @@ -68,13 +68,14 @@ rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["delete"]
{{- if .Values.webhook.enabled }}
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions/status"]
resourceNames: ["ec2nodeclasses.karpenter.k8s.aws", "nodepools.karpenter.sh", "nodeclaims.karpenter.sh"]
verbs: ["patch"]
{{- if .Values.webhook.enabled }}
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
resourceNames: ["ec2nodeclasses.karpenter.k8s.aws", "nodepools.karpenter.sh", "nodeclaims.karpenter.sh"]
verbs: ["update"]
{{- end }}
{{- with .Values.additionalClusterRoleRules -}}
Expand Down
1 change: 1 addition & 0 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func main() {

op.
WithControllers(ctx, corecontrollers.NewControllers(
ctx,
op.Manager,
op.Clock,
op.GetClient(),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require (
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
knative.dev/pkg v0.0.0-20231010144348-ca8c009405dd
sigs.k8s.io/controller-runtime v0.18.4
sigs.k8s.io/karpenter v1.0.2
sigs.k8s.io/karpenter v1.0.3-0.20240930210524-ced4d37eda82
sigs.k8s.io/yaml v1.4.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,8 @@ sigs.k8s.io/controller-runtime v0.18.4 h1:87+guW1zhvuPLh1PHybKdYFLU0YJp4FhJRmiHv
sigs.k8s.io/controller-runtime v0.18.4/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/karpenter v1.0.2 h1:llX4Sb6cLZmSZImMqFktZ3O+M8+nlc8xRcAEtfQVzCI=
sigs.k8s.io/karpenter v1.0.2/go.mod h1:3NLmsnHHw8p4VutpjTOPUZyhE3qH6yGTs8O94Lsu8uw=
sigs.k8s.io/karpenter v1.0.3-0.20240930210524-ced4d37eda82 h1:kKll2aUiWasrhrIkZF2fwSC7T5snCirfTQV3mjn0rH4=
sigs.k8s.io/karpenter v1.0.3-0.20240930210524-ced4d37eda82/go.mod h1:3NLmsnHHw8p4VutpjTOPUZyhE3qH6yGTs8O94Lsu8uw=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
Expand Down
5 changes: 4 additions & 1 deletion pkg/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

"sigs.k8s.io/karpenter/pkg/events"
karpoptions "sigs.k8s.io/karpenter/pkg/operator/options"

"github.com/aws/karpenter-provider-aws/pkg/cache"
"github.com/aws/karpenter-provider-aws/pkg/controllers/interruption"
Expand Down Expand Up @@ -68,7 +69,9 @@ func NewControllers(ctx context.Context, mgr manager.Manager, sess *session.Sess
controllerspricing.NewController(pricingProvider),
controllersinstancetype.NewController(instanceTypeProvider),
status.NewController[*v1.EC2NodeClass](kubeClient, mgr.GetEventRecorderFor("karpenter")),
migration.NewController[*v1.EC2NodeClass](kubeClient),
}
if !karpoptions.FromContext(ctx).DisableWebhook {
controllers = append(controllers, migration.NewController[*v1.EC2NodeClass](kubeClient))
}
if options.FromContext(ctx).InterruptionQueue != "" {
sqsapi := servicesqs.New(sess)
Expand Down
2 changes: 0 additions & 2 deletions test/suites/integration/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.
package integration_test

import (
"fmt"
"time"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand Down Expand Up @@ -88,7 +87,6 @@ var _ = Describe("EC2NodeClass Migration Controller", func() {
crd := &apiextensionsv1.CustomResourceDefinition{}
Eventually(func(g Gomega) {
g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(item), crd)).To(Succeed())
fmt.Println(crd.Status.StoredVersions)
g.Expect(crd.Status.StoredVersions).To(HaveExactElements("v1"))
}).WithTimeout(time.Second * 10).Should(Succeed())
}
Expand Down
Loading