Skip to content

Commit 55510ce

Browse files
Merge pull request #14 from smartnews/v0.37.4-patch
chore: upgrade to v0.37.4
2 parents 79c6bc1 + 5932e91 commit 55510ce

File tree

9 files changed

+59
-5
lines changed

9 files changed

+59
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ licenses: download ## Verifies dependency licenses
127127
! go-licenses csv ./... | grep -v -e 'MIT' -e 'Apache-2.0' -e 'BSD-3-Clause' -e 'BSD-2-Clause' -e 'ISC' -e 'MPL-2.0' -e 'github.com/awslabs/amazon-eks-ami/nodeadm'
128128

129129
image: ## Build the Karpenter controller images using ko build
130-
$(eval CONTROLLER_IMG=$(shell $(WITH_GOFLAGS) KOCACHE=$(KOCACHE) KO_DOCKER_REPO="$(KO_DOCKER_REPO)" ko build --bare github.com/aws/karpenter-provider-aws/cmd/controller))
130+
$(eval CONTROLLER_IMG=$(shell $(WITH_GOFLAGS) KOCACHE=$(KOCACHE) KO_DOCKER_REPO="$(KO_DOCKER_REPO)" ko build --platform linux/amd64 --bare github.com/aws/karpenter-provider-aws/cmd/controller))
131131
$(eval IMG_REPOSITORY=$(shell echo $(CONTROLLER_IMG) | cut -d "@" -f 1 | cut -d ":" -f 1))
132132
$(eval IMG_TAG=$(shell echo $(CONTROLLER_IMG) | cut -d "@" -f 1 | cut -d ":" -f 2 -s))
133133
$(eval IMG_DIGEST=$(shell echo $(CONTROLLER_IMG) | cut -d "@" -f 2))

charts/karpenter-crd/templates/karpenter.sh_nodepools.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,13 @@ spec:
621621
memory leak protection, and disruption testing.
622622
pattern: ^(([0-9]+(s|m|h))+)|(Never)$
623623
type: string
624+
utilizationThreshold:
625+
description: |-
626+
UtilizationThreshold is defined as sum of requested resources divided by capacity
627+
below which a node can be considered for disruption.
628+
maximum: 100
629+
minimum: 1
630+
type: integer
624631
type: object
625632
x-kubernetes-validations:
626633
- message: consolidateAfter cannot be combined with consolidationPolicy=WhenUnderutilized

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,5 @@ require (
116116
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
117117
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
118118
)
119+
120+
replace sigs.k8s.io/karpenter v0.37.4 => github.com/smartnews/karpenter v0.37.4-sn-1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXn
337337
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
338338
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
339339
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
340+
github.com/smartnews/karpenter v0.37.4-sn-1 h1:veKX4PXeHuTIDdNxtIhdeM6FbICWXfUg6N2AGMWfacc=
341+
github.com/smartnews/karpenter v0.37.4-sn-1/go.mod h1:XvblVAMUcv1Ja8eYC6dg4Wmx3Kwxhp58//YlPhVZQTk=
340342
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
341343
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
342344
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
@@ -761,8 +763,6 @@ sigs.k8s.io/controller-runtime v0.18.2 h1:RqVW6Kpeaji67CY5nPEfRz6ZfFMk0lWQlNrLql
761763
sigs.k8s.io/controller-runtime v0.18.2/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw=
762764
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
763765
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
764-
sigs.k8s.io/karpenter v0.37.4 h1:h0DpVO+urDRYJeu0jLO3WlmFEAt17fj2WUfrzLhSDbc=
765-
sigs.k8s.io/karpenter v0.37.4/go.mod h1:XvblVAMUcv1Ja8eYC6dg4Wmx3Kwxhp58//YlPhVZQTk=
766766
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
767767
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
768768
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=

pkg/apis/crds/karpenter.sh_nodepools.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,13 @@ spec:
621621
memory leak protection, and disruption testing.
622622
pattern: ^(([0-9]+(s|m|h))+)|(Never)$
623623
type: string
624+
utilizationThreshold:
625+
description: |-
626+
UtilizationThreshold is defined as sum of requested resources divided by capacity
627+
below which a node can be considered for disruption.
628+
maximum: 100
629+
minimum: 1
630+
type: integer
624631
type: object
625632
x-kubernetes-validations:
626633
- message: consolidateAfter cannot be combined with consolidationPolicy=WhenUnderutilized

pkg/cache/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
// resources. Cache hits enable faster provisioning and reduced API load on
2424
// AWS APIs, which can have a serious impact on performance and scalability.
2525
// DO NOT CHANGE THIS VALUE WITHOUT DUE CONSIDERATION
26-
DefaultTTL = time.Minute
26+
DefaultTTL = 5 * time.Minute
2727
// UnavailableOfferingsTTL is the time before offerings that were marked as unavailable
2828
// are removed from the cache and are available for launch again
2929
UnavailableOfferingsTTL = 3 * time.Minute

pkg/controllers/interruption/controller.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/samber/lo"
2525
"go.uber.org/multierr"
2626
v1 "k8s.io/api/core/v1"
27+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2728
"k8s.io/client-go/util/workqueue"
2829
"k8s.io/klog/v2"
2930
"k8s.io/utils/clock"
@@ -201,13 +202,36 @@ func (c *Controller) handleNodeClaim(ctx context.Context, msg messages.Message,
201202
if zone != "" && instanceType != "" {
202203
c.unavailableOfferingsCache.MarkUnavailable(ctx, string(msg.Kind()), instanceType, zone, v1beta1.CapacityTypeSpot)
203204
}
205+
spotTotal.WithLabelValues(instanceType, zone, nodeClaim.Status.NodeName, nodeClaim.Labels["karpenter.sh/nodepool"]).Inc()
206+
// try to create a new nodeclaim immediately but ignore error if it fails
207+
if err := c.createNodeClaim(ctx, nodeClaim); err != nil {
208+
log.FromContext(ctx).Error(err, "[interruption handling]failed to create a new nodeclaim")
209+
} else {
210+
log.FromContext(ctx).Info("Created new nodeclaim due to spot interruption")
211+
// wait for the node provisioning before draining
212+
time.Sleep(60 * time.Second)
213+
}
204214
}
205215
if action != NoAction {
206216
return c.deleteNodeClaim(ctx, nodeClaim, node)
207217
}
208218
return nil
209219
}
210220

221+
// createNodeClaim creates a new NodeClaim with the same spec of the interrupted one
222+
func (c *Controller) createNodeClaim(ctx context.Context, oldNodeClaim *v1beta1.NodeClaim) error {
223+
newNodeClaim := &v1beta1.NodeClaim{
224+
ObjectMeta: metav1.ObjectMeta{
225+
GenerateName: oldNodeClaim.ObjectMeta.GenerateName,
226+
Annotations: oldNodeClaim.ObjectMeta.Annotations,
227+
Labels: oldNodeClaim.ObjectMeta.Labels,
228+
OwnerReferences: oldNodeClaim.ObjectMeta.OwnerReferences,
229+
},
230+
Spec: oldNodeClaim.Spec,
231+
}
232+
return c.kubeClient.Create(ctx, newNodeClaim)
233+
}
234+
211235
// deleteNodeClaim removes the NodeClaim from the api-server
212236
func (c *Controller) deleteNodeClaim(ctx context.Context, nodeClaim *v1beta1.NodeClaim, node *v1.Node) error {
213237
if !nodeClaim.DeletionTimestamp.IsZero() {

pkg/controllers/interruption/metrics.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ const (
2626
messageTypeLabel = "message_type"
2727
actionTypeLabel = "action_type"
2828
terminationReasonLabel = "interruption"
29+
instanceTypeLabel = "instance_type"
30+
zoneLabel = "zone"
31+
hostLabel = "node_name"
32+
poolLabel = "node_pool"
2933
)
3034

3135
var (
@@ -67,8 +71,17 @@ var (
6771
metrics.NodePoolLabel,
6872
},
6973
)
74+
spotTotal = prometheus.NewCounterVec(
75+
prometheus.CounterOpts{
76+
Namespace: metrics.Namespace,
77+
Subsystem: interruptionSubsystem,
78+
Name: "spot_total",
79+
Help: "Number of the spot interruption. Labeled by AZ, instance type",
80+
},
81+
[]string{instanceTypeLabel, zoneLabel, hostLabel, poolLabel},
82+
)
7083
)
7184

7285
func init() {
73-
crmetrics.Registry.MustRegister(receivedMessages, deletedMessages, messageLatency, actionsPerformed)
86+
crmetrics.Registry.MustRegister(receivedMessages, deletedMessages, messageLatency, actionsPerformed, spotTotal)
7487
}

pkg/providers/instance/instance.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ func getTags(ctx context.Context, nodeClass *v1beta1.EC2NodeClass, nodeClaim *co
264264
corev1beta1.NodePoolLabelKey: nodeClaim.Labels[corev1beta1.NodePoolLabelKey],
265265
corev1beta1.ManagedByAnnotationKey: options.FromContext(ctx).ClusterName,
266266
v1beta1.LabelNodeClass: nodeClass.Name,
267+
"Component": nodeClaim.Labels[corev1beta1.NodePoolLabelKey], // used for aws explore
267268
}
268269
return lo.Assign(nodeClass.Spec.Tags, staticTags)
269270
}

0 commit comments

Comments
 (0)