Skip to content

Commit

Permalink
remaining changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed Jul 12, 2024
1 parent 9f1c018 commit 46bc2ac
Show file tree
Hide file tree
Showing 23 changed files with 119 additions and 103 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ spec:
type: object
type: object
served: true
storage: false
storage: true
subresources:
status: {}
- name: v1beta1
Expand Down Expand Up @@ -1293,7 +1293,7 @@ spec:
type: object
type: object
served: true
storage: true
storage: false
subresources:
status: {}
conversion:
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/crds/karpenter.sh_nodeclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ spec:
- spec
type: object
served: true
storage: false
storage: true
subresources:
status: {}
- additionalPrinterColumns:
Expand Down Expand Up @@ -790,7 +790,7 @@ spec:
- spec
type: object
served: true
storage: true
storage: false
subresources:
status: {}
conversion:
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/crds/karpenter.sh_nodepools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ spec:
- spec
type: object
served: true
storage: false
storage: true
subresources:
status: {}
- additionalPrinterColumns:
Expand Down Expand Up @@ -1068,7 +1068,7 @@ spec:
- spec
type: object
served: true
storage: true
storage: false
subresources:
status: {}
conversion:
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/v1/ec2nodeclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ const (
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
// +kubebuilder:printcolumn:name="Role",type="string",JSONPath=".spec.role",priority=1,description=""
// +kubebuilder:resource:path=ec2nodeclasses,scope=Cluster,categories=karpenter,shortName={ec2nc,ec2ncs}
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
type EC2NodeClass struct {
metav1.TypeMeta `json:",inline"`
Expand Down
26 changes: 13 additions & 13 deletions pkg/apis/v1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func init() {
var (
TerminationFinalizer = apis.Group + "/termination"
AWSToKubeArchitectures = map[string]string{
"x86_64": karpv1.ArchitectureAmd64,
"x86_64": karpv1.ArchitectureAmd64,
karpv1.ArchitectureArm64: karpv1.ArchitectureArm64,
}
WellKnownArchitectures = sets.NewString(
Expand All @@ -75,18 +75,18 @@ var (
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(LabelNodeClass))),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(TagNodeClaim))),
}
AMIFamilyBottlerocket = "Bottlerocket"
AMIFamilyAL2 = "AL2"
AMIFamilyAL2023 = "AL2023"
AMIFamilyUbuntu = "Ubuntu"
AMIFamilyWindows2019 = "Windows2019"
AMIFamilyWindows2022 = "Windows2022"
AMIFamilyCustom = "Custom"
Windows2019 = "2019"
Windows2022 = "2022"
WindowsCore = "Core"
Windows2019Build = "10.0.17763"
Windows2022Build = "10.0.20348"
AMIFamilyBottlerocket = "Bottlerocket"
AMIFamilyAL2 = "AL2"
AMIFamilyAL2023 = "AL2023"
AMIFamilyUbuntu = "Ubuntu"
AMIFamilyWindows2019 = "Windows2019"
AMIFamilyWindows2022 = "Windows2022"
AMIFamilyCustom = "Custom"
Windows2019 = "2019"
Windows2022 = "2022"
WindowsCore = "Core"
Windows2019Build = "10.0.17763"
Windows2022Build = "10.0.20348"
ResourceNVIDIAGPU corev1.ResourceName = "nvidia.com/gpu"
ResourceAMDGPU corev1.ResourceName = "amd.com/gpu"
ResourceAWSNeuron corev1.ResourceName = "aws.amazon.com/neuron"
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/v1beta1/ec2nodeclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ const (

// EC2NodeClass is the Schema for the EC2NodeClass API
// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +kubebuilder:resource:path=ec2nodeclasses,scope=Cluster,categories=karpenter,shortName={ec2nc,ec2ncs}
// +kubebuilder:subresource:status
type EC2NodeClass struct {
Expand Down
26 changes: 13 additions & 13 deletions pkg/apis/v1beta1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func init() {
var (
TerminationFinalizer = apis.Group + "/termination"
AWSToKubeArchitectures = map[string]string{
"x86_64": karpv1beta1.ArchitectureAmd64,
"x86_64": karpv1beta1.ArchitectureAmd64,
karpv1beta1.ArchitectureArm64: karpv1beta1.ArchitectureArm64,
}
WellKnownArchitectures = sets.NewString(
Expand All @@ -75,18 +75,18 @@ var (
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(LabelNodeClass))),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(TagNodeClaim))),
}
AMIFamilyBottlerocket = "Bottlerocket"
AMIFamilyAL2 = "AL2"
AMIFamilyAL2023 = "AL2023"
AMIFamilyUbuntu = "Ubuntu"
AMIFamilyWindows2019 = "Windows2019"
AMIFamilyWindows2022 = "Windows2022"
AMIFamilyCustom = "Custom"
Windows2019 = "2019"
Windows2022 = "2022"
WindowsCore = "Core"
Windows2019Build = "10.0.17763"
Windows2022Build = "10.0.20348"
AMIFamilyBottlerocket = "Bottlerocket"
AMIFamilyAL2 = "AL2"
AMIFamilyAL2023 = "AL2023"
AMIFamilyUbuntu = "Ubuntu"
AMIFamilyWindows2019 = "Windows2019"
AMIFamilyWindows2022 = "Windows2022"
AMIFamilyCustom = "Custom"
Windows2019 = "2019"
Windows2022 = "2022"
WindowsCore = "Core"
Windows2019Build = "10.0.17763"
Windows2022Build = "10.0.20348"
ResourceNVIDIAGPU corev1.ResourceName = "nvidia.com/gpu"
ResourceAMDGPU corev1.ResourceName = "amd.com/gpu"
ResourceAWSNeuron corev1.ResourceName = "aws.amazon.com/neuron"
Expand Down
6 changes: 5 additions & 1 deletion pkg/cloudprovider/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,11 @@ var _ = Describe("CloudProvider", func() {
Tags: []*ec2.Tag{{Key: aws.String("Name"), Value: aws.String("test-subnet-2")}}},
}})
controller := status.NewController(env.Client, awsEnv.SubnetProvider, awsEnv.SecurityGroupProvider, awsEnv.AMIProvider, awsEnv.InstanceProfileProvider, awsEnv.LaunchTemplateProvider)
nodeClass.Spec.Kubelet = &v1.KubeletConfiguration{MaxPods: aws.Int32(1)}
nodeClass.Spec.Kubelet = &v1.KubeletConfiguration{
MaxPods: aws.Int32(1),
}
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
nodeClass = ExpectExists(ctx, env.Client, nodeClass)
ExpectObjectReconciled(ctx, env.Client, controller, nodeClass)
pod1 := coretest.UnschedulablePod(coretest.PodOptions{NodeSelector: map[string]string{corev1.LabelTopologyZone: "test-zone-1a"}})
pod2 := coretest.UnschedulablePod(coretest.PodOptions{NodeSelector: map[string]string{corev1.LabelTopologyZone: "test-zone-1a"}})
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/karpenter/pkg/cloudprovider"

"github.com/aws/karpenter-provider-aws/pkg/apis/v1beta1"
v1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1"
nodeclasshash "github.com/aws/karpenter-provider-aws/pkg/controllers/nodeclass/hash"
nodeclassstatus "github.com/aws/karpenter-provider-aws/pkg/controllers/nodeclass/status"
nodeclasstermination "github.com/aws/karpenter-provider-aws/pkg/controllers/nodeclass/termination"
Expand Down Expand Up @@ -66,7 +66,7 @@ func NewControllers(ctx context.Context, mgr manager.Manager, sess *session.Sess
nodeclaimtagging.NewController(kubeClient, instanceProvider),
controllerspricing.NewController(pricingProvider),
controllersinstancetype.NewController(instanceTypeProvider),
status.NewController[*v1beta1.EC2NodeClass](kubeClient, mgr.GetEventRecorderFor("karpenter")),
status.NewController[*v1.EC2NodeClass](kubeClient, mgr.GetEventRecorderFor("karpenter")),
}
if options.FromContext(ctx).InterruptionQueue != "" {
sqsapi := servicesqs.New(sess)
Expand Down
6 changes: 3 additions & 3 deletions pkg/controllers/interruption/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ var _ = Describe("InterruptionHandling", func() {
})
It("should mark the ICE cache for the offering when getting a spot interruption warning", func() {
nodeClaim.Labels = lo.Assign(nodeClaim.Labels, map[string]string{
corev1.LabelTopologyZone: "coretest-zone-1a",
corev1.LabelInstanceTypeStable: "t3.large",
karpv1.CapacityTypeLabelKey: karpv1.CapacityTypeSpot,
corev1.LabelTopologyZone: "coretest-zone-1a",
corev1.LabelInstanceTypeStable: "t3.large",
karpv1.CapacityTypeLabelKey: karpv1.CapacityTypeSpot,
})
ExpectMessagesCreated(spotInterruptionMessage(lo.Must(utils.ParseInstanceID(nodeClaim.Status.ProviderID))))
ExpectApplied(ctx, env.Client, nodeClaim, node)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/nodeclaim/tagging/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

"github.com/awslabs/operatorpkg/reasonable"

"github.com/aws/karpenter-provider-aws/pkg/apis/v1"
v1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1"
"github.com/aws/karpenter-provider-aws/pkg/providers/instance"
"github.com/aws/karpenter-provider-aws/pkg/utils"

Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/nodeclass/status/ami_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ var _ = Describe("NodeClass AMI Status Controller", func() {
version := lo.Must(awsEnv.VersionProvider.Get(ctx))

awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2/recommended/image_id", version): "ami-id-123",
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2-gpu/recommended/image_id", version): "ami-id-456",
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2/recommended/image_id", version): "ami-id-123",
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2-gpu/recommended/image_id", version): "ami-id-456",
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2%s/recommended/image_id", version, fmt.Sprintf("-%s", karpv1.ArchitectureArm64)): "ami-id-789",
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"

karpv1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1"
karpv1 "sigs.k8s.io/karpenter/pkg/apis/v1"
karpv1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1"
"sigs.k8s.io/karpenter/pkg/operator"

awscache "github.com/aws/karpenter-provider-aws/pkg/cache"
Expand Down
13 changes: 6 additions & 7 deletions pkg/providers/amifamily/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/imdario/mergo"
"github.com/samber/lo"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -208,14 +207,14 @@ func (r Resolver) defaultClusterDNS(opts *Options, kubeletConfig *v1.KubeletConf

func (r Resolver) resolveLaunchTemplate(nodeClass *v1.EC2NodeClass, nodeClaim *karpv1.NodeClaim, instanceTypes []*cloudprovider.InstanceType, capacityType string,
amiFamily AMIFamily, amiID string, maxPods int, efaCount int, options *Options) (*LaunchTemplate, error) {
kubeletConfig := &v1.KubeletConfiguration{}
if kc, err := utils.GetKubeletConfigurationWithNodeClaim(nodeClaim, nodeClass); err != nil {
kubeletConfig, err := utils.GetKubeletConfigurationWithNodeClaim(nodeClaim, nodeClass)
if err != nil {
return nil, fmt.Errorf("resolving kubelet configuration, %w", err)
} else if kc != nil {
if err := mergo.Merge(kubeletConfig, kc); err != nil {
return nil, err
}
}
if kubeletConfig == nil {
kubeletConfig = &v1.KubeletConfiguration{}
}
fmt.Printf("resolved kubelet config with maxPods %d\n", lo.FromPtr(kubeletConfig.MaxPods))
if kubeletConfig.MaxPods == nil {
kubeletConfig.MaxPods = lo.ToPtr(int32(maxPods))
}
Expand Down
Loading

0 comments on commit 46bc2ac

Please sign in to comment.