Documentation ¶
Index ¶
- Constants
- func CreateJSONPatch(original, new interface{}) ([]byte, error)
- func CreateMergePatch(original, new interface{}) ([]byte, error)
- func GetClusterID(node *corev1.Node) string
- func GetRequestFromContainer(container *corev1.Container) *common.Resource
- func GetRequestFromPod(pod *corev1.Pod) *common.Resource
- func GetUpdatedPod(orig, update *corev1.Pod, ignoreLabels []string)
- func IsVirtualNode(node *corev1.Node) bool
- func IsVirtualPod(pod *corev1.Pod) bool
- func NewClient(configPath string, opts ...Opts) (kubernetes.Interface, error)
- func NewMetricClient(configPath string, opts ...Opts) (versioned.Interface, error)
- func RecoverLabels(labels map[string]string, annotations map[string]string)
- func ReplacePodNodeNameNodeAffinity(affinity *v1.Affinity, ownerID string, expireTime time.Duration, ...) (*v1.Affinity, int)
- func SetupSignalHandler() <-chan struct{}
- func TrimObjectMeta(meta *metav1.ObjectMeta)
- func TrimPod(pod *corev1.Pod, ignoreLabels []string) *corev1.Pod
- func UpdateConfigMap(old, new *corev1.ConfigMap)
- func UpdateSecret(old, new *corev1.Secret)
- type CheckValidFunc
- type ClustersNodeSelection
- type Opts
- type UnschedulableCache
Constants ¶
const ( // GlobalLabel make object global GlobalLabel = "global" // SelectorKey is the key of ClusterSelector SelectorKey = "clusterSelector" // SelectedNodeKey is the node selected by a scheduler SelectedNodeKey = "volume.kubernetes.io/selected-node" // HostNameKey is the label of HostNameKey HostNameKey = "kubernetes.io/hostname" // BetaHostNameKey is the label of HostNameKey BetaHostNameKey = "beta.kubernetes.io/hostname" // LabelOSBeta is the label of os LabelOSBeta = "beta.kubernetes.io/os" // VirtualPodLabel is the label of virtual pod VirtualPodLabel = "virtual-pod" // VirtualKubeletLabel is the label of virtual kubelet VirtualKubeletLabel = "virtual-kubelet" // TrippedLabels is the label of tripped labels TrippedLabels = "tripped-labels" // ClusterID marks the id of a cluster ClusterID = "clusterID" // NodeType is define the node type key NodeType = "type" // BatchPodLabel is the label of batch pod BatchPodLabel = "group.batch.scheduler.tencent.com" // TaintNodeNotReady will be added when node is not ready // and feature-gate for TaintBasedEvictions flag is enabled, // and removed when node becomes ready. TaintNodeNotReady = "node.kubernetes.io/not-ready" // TaintNodeUnreachable will be added when node becomes unreachable // (corresponding to NodeReady status ConditionUnknown) // and feature-gate for TaintBasedEvictions flag is enabled, // and removed when node becomes reachable (NodeReady status ConditionTrue). TaintNodeUnreachable = "node.kubernetes.io/unreachable" // CreatedbyDescheduler is used to mark if a pod is re-created by descheduler CreatedbyDescheduler = "create-by-descheduler" // DescheduleCount is used for recording deschedule count DescheduleCount = "sigs.k8s.io/deschedule-count" )
Variables ¶
This section is empty.
Functions ¶
func CreateJSONPatch ¶
CreateJSONPatch return patch generated from original and new interfaces
func CreateMergePatch ¶
CreateMergePatch return patch generated from original and new interfaces
func GetClusterID ¶
GetClusterID return the cluster in node label
func GetRequestFromContainer ¶
GetRequestFromContainer get resources required by container
func GetRequestFromPod ¶
GetRequestFromPod get resources required by pod
func GetUpdatedPod ¶
GetUpdatedPod allows user to update image, label, annotations for tolerations, we can only add some more.
func IsVirtualNode ¶
IsVirtualNode defines if a node is virtual node
func IsVirtualPod ¶
IsVirtualPod defines if a pod is virtual pod
func NewClient ¶
func NewClient(configPath string, opts ...Opts) (kubernetes.Interface, error)
NewClient returns a new client for k8s
func NewMetricClient ¶
NewMetricClient returns a new client for k8s
func RecoverLabels ¶
RecoverLabels recover some label that have been removed
func ReplacePodNodeNameNodeAffinity ¶
func ReplacePodNodeNameNodeAffinity(affinity *v1.Affinity, ownerID string, expireTime time.Duration, checkFuc CheckValidFunc, nodeNames ...string) (*v1.Affinity, int)
ReplacePodNodeNameNodeAffinity replaces the RequiredDuringSchedulingIgnoredDuringExecution NodeAffinity of the given affinity with a new NodeAffinity that selects the given nodeName. Note that this function assumes that no NodeAffinity conflicts with the selected nodeName.
func SetupSignalHandler ¶
func SetupSignalHandler() <-chan struct{}
SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned which is closed on one of these signals. If a second signal is caught, the program is terminated with exit code 1.
func TrimObjectMeta ¶
func TrimObjectMeta(meta *metav1.ObjectMeta)
TrimObjectMeta removes some fields of ObjectMeta
func TrimPod ¶
TrimPod filter some fields that should not be contained when created in subClusters for example: ownerReference, serviceLink and Uid we should also add some fields back for scheduling.
func UpdateConfigMap ¶
UpdateConfigMap updates the configMap data
Types ¶
type CheckValidFunc ¶
CheckValidFunc defines the check func
type ClustersNodeSelection ¶
type ClustersNodeSelection struct { NodeSelector map[string]string `json:"nodeSelector,omitempty"` Affinity *corev1.Affinity `json:"affinity,omitempty"` Tolerations []corev1.Toleration `json:"tolerations,omitempty"` }
ClustersNodeSelection is a struct including some scheduling parameters
func ConvertAnnotations ¶
func ConvertAnnotations(annotation map[string]string) *ClustersNodeSelection
ConvertAnnotations converts annotations to ClustersNodeSelection
type UnschedulableCache ¶
UnschedulableCache contaiens cache ownerid/node/freezeTime
func NewUnschedulableCache ¶
func NewUnschedulableCache() *UnschedulableCache
NewUnschedulableCache init a new Unschedulable
func (*UnschedulableCache) Add ¶
func (c *UnschedulableCache) Add(node, ownerID string)
Add add node/ownerID to cache
func (*UnschedulableCache) GetFreezeNodes ¶
func (c *UnschedulableCache) GetFreezeNodes(ownerID string) []string
GetFreezeNodes return the freezed nodes
func (*UnschedulableCache) GetFreezeTime ¶
func (c *UnschedulableCache) GetFreezeTime(node, ownerID string) *time.Time
GetFreezeTime returns node/ownerID freeze time