v1alpha1

package
v0.0.0-...-571e284 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

+k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +groupName=karpenter.k8s.gcp

Index

Constants

View Source
const (
	KubeletMaxPods = 110

	// We need to bump the GCENodeClassHashVersion when we make an update to the GCENodeClass CRD under these conditions:
	// 1. A field changes its default value for an existing field that is already hashed
	// 2. A field is added to the hash calculation with an already-set value
	// 3. A field is removed from the hash calculations
	GCENodeClassHashVersion = "v3"
)
View Source
const (
	ConditionTypeSecurityGroupsReady = "SecurityGroupsReady"
	ConditionTypeInstanceRAMReady    = "InstanceRAMReady"
)

Variables

View Source
var (
	TerminationFinalizer   = apis.Group + "/termination"
	GCPToKubeArchitectures = map[string]string{
		"x86_64": karpv1.ArchitectureAmd64,
		"arm64":  karpv1.ArchitectureArm64,
	}
	WellKnownArchitectures = sets.NewString(
		karpv1.ArchitectureAmd64,
		karpv1.ArchitectureArm64,
	)
	RestrictedLabelDomains = []string{
		apis.Group,
	}
	RestrictedTagPatterns = []*regexp.Regexp{

		regexp.MustCompile(`^kubernetes\.io/cluster/[0-9A-Za-z][A-Za-z0-9\-_]*$`),
		regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(karpv1.NodePoolLabelKey))),
		regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(GCEClusterIDTagKey))),
		regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(LabelNodeClass))),
		regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(TagNodeClaim))),
	}

	ResourceNVIDIAGPU  corev1.ResourceName = "nvidia.com/gpu"
	ResourceAMDGPU     corev1.ResourceName = "amd.com/gpu"
	GCEClusterIDTagKey                     = "gce:gce-cluster-id"

	LabelNodeClass                           = apis.Group + "/gcenodeclass"
	LabelTopologyZoneID                      = "topology.k8s.gcp/zone-id"
	LabelInstanceCategory                    = apis.Group + "/instance-category"
	LabelInstanceFamily                      = apis.Group + "/instance-family"
	LabelInstanceGeneration                  = apis.Group + "/instance-generation"
	LabelInstanceSize                        = apis.Group + "/instance-size"
	LabelInstanceCPU                         = apis.Group + "/instance-cpu"
	LabelInstanceCPUModel                    = apis.Group + "/instance-cpu-model"
	LabelInstanceMemory                      = apis.Group + "/instance-memory"
	LabelInstanceGPUName                     = apis.Group + "/instance-gpu-name"
	LabelInstanceGPUManufacturer             = apis.Group + "/instance-gpu-manufacturer"
	LabelInstanceGPUCount                    = apis.Group + "/instance-gpu-count"
	LabelInstanceGPUMemory                   = apis.Group + "/instance-gpu-memory"
	AnnotationGCENodeClassHash               = apis.Group + "/gcenodeclass-hash"
	AnnotationClusterNameTaggedCompatability = apis.CompatibilityGroup + "/cluster-name-tagged"
	AnnotationGCENodeClassHashVersion        = apis.Group + "/gcenodeclass-hash-version"
	AnnotationInstanceTagged                 = apis.Group + "/tagged"

	TagNodeClaim = coreapis.Group + "/nodeclaim"
	TagName      = "Name"
)

Functions

func ImageFamilyFromAlias

func ImageFamilyFromAlias(alias string) string

Types

type GCENodeClass

type GCENodeClass struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   GCENodeClassSpec   `json:"spec,omitempty"`
	Status GCENodeClassStatus `json:"status,omitempty"`
}

GCENodeClass is the Schema for the GCENodeClass API +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +kubebuilder:resource:path=gcenodeclasses,scope=Cluster,categories=karpenter,shortName={gcenc,gcencs} +kubebuilder:subresource:status

func (*GCENodeClass) DeepCopy

func (in *GCENodeClass) DeepCopy() *GCENodeClass

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCENodeClass.

func (*GCENodeClass) DeepCopyInto

func (in *GCENodeClass) DeepCopyInto(out *GCENodeClass)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*GCENodeClass) DeepCopyObject

func (in *GCENodeClass) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*GCENodeClass) GetConditions

func (in *GCENodeClass) GetConditions() []status.Condition

func (*GCENodeClass) Hash

func (in *GCENodeClass) Hash() string

func (*GCENodeClass) SetConditions

func (in *GCENodeClass) SetConditions(conditions []status.Condition)

func (*GCENodeClass) SetDefaults

func (in *GCENodeClass) SetDefaults(_ context.Context)

func (*GCENodeClass) StatusConditions

func (in *GCENodeClass) StatusConditions() status.ConditionSet

type GCENodeClassList

type GCENodeClassList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []GCENodeClass `json:"items"`
}

GCENodeClassList contains a list of GCENodeClass +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*GCENodeClassList) DeepCopy

func (in *GCENodeClassList) DeepCopy() *GCENodeClassList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCENodeClassList.

func (*GCENodeClassList) DeepCopyInto

func (in *GCENodeClassList) DeepCopyInto(out *GCENodeClassList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*GCENodeClassList) DeepCopyObject

func (in *GCENodeClassList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type GCENodeClassSpec

type GCENodeClassSpec struct {
	// SecurityGroupSelectorTerms is a list of or security group selector terms. The terms are ORed.
	// +kubebuilder:validation:XValidation:message="securityGroupSelectorTerms cannot be empty",rule="self.size() != 0"
	// +kubebuilder:validation:XValidation:message="expected at least one, got none, ['tags', 'id', 'name']",rule="self.all(x, has(x.tags) || has(x.id) || has(x.name))"
	// +kubebuilder:validation:XValidation:message="'id' is mutually exclusive, cannot be set with a combination of other fields in securityGroupSelectorTerms",rule="!self.all(x, has(x.id) && (has(x.tags) || has(x.name)))"
	// +kubebuilder:validation:XValidation:message="'name' is mutually exclusive, cannot be set with a combination of other fields in securityGroupSelectorTerms",rule="!self.all(x, has(x.name) && (has(x.tags) || has(x.id)))"
	// +kubebuilder:validation:MaxItems:=30
	// +required
	SecurityGroupSelectorTerms []SecurityGroupSelectorTerm `json:"securityGroupSelectorTerms" hash:"ignore"`
	// KubeletConfiguration defines args to be used when configuring kubelet on provisioned nodes.
	// They are a vswitch of the upstream types, recognizing not all options may be supported.
	// Wherever possible, the types and names should reflect the upstream kubelet types.
	// +kubebuilder:validation:XValidation:message="imageGCHighThresholdPercent must be greater than imageGCLowThresholdPercent",rule="has(self.imageGCHighThresholdPercent) && has(self.imageGCLowThresholdPercent) ?  self.imageGCHighThresholdPercent > self.imageGCLowThresholdPercent  : true"
	// +kubebuilder:validation:XValidation:message="evictionSoft OwnerKey does not have a matching evictionSoftGracePeriod",rule="has(self.evictionSoft) ? self.evictionSoft.all(e, (e in self.evictionSoftGracePeriod)):true"
	// +kubebuilder:validation:XValidation:message="evictionSoftGracePeriod OwnerKey does not have a matching evictionSoft",rule="has(self.evictionSoftGracePeriod) ? self.evictionSoftGracePeriod.all(e, (e in self.evictionSoft)):true"
	// +optional
	KubeletConfiguration *KubeletConfiguration `json:"kubeletConfiguration,omitempty"`
	// Tags to be applied on gce resources like instances and launch templates.
	// +kubebuilder:validation:XValidation:message="empty tag keys aren't supported",rule="self.all(k, k != ”)"
	// +kubebuilder:validation:XValidation:message="tag contains a restricted tag matching gce:gce-cluster-name",rule="self.all(k, k !='gce:gce-cluster-name')"
	// +kubebuilder:validation:XValidation:message="tag contains a restricted tag matching kubernetes.io/cluster/",rule="self.all(k, !k.startsWith('kubernetes.io/cluster') )"
	// +kubebuilder:validation:XValidation:message="tag contains a restricted tag matching karpenter.sh/nodepool",rule="self.all(k, k != 'karpenter.sh/nodepool')"
	// +kubebuilder:validation:XValidation:message="tag contains a restricted tag matching karpenter.sh/nodeclaim",rule="self.all(k, k !='karpenter.sh/nodeclaim')"
	// +kubebuilder:validation:XValidation:message="tag contains a restricted tag matching karpenter.k8s.gcp/gcenodeclass",rule="self.all(k, k !='karpenter.k8s.gcp/gcenodeclass')"
	// +optional
	Tags map[string]string `json:"tags,omitempty"`
	// ResourceGroupID is the resource group id in GCE
	// +kubebuilder:validation:Pattern:="rg-[0-9a-z]+"
	// +optional
	ResourceGroupID string `json:"resourceGroupId,omitempty"`
}

GCENodeClassSpec is the top level specification for the GCP Karpenter Provider. This will contain the configuration necessary to launch instances in GCP.

func (*GCENodeClassSpec) DeepCopy

func (in *GCENodeClassSpec) DeepCopy() *GCENodeClassSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCENodeClassSpec.

func (*GCENodeClassSpec) DeepCopyInto

func (in *GCENodeClassSpec) DeepCopyInto(out *GCENodeClassSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type GCENodeClassStatus

type GCENodeClassStatus struct {
	// SecurityGroups contains the current Security Groups values that are available to the
	// cluster under the SecurityGroups selectors.
	// +optional
	SecurityGroups []SecurityGroup `json:"securityGroups,omitempty"`
	// Conditions contains signals for health and readiness
	// +optional
	Conditions []status.Condition `json:"conditions,omitempty"`
}

GCENodeClassStatus contains the resolved state of the GCENodeClass

func (*GCENodeClassStatus) DeepCopy

func (in *GCENodeClassStatus) DeepCopy() *GCENodeClassStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCENodeClassStatus.

func (*GCENodeClassStatus) DeepCopyInto

func (in *GCENodeClassStatus) DeepCopyInto(out *GCENodeClassStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type KubeletConfiguration

type KubeletConfiguration struct {
	// clusterDNS is a list of IP addresses for the cluster DNS server.
	// Note that not all providers may use all addresses.
	//+optional
	ClusterDNS []string `json:"clusterDNS,omitempty"`
	// MaxPods is an override for the maximum number of pods that can run on
	// a worker node instance.
	// +kubebuilder:validation:Minimum:=0
	// +optional
	MaxPods *int32 `json:"maxPods,omitempty"`
	// PodsPerCore is an override for the number of pods that can run on a worker node
	// instance based on the number of cpu cores. This value cannot exceed MaxPods, so, if
	// MaxPods is a lower value, that value will be used.
	// +kubebuilder:validation:Minimum:=0
	// +optional
	PodsPerCore *int32 `json:"podsPerCore,omitempty"`
	// SystemReserved contains resources reserved for OS system daemons and kernel memory.
	// +kubebuilder:validation:XValidation:message="valid keys for systemReserved are ['cpu','memory','ephemeral-storage','pid']",rule="self.all(x, x=='cpu' || x=='memory' || x=='ephemeral-storage' || x=='pid')"
	// +kubebuilder:validation:XValidation:message="systemReserved value cannot be a negative resource quantity",rule="self.all(x, !self[x].startsWith('-'))"
	// +optional
	SystemReserved map[string]string `json:"systemReserved,omitempty"`
	// KubeReserved contains resources reserved for Kubernetes system components.
	// +kubebuilder:validation:XValidation:message="valid keys for kubeReserved are ['cpu','memory','ephemeral-storage','pid']",rule="self.all(x, x=='cpu' || x=='memory' || x=='ephemeral-storage' || x=='pid')"
	// +kubebuilder:validation:XValidation:message="kubeReserved value cannot be a negative resource quantity",rule="self.all(x, !self[x].startsWith('-'))"
	// +optional
	KubeReserved map[string]string `json:"kubeReserved,omitempty"`
	// EvictionHard is the map of signal names to quantities that define hard eviction thresholds
	// +kubebuilder:validation:XValidation:message="valid keys for evictionHard are ['memory.available','nodefs.available','nodefs.inodesFree','imagefs.available','imagefs.inodesFree','pid.available']",rule="self.all(x, x in ['memory.available','nodefs.available','nodefs.inodesFree','imagefs.available','imagefs.inodesFree','pid.available'])"
	// +optional
	EvictionHard map[string]string `json:"evictionHard,omitempty"`
	// EvictionSoft is the map of signal names to quantities that define soft eviction thresholds
	// +kubebuilder:validation:XValidation:message="valid keys for evictionSoft are ['memory.available','nodefs.available','nodefs.inodesFree','imagefs.available','imagefs.inodesFree','pid.available']",rule="self.all(x, x in ['memory.available','nodefs.available','nodefs.inodesFree','imagefs.available','imagefs.inodesFree','pid.available'])"
	// +optional
	EvictionSoft map[string]string `json:"evictionSoft,omitempty"`
	// EvictionSoftGracePeriod is the map of signal names to quantities that define grace periods for each eviction signal
	// +kubebuilder:validation:XValidation:message="valid keys for evictionSoftGracePeriod are ['memory.available','nodefs.available','nodefs.inodesFree','imagefs.available','imagefs.inodesFree','pid.available']",rule="self.all(x, x in ['memory.available','nodefs.available','nodefs.inodesFree','imagefs.available','imagefs.inodesFree','pid.available'])"
	// +optional
	EvictionSoftGracePeriod map[string]metav1.Duration `json:"evictionSoftGracePeriod,omitempty"`
	// EvictionMaxPodGracePeriod is the maximum allowed grace period (in seconds) to use when terminating pods in
	// response to soft eviction thresholds being met.
	// +optional
	EvictionMaxPodGracePeriod *int32 `json:"evictionMaxPodGracePeriod,omitempty"`
	// ImageGCHighThresholdPercent is the percent of disk usage after which image
	// garbage collection is always run. The percent is calculated by dividing this
	// field value by 100, so this field must be between 0 and 100, inclusive.
	// When specified, the value must be greater than ImageGCLowThresholdPercent.
	// +kubebuilder:validation:Minimum:=0
	// +kubebuilder:validation:Maximum:=100
	// +optional
	ImageGCHighThresholdPercent *int32 `json:"imageGCHighThresholdPercent,omitempty"`
	// ImageGCLowThresholdPercent is the percent of disk usage before which image
	// garbage collection is never run. Lowest disk usage to garbage collect to.
	// The percent is calculated by dividing this field value by 100,
	// so the field value must be between 0 and 100, inclusive.
	// When specified, the value must be less than imageGCHighThresholdPercent
	// +kubebuilder:validation:Minimum:=0
	// +kubebuilder:validation:Maximum:=100
	// +optional
	ImageGCLowThresholdPercent *int32 `json:"imageGCLowThresholdPercent,omitempty"`
	// CPUCFSQuota enables CPU CFS quota enforcement for containers that specify CPU limits.
	// +optional
	CPUCFSQuota *bool `json:"cpuCFSQuota,omitempty"`
}

KubeletConfiguration defines args to be used when configuring kubelet on provisioned nodes. They are a vswitch of the upstream types, recognizing not all options may be supported. Wherever possible, the types and names should reflect the upstream kubelet types. https://pkg.go.dev/k8s.io/kubelet/config/v1beta1#KubeletConfiguration https://github.com/kubernetes/kubernetes/blob/9f82d81e55cafdedab619ea25cabf5d42736dacf/cmd/kubelet/app/options/options.go#L53

func (*KubeletConfiguration) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfiguration.

func (*KubeletConfiguration) DeepCopyInto

func (in *KubeletConfiguration) DeepCopyInto(out *KubeletConfiguration)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SecurityGroup

type SecurityGroup struct {
	// ID of the security group
	// +required
	ID string `json:"id"`
	// Name of the security group
	// +optional
	Name string `json:"name,omitempty"`
}

SecurityGroup contains resolved SecurityGroup selector values utilized for node launch

func (*SecurityGroup) DeepCopy

func (in *SecurityGroup) DeepCopy() *SecurityGroup

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityGroup.

func (*SecurityGroup) DeepCopyInto

func (in *SecurityGroup) DeepCopyInto(out *SecurityGroup)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SecurityGroupSelectorTerm

type SecurityGroupSelectorTerm struct {
	// Tags is a map of key/value tags used to select vSwitches
	// Specifying '*' for a value selects all values for a given tag key.
	// +kubebuilder:validation:XValidation:message="empty tag keys aren't supported",rule="self.all(k, k != ”)"
	// +kubebuilder:validation:MaxProperties:=20
	// +optional
	Tags map[string]string `json:"tags,omitempty"`
	// ID is the security group id in GCE
	// +kubebuilder:validation:Pattern:="sg-[0-9a-z]+"
	// +optional
	ID string `json:"id,omitempty"`
	// Name is the security group name in GCE.
	// This value is the name field, which is different from the name tag.
	Name string `json:"name,omitempty"`
}

SecurityGroupSelectorTerm defines selection logic for a security group used by Karpenter to launch nodes. If multiple fields are used for selection, the requirements are ANDed.

func (*SecurityGroupSelectorTerm) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityGroupSelectorTerm.

func (*SecurityGroupSelectorTerm) DeepCopyInto

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL