Documentation
¶
Index ¶
- Constants
- Variables
- func AddOrUpdateCNRTaint(cnr *apis.CustomNodeResource, taint *apis.Taint) (*apis.CustomNodeResource, bool, error)
- func CNRTaintExists(taints []*apis.Taint, taintToFind *apis.Taint) bool
- func CheckCNRConditionMatched(curCondition *nodev1alpha1.CNRCondition, status corev1.ConditionStatus, ...) bool
- func CheckSPDMatchWithPod(pod *core.Pod, spd *apiworkload.ServiceProfileDescriptor, ...) bool
- func CheckVPARecommendationMatchVPA(vpaRec *apis.VerticalPodAutoscalerRecommendation, ...) bool
- func CheckVPAStatusLegal(vpa *apis.KatalystVerticalPodAutoscaler, pods []*core.Pod) (bool, string, error)
- func CheckWorkloadEnableVPA(runtimeObject runtime.Object) bool
- func CheckWorkloadSPDEnabled(workload metav1.Object) bool
- func ConvertVPAContainerResourceToRecommendedContainerResources(resource apis.ContainerResources) apis.RecommendedContainerResources
- func ConvertVPAContainerResourceToResourceRequirements(containerResource apis.ContainerResources) core.ResourceRequirements
- func DeleteCNRTaint(taints []*apis.Taint, taintToDelete *apis.Taint) ([]*apis.Taint, bool)
- func GenerateVPAPodResizePolicyAnnotations(pod *core.Pod, containerPolicies map[string]apis.ContainerResourcePolicy) (map[string]string, error)
- func GenerateVPAPodResizeResourceAnnotations(pod *core.Pod, ...) (map[string]core.ResourceRequirements, error)
- func GenerateVPAPolicyMap(vpa *apis.KatalystVerticalPodAutoscaler) (map[string]apis.ContainerResourcePolicy, error)
- func GenerateVPAResourceMap(vpa *apis.KatalystVerticalPodAutoscaler) (map[consts.PodContainerName]apis.ContainerResources, ...)
- func GetCNRCondition(status *apis.CustomNodeResourceStatus, conditionType apis.CNRConditionType) (int, *apis.CNRCondition)
- func GetPodListForSPD(spd *apiworkload.ServiceProfileDescriptor, podIndexer cache.Indexer, ...) ([]*core.Pod, error)
- func GetPodListForVPA(vpa *apis.KatalystVerticalPodAutoscaler, podIndexer cache.Indexer, ...) ([]*core.Pod, error)
- func GetSPDForPod(pod *core.Pod, spdIndexer cache.Indexer, ...) (*apiworkload.ServiceProfileDescriptor, error)
- func GetSPDForVPA(vpa *apis.KatalystVerticalPodAutoscaler, spdIndexer cache.Indexer, ...) (*workload.ServiceProfileDescriptor, error)
- func GetSPDForWorkload(workload *unstructured.Unstructured, spdIndexer cache.Indexer, ...) (*apiworkload.ServiceProfileDescriptor, error)
- func GetVPAForPod(pod *core.Pod, vpaIndexer cache.Indexer, ...) (*apis.KatalystVerticalPodAutoscaler, error)
- func GetVPAForVPARec(vpaRec *apis.VerticalPodAutoscalerRecommendation, ...) (*apis.KatalystVerticalPodAutoscaler, error)
- func GetVPAForWorkload(workload *unstructured.Unstructured, vpaIndexer cache.Indexer, ...) (*apis.KatalystVerticalPodAutoscaler, error)
- func GetVPARecForVPA(vpa *apis.KatalystVerticalPodAutoscaler, vpaRecIndexer cache.Indexer, ...) (*apis.VerticalPodAutoscalerRecommendation, error)
- func GetWorkloadForSPD(spd *apiworkload.ServiceProfileDescriptor, lister cache.GenericLister) (runtime.Object, error)
- func GetWorkloadForVPA(vpa *apis.KatalystVerticalPodAutoscaler, workloadLister cache.GenericLister) (runtime.Object, error)
- func MatchCNRTaint(taintToMatch, taint *apis.Taint) bool
- func RemoveCNRTaint(cnr *apis.CustomNodeResource, taint *apis.Taint) (*apis.CustomNodeResource, bool, error)
- func SPDTargetReferenceIndex(obj interface{}) ([]string, error)
- func SetCNRCondition(cnr *apis.CustomNodeResource, conditionType apis.CNRConditionType, ...)
- func VPATargetReferenceIndex(obj interface{}) ([]string, error)
- type KCCTargetResource
- func (g KCCTargetResource) CheckExpired(now time.Time) bool
- func (g KCCTargetResource) CheckValid() bool
- func (g KCCTargetResource) DeepCopy() KCCTargetResource
- func (g KCCTargetResource) GenerateConfigHash(length int) (string, error)
- func (g KCCTargetResource) GetCollisionCount() *int32
- func (g KCCTargetResource) GetGenericStatus() v1alpha1.GenericConfigStatus
- func (g KCCTargetResource) GetHash() string
- func (g KCCTargetResource) GetLabelSelector() string
- func (g KCCTargetResource) GetLastDuration() *time.Duration
- func (g KCCTargetResource) GetNodeNames() []string
- func (g KCCTargetResource) GetObservedGeneration() int64
- func (g KCCTargetResource) GetRevisionHistoryLimit() int64
- func (g KCCTargetResource) IsUpdated() bool
- func (g KCCTargetResource) SetCollisionCount(count *int32)
- func (g KCCTargetResource) SetGenericStatus(status v1alpha1.GenericConfigStatus)
- func (g KCCTargetResource) SetHash(hash string)
- func (g KCCTargetResource) SetObservedGeneration(generation int64)
- func (g KCCTargetResource) Unmarshal(conf interface{}) error
Constants ¶
const ( CNRFieldNameNodeResourceProperties = "NodeResourceProperties" CNRFieldNameTopologyStatus = "TopologyStatus" CNRFieldNameResourceAllocatable = "ResourceAllocatable" CNRFieldNameResourceCapacity = "ResourceCapacity" )
those fields are used by in-tree reporter plugins to refer specific field names of CNR.
const (
CNRKind = "CustomNodeResource"
)
Variables ¶
var ( CNRGroupVersionKind = metav1.GroupVersionKind{ Group: nodev1alpha1.SchemeGroupVersion.Group, Kind: CNRKind, Version: nodev1alpha1.SchemeGroupVersion.Version, } ReclaimedResourceNameToNativeResourceNameMap = map[corev1.ResourceName]corev1.ResourceName{ consts.ReclaimedResourceMilliCPU: corev1.ResourceCPU, consts.ReclaimedResourceMemory: corev1.ResourceMemory, } )
Functions ¶
func AddOrUpdateCNRTaint ¶
func AddOrUpdateCNRTaint(cnr *apis.CustomNodeResource, taint *apis.Taint) (*apis.CustomNodeResource, bool, error)
AddOrUpdateCNRTaint tries to add a taint to annotations list. Returns a new copy of updated CNR and true if something was updated false otherwise.
func CNRTaintExists ¶
CNRTaintExists checks if the given taint exists in list of taints. Returns true if exists false otherwise.
func CheckCNRConditionMatched ¶
func CheckCNRConditionMatched(curCondition *nodev1alpha1.CNRCondition, status corev1.ConditionStatus, reason, message string) bool
CheckCNRConditionMatched checks if current CNR condition matches the update condition
func CheckSPDMatchWithPod ¶
func CheckSPDMatchWithPod(pod *core.Pod, spd *apiworkload.ServiceProfileDescriptor, workloadListerMap map[schema.GroupVersionKind]cache.GenericLister) bool
CheckSPDMatchWithPod checks whether the given pod and spd matches with each other
func CheckVPARecommendationMatchVPA ¶
func CheckVPARecommendationMatchVPA(vpaRec *apis.VerticalPodAutoscalerRecommendation, vpa *apis.KatalystVerticalPodAutoscaler) bool
func CheckVPAStatusLegal ¶
func CheckVPAStatusLegal(vpa *apis.KatalystVerticalPodAutoscaler, pods []*core.Pod) (bool, string, error)
CheckVPAStatusLegal checks following things and return a msg 1. recommended resource mustn't change pod qos class 2. recommended resource mustn't scale up in VPA 1.0 todo: remove this in VPA 2.0 3. recommended resource mustn't be negative if vpa status is illegal, we'll refuse update its status
func CheckWorkloadEnableVPA ¶
CheckWorkloadEnableVPA is used to check whether the object enables VPA functionality
func CheckWorkloadSPDEnabled ¶
CheckWorkloadSPDEnabled checks if the given workload is enabled with service profiling.
func ConvertVPAContainerResourceToRecommendedContainerResources ¶
func ConvertVPAContainerResourceToRecommendedContainerResources(resource apis.ContainerResources) apis.RecommendedContainerResources
ConvertVPAContainerResourceToRecommendedContainerResources converts apis.ContainerResources to apis.RecommendedContainerResources
func ConvertVPAContainerResourceToResourceRequirements ¶
func ConvertVPAContainerResourceToResourceRequirements(containerResource apis.ContainerResources) core.ResourceRequirements
ConvertVPAContainerResourceToResourceRequirements converts target value in apis.ContainerResources to core.ResourceRequirements
func DeleteCNRTaint ¶
DeleteCNRTaint removes all the taints that have the same key and effect to given taintToDelete.
func GenerateVPAPodResizePolicyAnnotations ¶
func GenerateVPAPodResizePolicyAnnotations(pod *core.Pod, containerPolicies map[string]apis.ContainerResourcePolicy) (map[string]string, error)
GenerateVPAPodResizePolicyAnnotations returns mapping from containerName to policy
func GenerateVPAPodResizeResourceAnnotations ¶
func GenerateVPAPodResizeResourceAnnotations(pod *core.Pod, podResources map[consts.PodContainerName]apis.ContainerResources, containerResources map[consts.ContainerName]apis.ContainerResources) (map[string]core.ResourceRequirements, error)
GenerateVPAPodResizeResourceAnnotations returns mapping from containerName to resourceRequirements by merging the given podResources and containerResources; and podResources is always superior to containerResources
func GenerateVPAPolicyMap ¶
func GenerateVPAPolicyMap(vpa *apis.KatalystVerticalPodAutoscaler) (map[string]apis.ContainerResourcePolicy, error)
GenerateVPAPolicyMap returns vpa resource policy at container-level
func GenerateVPAResourceMap ¶
func GenerateVPAResourceMap(vpa *apis.KatalystVerticalPodAutoscaler) (map[consts.PodContainerName]apis.ContainerResources, map[consts.ContainerName]apis.ContainerResources, error)
GenerateVPAResourceMap returns the map of pod resources and container resources; the returned pod resources map use GeneratePodContainerName as key, and apis.ContainerResources as value the returned container resources map use GenerateContainerName as key, and apis.ContainerResources as value
func GetCNRCondition ¶
func GetCNRCondition(status *apis.CustomNodeResourceStatus, conditionType apis.CNRConditionType) (int, *apis.CNRCondition)
GetCNRCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.
func GetPodListForSPD ¶
func GetPodListForSPD(spd *apiworkload.ServiceProfileDescriptor, podIndexer cache.Indexer, podLabelIndexKeyList []string, workloadLister cache.GenericLister, podLister corelisters.PodLister) ([]*core.Pod, error)
GetPodListForSPD is used to get pods that should be managed by the given spd, we'll always get through workload
func GetPodListForVPA ¶
func GetPodListForVPA(vpa *apis.KatalystVerticalPodAutoscaler, podIndexer cache.Indexer, podLabelIndexKeyList []string, workloadLister cache.GenericLister, podLister corelisters.PodLister) ([]*core.Pod, error)
GetPodListForVPA is used to get pods that should be managed by the given vpa, we'll always get through workload
func GetSPDForPod ¶
func GetSPDForPod(pod *core.Pod, spdIndexer cache.Indexer, workloadListerMap map[schema.GroupVersionKind]cache.GenericLister, spdLister workloadlister.ServiceProfileDescriptorLister) (*apiworkload.ServiceProfileDescriptor, error)
GetSPDForPod is used to get spd that should manage the given vpa, we'll try to find by annotation for pod, and then go through workload if not exist, and we will find it recursively since we don't know in which level the owner will be.
func GetSPDForVPA ¶
func GetSPDForVPA(vpa *apis.KatalystVerticalPodAutoscaler, spdIndexer cache.Indexer, workloadLister cache.GenericLister, spdLister workloadlister.ServiceProfileDescriptorLister) (*workload.ServiceProfileDescriptor, error)
GetSPDForVPA is used to get spd that matches with the workload belongs to the given vpa the preference is indexer --> GetSPDForWorkload
func GetSPDForWorkload ¶
func GetSPDForWorkload(workload *unstructured.Unstructured, spdIndexer cache.Indexer, spdLister workloadlister.ServiceProfileDescriptorLister) (*apiworkload.ServiceProfileDescriptor, error)
GetSPDForWorkload is used to get spd that should manage the given workload the preference is annotation ---> indexer --> lister
func GetVPAForPod ¶
func GetVPAForPod(pod *core.Pod, vpaIndexer cache.Indexer, workloadListerMap map[schema.GroupVersionKind]cache.GenericLister, vpaLister autoscalelister.KatalystVerticalPodAutoscalerLister) (*apis.KatalystVerticalPodAutoscaler, error)
GetVPAForPod is used to get vpa that should manage the given vpa, we'll always get through workload, and we will find it recursively since we don't know in which level the owner will be.
func GetVPAForVPARec ¶
func GetVPAForVPARec(vpaRec *apis.VerticalPodAutoscalerRecommendation, vpaLister autoscalelister.KatalystVerticalPodAutoscalerLister) (*apis.KatalystVerticalPodAutoscaler, error)
GetVPAForVPARec is used to get vpa that should manage the given vpaRec
func GetVPAForWorkload ¶
func GetVPAForWorkload(workload *unstructured.Unstructured, vpaIndexer cache.Indexer, vpaLister autoscalelister.KatalystVerticalPodAutoscalerLister) (*apis.KatalystVerticalPodAutoscaler, error)
GetVPAForWorkload is used to get vpa that should manage the given workload
func GetVPARecForVPA ¶
func GetVPARecForVPA(vpa *apis.KatalystVerticalPodAutoscaler, vpaRecIndexer cache.Indexer, recLister autoscalelister.VerticalPodAutoscalerRecommendationLister) (*apis.VerticalPodAutoscalerRecommendation, error)
GetVPARecForVPA is used to get vpaRec that should be managed the given vpa
func GetWorkloadForSPD ¶
func GetWorkloadForSPD(spd *apiworkload.ServiceProfileDescriptor, lister cache.GenericLister) (runtime.Object, error)
GetWorkloadForSPD is used to get workload that should be managed the given spd
func GetWorkloadForVPA ¶
func GetWorkloadForVPA(vpa *apis.KatalystVerticalPodAutoscaler, workloadLister cache.GenericLister) (runtime.Object, error)
GetWorkloadForVPA is used to get workload that should be managed by the given vpa
func MatchCNRTaint ¶
MatchCNRTaint checks if the taint matches taintToMatch. Taints are unique by key:effect, if the two taints have same key:effect, regard as they match.
func RemoveCNRTaint ¶
func RemoveCNRTaint(cnr *apis.CustomNodeResource, taint *apis.Taint) (*apis.CustomNodeResource, bool, error)
RemoveCNRTaint tries to remove a taint cnr taints. Returns a new copy of updated CNR and true if something was updated false otherwise.
func SPDTargetReferenceIndex ¶
SPDTargetReferenceIndex is used to construct informer index for target reference in SPD
func SetCNRCondition ¶
func SetCNRCondition(cnr *apis.CustomNodeResource, conditionType apis.CNRConditionType, status corev1.ConditionStatus, reason, message string, now metav1.Time)
SetCNRCondition set specific cnr condition.
func VPATargetReferenceIndex ¶
VPATargetReferenceIndex is used to construct informer index for target reference in VPA
Types ¶
type KCCTargetResource ¶
type KCCTargetResource struct {
*unstructured.Unstructured
}
KCCTargetResource is used to provide util function to get detailed information about KCC Target fields.
func ToKCCTargetResource ¶
func ToKCCTargetResource(obj *unstructured.Unstructured) KCCTargetResource
func (KCCTargetResource) CheckExpired ¶
func (g KCCTargetResource) CheckExpired(now time.Time) bool
func (KCCTargetResource) CheckValid ¶
func (g KCCTargetResource) CheckValid() bool
func (KCCTargetResource) DeepCopy ¶
func (g KCCTargetResource) DeepCopy() KCCTargetResource
func (KCCTargetResource) GenerateConfigHash ¶
func (g KCCTargetResource) GenerateConfigHash(length int) (string, error)
func (KCCTargetResource) GetCollisionCount ¶
func (g KCCTargetResource) GetCollisionCount() *int32
func (KCCTargetResource) GetGenericStatus ¶
func (g KCCTargetResource) GetGenericStatus() v1alpha1.GenericConfigStatus
func (KCCTargetResource) GetHash ¶
func (g KCCTargetResource) GetHash() string
func (KCCTargetResource) GetLabelSelector ¶
func (g KCCTargetResource) GetLabelSelector() string
func (KCCTargetResource) GetLastDuration ¶
func (g KCCTargetResource) GetLastDuration() *time.Duration
func (KCCTargetResource) GetNodeNames ¶
func (g KCCTargetResource) GetNodeNames() []string
func (KCCTargetResource) GetObservedGeneration ¶
func (g KCCTargetResource) GetObservedGeneration() int64
func (KCCTargetResource) GetRevisionHistoryLimit ¶
func (g KCCTargetResource) GetRevisionHistoryLimit() int64
func (KCCTargetResource) IsUpdated ¶
func (g KCCTargetResource) IsUpdated() bool
func (KCCTargetResource) SetCollisionCount ¶
func (g KCCTargetResource) SetCollisionCount(count *int32)
func (KCCTargetResource) SetGenericStatus ¶
func (g KCCTargetResource) SetGenericStatus(status v1alpha1.GenericConfigStatus)
func (KCCTargetResource) SetHash ¶
func (g KCCTargetResource) SetHash(hash string)
func (KCCTargetResource) SetObservedGeneration ¶
func (g KCCTargetResource) SetObservedGeneration(generation int64)
func (KCCTargetResource) Unmarshal ¶
func (g KCCTargetResource) Unmarshal(conf interface{}) error