// GetTemplateGeneration gets the template generation associated with a v1.DaemonSet by extracting it from the // deprecated annotation. If no annotation is found nil is returned. If the annotation is found and fails to parse // nil is returned with an error. If the generation can be parsed from the annotation, a pointer to the parsed int64 // value is returned. func GetTemplateGeneration(ds *apps.DaemonSet) (*int64, error) { … } // AddOrUpdateDaemonPodTolerations apply necessary tolerations to DaemonSet Pods, e.g. node.kubernetes.io/not-ready:NoExecute. func AddOrUpdateDaemonPodTolerations(spec *v1.PodSpec) { … } // CreatePodTemplate returns copy of provided template with additional // label which contains templateGeneration (for backward compatibility), // hash of provided template and sets default daemon tolerations. func CreatePodTemplate(template v1.PodTemplateSpec, generation *int64, hash string) v1.PodTemplateSpec { … } // AllowsSurge returns true if the daemonset allows more than a single pod on any node. func AllowsSurge(ds *apps.DaemonSet) bool { … } // SurgeCount returns 0 if surge is not requested, the expected surge number to allow // out of numberToSchedule if surge is configured, or an error if the surge percentage // requested is invalid. func SurgeCount(ds *apps.DaemonSet, numberToSchedule int) (int, error) { … } // UnavailableCount returns 0 if unavailability is not requested, the expected // unavailability number to allow out of numberToSchedule if requested, or an error if // the unavailability percentage requested is invalid. func UnavailableCount(ds *apps.DaemonSet, numberToSchedule int) (int, error) { … } // IsPodUpdated checks if pod contains label value that either matches templateGeneration or hash func IsPodUpdated(pod *v1.Pod, hash string, dsTemplateGeneration *int64) bool { … } // ReplaceDaemonSetPodNodeNameNodeAffinity 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 ReplaceDaemonSetPodNodeNameNodeAffinity(affinity *v1.Affinity, nodename string) *v1.Affinity { … } // GetTargetNodeName get the target node name of DaemonSet pods. If `.spec.NodeName` is not empty (nil), // return `.spec.NodeName`; otherwise, retrieve node name of pending pods from NodeAffinity. Return error // if failed to retrieve node name from `.spec.NodeName` and NodeAffinity. func GetTargetNodeName(pod *v1.Pod) (string, error) { … }