-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implemented NodeOverlay with support for custom pricing
- Loading branch information
Showing
21 changed files
with
542 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.15.0 | ||
name: nodeoverlays.karpenter.sh | ||
spec: | ||
group: karpenter.sh | ||
names: | ||
categories: | ||
- karpenter | ||
kind: NodeOverlay | ||
listKind: NodeOverlayList | ||
plural: nodeoverlays | ||
singular: nodeoverlay | ||
scope: Cluster | ||
versions: | ||
- name: v1beta1 | ||
schema: | ||
openAPIV3Schema: | ||
properties: | ||
apiVersion: | ||
description: |- | ||
APIVersion defines the versioned schema of this representation of an object. | ||
Servers should convert recognized schemas to the latest internal value, and | ||
may reject unrecognized values. | ||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | ||
type: string | ||
kind: | ||
description: |- | ||
Kind is a string value representing the REST resource this object represents. | ||
Servers may infer this from the endpoint the client submits requests to. | ||
Cannot be updated. | ||
In CamelCase. | ||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
properties: | ||
pricePercent: | ||
description: PricePercent modifies the price of the simulated node | ||
(PriceAdjustment + (Price * PricePercent / 100)). | ||
type: integer | ||
selector: | ||
description: Selector matches against simulated nodes and modifies | ||
their scheduling properties. Matches all if empty. | ||
items: | ||
description: |- | ||
A node selector requirement is a selector that contains values, a key, and an operator | ||
that relates the key and values. | ||
properties: | ||
key: | ||
description: The label key that the selector applies to. | ||
type: string | ||
operator: | ||
description: |- | ||
Represents a key's relationship to a set of values. | ||
Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. | ||
type: string | ||
values: | ||
description: |- | ||
An array of string values. If the operator is In or NotIn, | ||
the values array must be non-empty. If the operator is Exists or DoesNotExist, | ||
the values array must be empty. If the operator is Gt or Lt, the values | ||
array must have a single element, which will be interpreted as an integer. | ||
This array is replaced during a strategic merge patch. | ||
items: | ||
type: string | ||
type: array | ||
x-kubernetes-list-type: atomic | ||
required: | ||
- key | ||
- operator | ||
type: object | ||
type: array | ||
type: object | ||
required: | ||
- spec | ||
type: object | ||
served: true | ||
storage: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
Copyright The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1beta1 | ||
|
||
import ( | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +kubebuilder:object:root=true | ||
type NodeOverlayList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NodeOverlay `json:"items"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:path=nodeoverlays,scope=Cluster,categories=karpenter | ||
type NodeOverlay struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// +required | ||
Spec NodeOverlaySpec `json:"spec"` | ||
} | ||
|
||
type NodeOverlaySpec struct { | ||
// Selector matches against simulated nodes and modifies their scheduling properties. Matches all if empty. | ||
// +optional | ||
Selector []v1.NodeSelectorRequirement `json:"selector,omitempty"` | ||
// PricePercent modifies the price of the simulated node (PriceAdjustment + (Price * PricePercent / 100)). | ||
// +optional | ||
PricePercent *int `json:"pricePercent,omitempty"` | ||
|
||
// | ||
// The following fields are not yet implemented | ||
// | ||
|
||
// PriceAdjustment modifies the price of the simulated node (PriceAdjustment + (Price * PricePercent / 100)). | ||
// +optional | ||
// PriceAdjustment *int `json:"priceAdjustment,omitempty"` | ||
|
||
// Requirements add additional scheduling requirements to the Node, which may be targeted by pod scheduling constraints | ||
// This feature is not currently implemented | ||
// +optional | ||
// Requirements []v1.NodeSelectorRequirement `json:"requirements,omitempty"` | ||
|
||
// Capacity adds resource capacities to the simulated Node, but will not replace existing values. | ||
// This feature is not currently implemented | ||
// +optional | ||
// Capacity v1.ResourceList | ||
|
||
// Overhead subtracts resources from the simulated Node | ||
// This feature is not currently implemented | ||
// +optional | ||
// Overhead v1.ResourceList `json:"overhead,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
# Reduce on-demand prices to 90% | ||
# https://github.com/aws/karpenter-provider-aws/issues/3860 | ||
# https://github.com/aws/karpenter-provider-aws/pull/4697 | ||
kind: NodeOverlay | ||
metadata: | ||
name: discount | ||
spec: | ||
selector: | ||
matchLabels: | ||
karpenter.sh/capacity-type: on-demand | ||
pricePercent: 90 | ||
--- | ||
# Support for extended resource types (e.g. smarter-devices/fuse) | ||
# https://github.com/kubernetes-sigs/karpenter/issues/751 | ||
https://github.com/kubernetes-sigs/karpenter/issues/729 | ||
kind: NodeOverlay | ||
metadata: | ||
name: discount | ||
spec: | ||
selector: | ||
matchLabels: | ||
karpenter.sh/capacity-type: on-demand | ||
matchExpressions: | ||
- key: node.kubernetes.io/instance-type | ||
operator: In | ||
values: | ||
- m5.large | ||
- m5.2xlarge | ||
- m5.4xlarge | ||
- m5.8xlarge | ||
- m5.12xlarge | ||
capacity: | ||
smarter-devices/fuse: 1 | ||
--- | ||
# Add memory overhead of 10Mi to all instances with 2Gi memory | ||
# https://github.com/aws/karpenter-provider-aws/issues/5161 | ||
kind: NodeOverlay | ||
metadata: | ||
name: discount | ||
spec: | ||
selector: | ||
matchLabels: | ||
karpenter.k8s.aws/instance-memory: 2048 | ||
overhead: | ||
memory: 10Mi | ||
--- |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.