From a82eb880685fc2856fd4670a3910da934cc776e8 Mon Sep 17 00:00:00 2001 From: Samuel Lang Date: Fri, 13 Oct 2023 10:44:56 +0200 Subject: [PATCH] support unknown resources Karpenter cannot be used on clusters where custom resources for pods are used, such as device drivers like `/dev/fuse` used with Podman. Following error is logged: ``` karpenter-778b9dbc4f-gk88t {"level":"ERROR",..."logger":"controller.provisioner","message":"Could not schedule pod, incompatible with provisioner \"default\", daemonset overhead={\"cpu\":\"562m\",\"memory\":\"758026799\",\"pods\":\"10\"}, no instance type satisfied resources {\"cpu\":\"1562m\",\"memory\":\"1831768623\",\"pods\":\"11\",\"smarter-devices/fuse\":\"1\"} and requirements karpenter.k8s.aws/instance-category In [c m r], karpenter.k8s.aws/instance-generation Exists >2, karpenter.k8s.aws/instance-hypervisor In [nitro], karpenter.k8s.aws/instance-size NotIn [medium micro nano small], karpenter.sh/capacity-type In [on-demand spot], karpenter.sh/provisioner-name In [default], kubernetes.io/arch In [amd64], kubernetes.io/os In [linux], node.kubernetes.io/node-group In [primary] (no instance type has enough resources)"} ``` Here we add a flag to instruct Karpenter to ignore certain defined resources, which will allow the usage of Karpenter for these clusters. --- pkg/utils/resources/resources.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/utils/resources/resources.go b/pkg/utils/resources/resources.go index ffffc2fa3e..975e192a2a 100644 --- a/pkg/utils/resources/resources.go +++ b/pkg/utils/resources/resources.go @@ -17,6 +17,8 @@ limitations under the License. package resources import ( + "strings" + "github.com/samber/lo" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -226,6 +228,9 @@ func Fits(candidate, total v1.ResourceList) bool { } } for resourceName, quantity := range candidate { + if strings.Contains(resourceName.String(), "smarter-devices") { + continue + } if Cmp(quantity, total[resourceName]) > 0 { return false }