lifted

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package lifted contains the files lifted from other projects.

Index

Constants

View Source
const (
	// MaxPeriodSeconds is the largest allowed scaling policy period (in seconds)
	MaxPeriodSeconds int32 = 1800
	// MaxStabilizationWindowSeconds is the largest allowed stabilization window (in seconds)
	MaxStabilizationWindowSeconds int32 = 3600
)
View Source
const DefaultCPUUtilization = 80

DefaultCPUUtilization is the default value for CPU utilization, provided no other metrics are present. This is here because it's used by both the v2beta1 defaulting logic, and the pseudo-defaulting done in v1 conversion.

View Source
const (
	// NodeUnreachablePodReason is the reason on a pod when its state cannot be confirmed as kubelet is unresponsive
	// on the node it is (was) running.
	NodeUnreachablePodReason = "NodeLost"
)
View Source
const (
	// SecretsField indicates the 'secrets' field of a service account
	SecretsField = "secrets"
)

Variables

ValidatePodName can be used to check whether the given pod name is valid. Prefix indicates this name will be used as part of generation, in which case trailing dashes are allowed.

Functions

func AddCoreV1Handlers added in v1.9.0

func AddCoreV1Handlers(h printers.PrintHandler)

AddCoreV1Handlers adds print handlers for core with v1 versions.

func EqualIgnoreHash added in v1.2.0

func EqualIgnoreHash(template1, template2 *corev1.PodTemplateSpec) bool

EqualIgnoreHash returns true if two given podTemplateSpec are equal, ignoring the diff in value of Labels[pod-template-hash] We ignore pod-template-hash because:

  1. The hash result would be different upon podTemplateSpec API changes (e.g. the addition of a new field will cause the hash code to change)
  2. The deployment template won't have hash labels

func FindNewReplicaSet added in v1.2.0

func FindNewReplicaSet(deployment *appsv1.Deployment, rsList []*appsv1.ReplicaSet) *appsv1.ReplicaSet

FindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template).

func GenerateHPAScaleDownRules added in v1.6.0

func GenerateHPAScaleDownRules(scalingRules *autoscalingv2.HPAScalingRules) *autoscalingv2.HPAScalingRules

GenerateHPAScaleDownRules returns a fully-initialized HPAScalingRules value We guarantee that no pointer in the structure will have the 'nil' value EXCEPT StabilizationWindowSeconds, for reasoning check the comment for defaultHPAScaleDownRules

func GenerateHPAScaleUpRules added in v1.6.0

func GenerateHPAScaleUpRules(scalingRules *autoscalingv2.HPAScalingRules) *autoscalingv2.HPAScalingRules

GenerateHPAScaleUpRules returns a fully-initialized HPAScalingRules value We guarantee that no pointer in the structure will have the 'nil' value

func GetDeletableResources added in v1.2.0

func GetDeletableResources(discoveryClient discovery.ServerResourcesInterface) map[schema.GroupVersionResource]struct{}

GetDeletableResources returns all resources from discoveryClient that the garbage collector should recognize and work with. More specifically, all preferred resources which support the 'delete', 'list', and 'watch' verbs.

All discovery errors are considered temporary. Upon encountering any error, GetDeletableResources will log and return any discovered resources it was able to process (which may be none).

func GetNewReplicaSet added in v1.2.0

func GetNewReplicaSet(deployment *appsv1.Deployment, f RsListFunc) (*appsv1.ReplicaSet, error)

GetNewReplicaSet returns a replica set that matches the intent of the given deployment; get ReplicaSetList from client interface. Returns nil if the new replica set doesn't exist yet.

func GetPodFromTemplate added in v1.2.0

func GetPodFromTemplate(template *corev1.PodTemplateSpec, parentObject runtime.Object, controllerRef *metav1.OwnerReference) (*corev1.Pod, error)

GetPodFromTemplate generates pod object from a template.

func IsAttachableVolumeResourceName added in v1.2.0

func IsAttachableVolumeResourceName(name corev1.ResourceName) bool

IsAttachableVolumeResourceName returns true when the resource name is prefixed in attachable volume

func IsExtendedResourceName added in v1.2.0

func IsExtendedResourceName(name corev1.ResourceName) bool

IsExtendedResourceName returns true if: 1. the resource name is not in the default namespace; 2. resource name does not have "requests." prefix, to avoid confusion with the convention in quota 3. it satisfies the rules in IsQualifiedName() after converted into quota resource name

func IsHugePageResourceName added in v1.2.0

func IsHugePageResourceName(name corev1.ResourceName) bool

IsHugePageResourceName returns true if the resource name has the huge page resource prefix.

func IsIntegerResourceName added in v1.2.0

func IsIntegerResourceName(str string) bool

IsIntegerResourceName returns true if the resource is measured in integer values

func IsNativeResource added in v1.2.0

func IsNativeResource(name corev1.ResourceName) bool

IsNativeResource returns true if the resource name is in the *kubernetes.io/ namespace. Partially-qualified (unprefixed) names are implicitly in the kubernetes.io/ namespace.

func IsPrefixedNativeResource added in v1.2.0

func IsPrefixedNativeResource(name corev1.ResourceName) bool

IsPrefixedNativeResource returns true if the resource name is in the *kubernetes.io/ namespace.

func IsQuotaHugePageResourceName added in v1.2.0

func IsQuotaHugePageResourceName(name corev1.ResourceName) bool

IsQuotaHugePageResourceName returns true if the resource name has the quota related huge page resource prefix.

func IsScalarResourceName added in v1.2.0

func IsScalarResourceName(name corev1.ResourceName) bool

IsScalarResourceName validates the resource for Extended, Hugepages, Native and AttachableVolume resources

func IsStandardContainerResourceName added in v1.6.0

func IsStandardContainerResourceName(str string) bool

IsStandardContainerResourceName returns true if the container can make a resource request for the specified resource

func IsStandardQuotaResourceName added in v1.2.0

func IsStandardQuotaResourceName(str string) bool

IsStandardQuotaResourceName returns true if the resource is known to the quota tracking system

func IsStandardResourceName added in v1.2.0

func IsStandardResourceName(str string) bool

IsStandardResourceName returns true if the resource is known to the system

func ListPodsByRS added in v1.2.0

func ListPodsByRS(deployment *appsv1.Deployment, rsList []*appsv1.ReplicaSet, f PodListFunc) ([]*corev1.Pod, error)

ListPodsByRS returns a list of pods the given deployment targets. This needs a list of ReplicaSets for the Deployment, which can be found with ListReplicaSets(). Note that this does NOT attempt to reconcile ControllerRef (adopt/orphan), because only the controller itself should do that. However, it does filter out anything whose ControllerRef doesn't match.

func ListReplicaSetsByDeployment added in v1.2.0

func ListReplicaSetsByDeployment(deployment *appsv1.Deployment, getRSList RsListFunc) ([]*appsv1.ReplicaSet, error)

ListReplicaSetsByDeployment returns a slice of RSes the given deployment targets. Note that this does NOT attempt to reconcile ControllerRef (adopt/orphan), because only the controller itself should do that. However, it does filter out anything whose ControllerRef doesn't match.

func NewRequestInfo

func NewRequestInfo(req *http.Request) *apirequest.RequestInfo

TODO write an integration test against the swagger doc to test the RequestInfo and match up behavior to responses NewRequestInfo returns the information from the http request. If error is not nil, RequestInfo holds the information as best it is known before the failure It handles both resource and non-resource requests and fills in all the pertinent information for each. Valid Inputs: Resource paths /apis/{api-group}/{version}/namespaces /api/{version}/namespaces /api/{version}/namespaces/{namespace} /api/{version}/namespaces/{namespace}/{resource} /api/{version}/namespaces/{namespace}/{resource}/{resourceName} /api/{version}/{resource} /api/{version}/{resource}/{resourceName}

Special verbs without subresources: /api/{version}/proxy/{resource}/{resourceName} /api/{version}/proxy/namespaces/{namespace}/{resource}/{resourceName}

Special verbs with subresources: /api/{version}/watch/{resource} /api/{version}/watch/namespaces/{namespace}/{resource}

NonResource paths /apis/{api-group}/{version} /apis/{api-group} /apis /api/{version} /api /healthz /

func NodeSelectorRequirementsAsSelector added in v1.2.0

func NodeSelectorRequirementsAsSelector(nsm []corev1.NodeSelectorRequirement) (labels.Selector, []error)

NodeSelectorRequirementsAsSelector converts the []NodeSelectorRequirement core type into a struct that implements labels.Selector.

func ObjectNeedsUpdate added in v1.2.0

func ObjectNeedsUpdate(desiredObj, clusterObj *unstructured.Unstructured, recordedVersion string) bool

ObjectNeedsUpdate determines whether the 2 objects provided cluster object needs to be updated according to the desired object and the recorded version.

func ObjectVersion added in v1.2.0

func ObjectVersion(clusterObj *unstructured.Unstructured) string

ObjectVersion retrieves the field type-prefixed value used for determining currency of the given cluster object.

func OutDir added in v1.4.0

func OutDir(path string) (string, error)

OutDir creates the absolute path name from path and checks path exists. Returns absolute path including trailing '/' or error if path does not exist.

func ParseTaints added in v1.2.0

func ParseTaints(spec []string) ([]corev1.Taint, []corev1.Taint, error)

ParseTaints takes a spec which is an array and creates slices for new taints to be added, taints to be deleted. It also validates the spec. For example, the form `<key>` may be used to remove a taint, but not to add one.

func RetainServiceAccountFields added in v1.2.0

func RetainServiceAccountFields(desired, observed *unstructured.Unstructured) (*unstructured.Unstructured, error)

RetainServiceAccountFields merges the 'secrets' field in the service account of the control plane and the member clusters and retains the merged service account. This ensures that the karmada-controller-manager doesn't continually clear a generated secret from a service account, prompting continual regeneration by the service account controller in the member cluster. Related issue: https://github.com/karmada-io/karmada/issues/2573

func RetainServiceFields added in v1.2.0

func RetainServiceFields(desired, observed *unstructured.Unstructured) (*unstructured.Unstructured, error)

RetainServiceFields updates the desired service object with values retained from the cluster object.

func SetDefaultsFederatedHPA added in v1.6.0

func SetDefaultsFederatedHPA(obj *autoscalingv1alpha1.FederatedHPA)

func SetDefaultsHorizontalPodAutoscalerBehavior added in v1.6.0

func SetDefaultsHorizontalPodAutoscalerBehavior(obj *autoscalingv1alpha1.FederatedHPA)

SetDefaultsHorizontalPodAutoscalerBehavior fills the behavior if it is not null

func SplitPath

func SplitPath(path string) []string

SplitPath returns the segments for a URL path.

func ValidateClusterTaints added in v1.2.0

func ValidateClusterTaints(taints []corev1.Taint, fldPath *field.Path) field.ErrorList

ValidateClusterTaints tests if given taints have valid data. Original func name: validateNodeTaints

func ValidateContainerResourceName added in v1.6.0

func ValidateContainerResourceName(value string, fldPath *field.Path) field.ErrorList

ValidateContainerResourceName checks the name of resource specified for a container

func ValidateCrossVersionObjectReference added in v1.6.0

func ValidateCrossVersionObjectReference(ref autoscalingv2.CrossVersionObjectReference, fldPath *field.Path) field.ErrorList

ValidateCrossVersionObjectReference validates a CrossVersionObjectReference and returns an ErrorList with any errors.

func ValidateDNS1123Label added in v1.6.0

func ValidateDNS1123Label(value string, fldPath *field.Path) field.ErrorList

func ValidateFederatedHPA added in v1.6.0

func ValidateFederatedHPA(fhpa *autoscalingv1alpha1.FederatedHPA) field.ErrorList

ValidateFederatedHPA validates a FederatedHPA and returns an ErrorList with any errors.

func ValidateIngressLoadBalancerStatus added in v1.6.0

func ValidateIngressLoadBalancerStatus(status *networkingv1.IngressLoadBalancerStatus, fldPath *field.Path) field.ErrorList

ValidateIngressLoadBalancerStatus validates required fields on an IngressLoadBalancerStatus

func ValidateIngressSpec added in v1.6.0

func ValidateIngressSpec(spec *networkingv1.IngressSpec, fldPath *field.Path, opts IngressValidationOptions) field.ErrorList

ValidateIngressSpec tests if required fields in the IngressSpec are set.

func ValidateLoadBalancerStatus added in v1.7.0

func ValidateLoadBalancerStatus(status *corev1.LoadBalancerStatus, fldPath *field.Path) field.ErrorList

ValidateLoadBalancerStatus validates required fields on a LoadBalancerStatus

func ValidateNonnegativeQuantity added in v1.2.0

func ValidateNonnegativeQuantity(value resource.Quantity, fldPath *field.Path) field.ErrorList

ValidateNonnegativeQuantity Validates that a Quantity is not negative

func ValidateResourceQuantityValue added in v1.2.0

func ValidateResourceQuantityValue(resource string, value resource.Quantity, fldPath *field.Path) field.ErrorList

ValidateResourceQuantityValue enforces that specified quantity is valid for specified resource

func ValidateResourceQuotaResourceName added in v1.2.0

func ValidateResourceQuotaResourceName(value string, fldPath *field.Path) field.ErrorList

ValidateResourceQuotaResourceName Validate resource names that can go in a resource quota Refer to docs/design/resources.md for more details.

func VisitContainers added in v1.2.0

func VisitContainers(podSpec *corev1.PodSpec, mask ContainerType, visitor ContainerVisitor) bool

VisitContainers invokes the visitor function with a pointer to every container spec in the given pod spec with type set in mask. If visitor returns false, visiting is short-circuited. VisitContainers returns true if visiting completes, false if visiting was short-circuited.

func VisitPodConfigmapNames added in v1.2.0

func VisitPodConfigmapNames(pod *corev1.Pod, visitor Visitor) bool

VisitPodConfigmapNames invokes the visitor function with the name of every configmap referenced by the pod spec. If visitor returns false, visiting is short-circuited. Transitive references (e.g. pod -> pvc -> pv -> secret) are not visited. Returns true if visiting completed, false if visiting was short-circuited.

func VisitPodSecretNames added in v1.2.0

func VisitPodSecretNames(pod *corev1.Pod, visitor Visitor) bool

VisitPodSecretNames invokes the visitor function with the name of every secret referenced by the pod spec. If visitor returns false, visiting is short-circuited. Transitive references (e.g. pod -> pvc -> pv -> secret) are not visited. Returns true if visiting completed, false if visiting was short-circuited.

Types

type ContainerType added in v1.2.0

type ContainerType int

ContainerType signifies container type

const (
	// Containers is for normal containers
	Containers ContainerType = 1 << iota
	// InitContainers is for init containers
	InitContainers
	// EphemeralContainers is for ephemeral containers
	EphemeralContainers
)

AllContainers specifies that all containers be visited

type ContainerVisitor added in v1.2.0

type ContainerVisitor func(container *corev1.Container, containerType ContainerType) (shouldContinue bool)

ContainerVisitor is called with each container spec, and returns true if visiting should continue.

type IngressValidationOptions added in v1.6.0

type IngressValidationOptions struct {
	// AllowInvalidSecretName indicates whether spec.tls[*].secretName values that are not valid Secret names should be allowed
	AllowInvalidSecretName bool

	// AllowInvalidWildcardHostRule indicates whether invalid rule values are allowed in rules with wildcard hostnames
	AllowInvalidWildcardHostRule bool
}

IngressValidationOptions cover beta to GA transitions for HTTP PathType

type PodListFunc added in v1.2.0

type PodListFunc func(string, labels.Selector) ([]*corev1.Pod, error)

PodListFunc returns the Pod slice from the Pod namespace and a selector.

type ReplicaSetsByCreationTimestamp added in v1.2.0

type ReplicaSetsByCreationTimestamp []*appsv1.ReplicaSet

ReplicaSetsByCreationTimestamp sorts a list of ReplicaSet by creation timestamp, using their names as a tie breaker.

func (ReplicaSetsByCreationTimestamp) Len added in v1.2.0

func (ReplicaSetsByCreationTimestamp) Less added in v1.2.0

func (ReplicaSetsByCreationTimestamp) Swap added in v1.2.0

func (o ReplicaSetsByCreationTimestamp) Swap(i, j int)

type RsListFunc added in v1.7.0

type RsListFunc func(string, labels.Selector) ([]*appsv1.ReplicaSet, error)

RsListFunc returns the ReplicaSet from the ReplicaSet namespace and the List metav1.ListOptions.

type Visitor added in v1.2.0

type Visitor func(name string) (shouldContinue bool)

Visitor is called with each object name, and returns true if visiting should continue

Directories

Path Synopsis
scheduler

Jump to

Keyboard shortcuts

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