From 6a940ff9d61dc81bdb3745f86b94848176a454a4 Mon Sep 17 00:00:00 2001 From: Amanuel Engeda <74629455+engedaam@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:07:56 -0800 Subject: [PATCH] feat: Add node events based metrics (#7382) --- charts/karpenter/templates/clusterrole-core.yaml | 3 +++ pkg/controllers/controllers.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/charts/karpenter/templates/clusterrole-core.yaml b/charts/karpenter/templates/clusterrole-core.yaml index eccc9fb7acc6..bc12a8a70ab7 100644 --- a/charts/karpenter/templates/clusterrole-core.yaml +++ b/charts/karpenter/templates/clusterrole-core.yaml @@ -44,6 +44,9 @@ rules: - apiGroups: ["policy"] resources: ["poddisruptionbudgets"] verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: ["events"] + verbs: ["get", list, "watch"] # Write - apiGroups: ["karpenter.sh"] resources: ["nodeclaims", "nodeclaims/status"] diff --git a/pkg/controllers/controllers.go b/pkg/controllers/controllers.go index 50fabf52d5ea..c5e58541f900 100644 --- a/pkg/controllers/controllers.go +++ b/pkg/controllers/controllers.go @@ -18,6 +18,7 @@ import ( "context" "github.com/awslabs/operatorpkg/controller" + opevents "github.com/awslabs/operatorpkg/events" "github.com/awslabs/operatorpkg/status" "github.com/patrickmn/go-cache" "sigs.k8s.io/controller-runtime/pkg/manager" @@ -37,6 +38,7 @@ import ( servicesqs "github.com/aws/aws-sdk-go-v2/service/sqs" "github.com/samber/lo" + corev1 "k8s.io/api/core/v1" "k8s.io/utils/clock" "sigs.k8s.io/controller-runtime/pkg/client" @@ -86,6 +88,7 @@ func NewControllers( controllersinstancetypecapacity.NewController(kubeClient, instanceTypeProvider), ssminvalidation.NewController(ssmCache, amiProvider), status.NewController[*v1.EC2NodeClass](kubeClient, mgr.GetEventRecorderFor("karpenter"), status.EmitDeprecatedMetrics), + opevents.NewController[*corev1.Node](kubeClient, clk), } if options.FromContext(ctx).InterruptionQueue != "" { sqsapi := servicesqs.NewFromConfig(cfg)