Skip to content

Commit

Permalink
Create v1beta1 APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Aug 9, 2023
1 parent e658971 commit 7eb92cc
Show file tree
Hide file tree
Showing 19 changed files with 2,891 additions and 5 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ coverage:
verify: tidy download ## Verify code. Includes dependencies, linting, formatting, etc
go generate ./...
hack/boilerplate.sh
cp $(KARPENTER_CORE_DIR)/pkg/apis/crds/karpenter.sh_machines.yaml \
$(KARPENTER_CORE_DIR)/pkg/apis/crds/karpenter.sh_provisioners.yaml \
pkg/apis/crds
cp $(KARPENTER_CORE_DIR)/pkg/apis/crds/* pkg/apis/crds
$(foreach dir,$(MOD_DIRS),cd $(dir) && golangci-lint run $(newline))
@git diff --quiet ||\
{ echo "New file modification detected in the Git working tree. Please check in before commit."; git --no-pager diff --name-only | uniq | awk '{print " - " $$0}'; \
Expand Down
1 change: 0 additions & 1 deletion charts/karpenter/crds

This file was deleted.

1 change: 1 addition & 0 deletions charts/karpenter/crds/karpenter.sh_machines.yaml
1 change: 1 addition & 0 deletions charts/karpenter/crds/karpenter.sh_provisioners.yaml
9 changes: 8 additions & 1 deletion pkg/apis/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/aws/karpenter-core/pkg/operator/scheme"
"github.com/aws/karpenter/pkg/apis/settings"
"github.com/aws/karpenter/pkg/apis/v1beta1"

"github.com/samber/lo"

Expand All @@ -36,6 +37,7 @@ var (
// Builder includes all types within the apis package
Builder = runtime.NewSchemeBuilder(
v1alpha1.SchemeBuilder.AddToScheme,
v1beta1.SchemeBuilder.AddToScheme,
)
// AddToScheme may be used to add all resources defined in the project to a Scheme
AddToScheme = Builder.AddToScheme
Expand All @@ -46,7 +48,12 @@ var (
var (
//go:embed crds/karpenter.k8s.aws_awsnodetemplates.yaml
AWSNodeTemplateCRD []byte
CRDs = append(apis.CRDs, lo.Must(functional.Unmarshal[v1.CustomResourceDefinition](AWSNodeTemplateCRD)))
//go:embed crds/compute.k8s.aws_nodeclasses.yaml
NodeClassCRD []byte
CRDs = append(apis.CRDs,
lo.Must(functional.Unmarshal[v1.CustomResourceDefinition](AWSNodeTemplateCRD)),
lo.Must(functional.Unmarshal[v1.CustomResourceDefinition](NodeClassCRD)),
)
)

func init() {
Expand Down
357 changes: 357 additions & 0 deletions pkg/apis/crds/compute.k8s.aws_nodeclasses.yaml

Large diffs are not rendered by default.

359 changes: 359 additions & 0 deletions pkg/apis/crds/karpenter.sh_nodeclaims.yaml

Large diffs are not rendered by default.

374 changes: 374 additions & 0 deletions pkg/apis/crds/karpenter.sh_nodepools.yaml

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions pkg/apis/v1beta1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
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.
*/

// +k8s:openapi-gen=true
// +k8s:deepcopy-gen=package,register
// +k8s:defaulter-gen=TypeMeta
// +groupName=compute.k8s.aws
package v1beta1 // doc.go is discovered by codegen
122 changes: 122 additions & 0 deletions pkg/apis/v1beta1/labels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
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 (
"fmt"
"regexp"

"github.com/aws/aws-sdk-go/service/ec2"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"

"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
"github.com/aws/karpenter-core/pkg/apis/v1beta1"
)

func init() {
v1beta1.RestrictedLabelDomains = v1beta1.RestrictedLabelDomains.Insert(RestrictedLabelDomains...)
v1beta1.WellKnownLabels = v1beta1.WellKnownLabels.Insert(
LabelInstanceHypervisor,
LabelInstanceEncryptionInTransitSupported,
LabelInstanceCategory,
LabelInstanceFamily,
LabelInstanceGeneration,
LabelInstanceSize,
LabelInstanceLocalNVME,
LabelInstanceCPU,
LabelInstanceMemory,
LabelInstanceNetworkBandwidth,
LabelInstancePods,
LabelInstanceGPUName,
LabelInstanceGPUManufacturer,
LabelInstanceGPUCount,
LabelInstanceGPUMemory,
LabelInstanceAcceleratorName,
LabelInstanceAcceleratorManufacturer,
LabelInstanceAcceleratorCount,
v1.LabelWindowsBuild,
)
}

var (
CapacityTypeSpot = ec2.DefaultTargetCapacityTypeSpot
CapacityTypeOnDemand = ec2.DefaultTargetCapacityTypeOnDemand
AWSToKubeArchitectures = map[string]string{
"x86_64": v1beta1.ArchitectureAmd64,
v1beta1.ArchitectureArm64: v1beta1.ArchitectureArm64,
}
WellKnownArchitectures = sets.NewString(
v1beta1.ArchitectureAmd64,
v1beta1.ArchitectureArm64,
)
RestrictedLabelDomains = []string{
Group,
}
RestrictedTagPatterns = []*regexp.Regexp{
// Adheres to cluster name pattern matching as specified in the API spec
// https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateCluster.html
regexp.MustCompile(`^kubernetes\.io/cluster/[0-9A-Za-z][A-Za-z0-9\-_]*$`),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(v1alpha5.ProvisionerNameLabelKey))),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(v1alpha5.MachineManagedByAnnotationKey))),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(v1beta1.NodePoolLabelKey))),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(v1beta1.ManagedByAnnotationKey))),
}
AMIFamilyBottlerocket = "Bottlerocket"
AMIFamilyAL2 = "AL2"
AMIFamilyUbuntu = "Ubuntu"
AMIFamilyWindows2019 = "Windows2019"
AMIFamilyWindows2022 = "Windows2022"
AMIFamilyCustom = "Custom"
SupportedAMIFamilies = []string{
AMIFamilyBottlerocket,
AMIFamilyAL2,
AMIFamilyUbuntu,
AMIFamilyWindows2019,
AMIFamilyWindows2022,
AMIFamilyCustom,
}
Windows2019 = "2019"
Windows2022 = "2022"
WindowsCore = "Core"
Windows2019Build = "10.0.17763"
Windows2022Build = "10.0.20348"
ResourceNVIDIAGPU v1.ResourceName = "nvidia.com/gpu"
ResourceAMDGPU v1.ResourceName = "amd.com/gpu"
ResourceAWSNeuron v1.ResourceName = "aws.amazon.com/neuron"
ResourceHabanaGaudi v1.ResourceName = "habana.ai/gaudi"
ResourceAWSPodENI v1.ResourceName = "vpc.amazonaws.com/pod-eni"
ResourcePrivateIPv4Address v1.ResourceName = "vpc.amazonaws.com/PrivateIPv4Address"

LabelInstanceHypervisor = Group + "/instance-hypervisor"
LabelInstanceEncryptionInTransitSupported = Group + "/instance-encryption-in-transit-supported"
LabelInstanceCategory = Group + "/instance-category"
LabelInstanceFamily = Group + "/instance-family"
LabelInstanceGeneration = Group + "/instance-generation"
LabelInstanceLocalNVME = Group + "/instance-local-nvme"
LabelInstanceSize = Group + "/instance-size"
LabelInstanceCPU = Group + "/instance-cpu"
LabelInstanceMemory = Group + "/instance-memory"
LabelInstanceNetworkBandwidth = Group + "/instance-network-bandwidth"
LabelInstancePods = Group + "/instance-pods"
LabelInstanceGPUName = Group + "/instance-gpu-name"
LabelInstanceGPUManufacturer = Group + "/instance-gpu-manufacturer"
LabelInstanceGPUCount = Group + "/instance-gpu-count"
LabelInstanceGPUMemory = Group + "/instance-gpu-memory"
LabelInstanceAcceleratorName = Group + "/instance-accelerator-name"
LabelInstanceAcceleratorManufacturer = Group + "/instance-accelerator-manufacturer"
LabelInstanceAcceleratorCount = Group + "/instance-accelerator-count"
AnnotationNodeClassHash = Group + "/nodeclass-hash"
)
Loading

0 comments on commit 7eb92cc

Please sign in to comment.