Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove the remainder of the alpha references #840

Merged
merged 4 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 1 addition & 121 deletions pkg/apis/v1alpha5/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,129 +14,9 @@ limitations under the License.

package v1alpha5

import (
"fmt"
"strings"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
)

// Well known labels and resources
const (
ArchitectureAmd64 = "amd64"
ArchitectureArm64 = "arm64"
CapacityTypeSpot = "spot"
CapacityTypeOnDemand = "on-demand"
)

// Karpenter specific domains and labels
const (
ProvisionerNameLabelKey = Group + "/provisioner-name"
LabelNodeInitialized = Group + "/initialized"
LabelNodeRegistered = Group + "/registered"
LabelCapacityType = Group + "/capacity-type"
)

// Karpenter specific annotations
// These are deprecated. These should be removed as part of the migration to v1.
const (
DoNotEvictPodAnnotationKey = Group + "/do-not-evict"
DoNotConsolidateNodeAnnotationKey = Group + "/do-not-consolidate"
EmptinessTimestampAnnotationKey = Group + "/emptiness-timestamp"
MachineLinkedAnnotationKey = Group + "/linked"
MachineManagedByAnnotationKey = Group + "/managed-by"
ProvisionerHashAnnotationKey = Group + "/provisioner-hash"

ProviderCompatabilityAnnotationKey = CompatabilityGroup + "/provider"
)

// Karpenter specific finalizers
const (
TerminationFinalizer = Group + "/termination"
)

var (
// RestrictedLabelDomains are either prohibited by the kubelet or reserved by karpenter
RestrictedLabelDomains = sets.NewString(
"kubernetes.io",
"k8s.io",
Group,
)

// LabelDomainExceptions are sub-domains of the RestrictedLabelDomains but allowed because
// they are not used in a context where they may be passed as argument to kubelet.
LabelDomainExceptions = sets.NewString(
"kops.k8s.io",
v1.LabelNamespaceSuffixNode,
v1.LabelNamespaceNodeRestriction,
)

// WellKnownLabels are labels that belong to the RestrictedLabelDomains but allowed.
// Karpenter is aware of these labels, and they can be used to further narrow down
// the range of the corresponding values by either provisioner or pods.
WellKnownLabels = sets.New(
ProvisionerNameLabelKey,
v1.LabelTopologyZone,
v1.LabelTopologyRegion,
v1.LabelInstanceTypeStable,
v1.LabelArchStable,
v1.LabelOSStable,
LabelCapacityType,
)

// RestrictedLabels are labels that should not be used
// because they may interfere with the internal provisioning logic.
RestrictedLabels = sets.NewString(
EmptinessTimestampAnnotationKey,
v1.LabelHostname,
)

// NormalizedLabels translate aliased concepts into the controller's
// WellKnownLabels. Pod requirements are translated for compatibility.
NormalizedLabels = map[string]string{
v1.LabelFailureDomainBetaZone: v1.LabelTopologyZone,
"beta.kubernetes.io/arch": v1.LabelArchStable,
"beta.kubernetes.io/os": v1.LabelOSStable,
v1.LabelInstanceType: v1.LabelInstanceTypeStable,
v1.LabelFailureDomainBetaRegion: v1.LabelTopologyRegion,
}
)

// IsRestrictedLabel returns an error if the label is restricted.
func IsRestrictedLabel(key string) error {
if WellKnownLabels.Has(key) {
return nil
}
if IsRestrictedNodeLabel(key) {
return fmt.Errorf("label %s is restricted; specify a well known label: %v, or a custom label that does not use a restricted domain: %v", key, sets.List(WellKnownLabels), RestrictedLabelDomains.List())
}
return nil
}

// IsRestrictedNodeLabel returns true if a node label should not be injected by Karpenter.
// They are either known labels that will be injected by cloud providers,
// or label domain managed by other software (e.g., kops.k8s.io managed by kOps).
func IsRestrictedNodeLabel(key string) bool {
if WellKnownLabels.Has(key) {
return true
}
labelDomain := GetLabelDomain(key)
for exceptionLabelDomain := range LabelDomainExceptions {
if strings.HasSuffix(labelDomain, exceptionLabelDomain) {
return false
}
}
for restrictedLabelDomain := range RestrictedLabelDomains {
if strings.HasSuffix(labelDomain, restrictedLabelDomain) {
return true
}
}
return RestrictedLabels.Has(key)
}

func GetLabelDomain(key string) string {
if parts := strings.SplitN(key, "/", 2); len(parts) == 2 {
return parts[0]
}
return ""
}
41 changes: 0 additions & 41 deletions pkg/apis/v1alpha5/limits.go

This file was deleted.

156 changes: 0 additions & 156 deletions pkg/apis/v1alpha5/machine.go

This file was deleted.

66 changes: 0 additions & 66 deletions pkg/apis/v1alpha5/machine_status.go

This file was deleted.

Loading