const RevisionAnnotation … const RevisionHistoryAnnotation … const DesiredReplicasAnnotation … const MaxReplicasAnnotation … const RollbackRevisionNotFound … const RollbackTemplateUnchanged … const RollbackDone … const TimedOutReason … // GetDeploymentCondition returns the condition with the provided type. func GetDeploymentCondition(status appsv1.DeploymentStatus, condType appsv1.DeploymentConditionType) *appsv1.DeploymentCondition { … } // Revision returns the revision number of the input object. func Revision(obj runtime.Object) (int64, error) { … } // GetAllReplicaSets returns the old and new replica sets targeted by the given Deployment. It gets PodList and // ReplicaSetList from client interface. Note that the first set of old replica sets doesn't include the ones // with no pods, and the second set of old replica sets include all old replica sets. The third returned value // is the new replica set, and it may be nil if it doesn't exist yet. func GetAllReplicaSets(deployment *appsv1.Deployment, c appsclient.AppsV1Interface) ([]*appsv1.ReplicaSet, []*appsv1.ReplicaSet, *appsv1.ReplicaSet, error) { … } // GetAllReplicaSetsInChunks is the same as GetAllReplicaSets, but accepts a chunk size argument. // It returns the old and new replica sets targeted by the given Deployment. It gets PodList and // ReplicaSetList from client interface. Note that the first set of old replica sets doesn't include the ones // with no pods, and the second set of old replica sets include all old replica sets. The third returned value // is the new replica set, and it may be nil if it doesn't exist yet. func GetAllReplicaSetsInChunks(deployment *appsv1.Deployment, c appsclient.AppsV1Interface, chunkSize int64) ([]*appsv1.ReplicaSet, []*appsv1.ReplicaSet, *appsv1.ReplicaSet, error) { … } // RsListFromClient returns an rsListFunc that wraps the given client. func rsListFromClient(c appsclient.AppsV1Interface) rsListFunc { … } type rsListFunc … // listReplicaSets 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 listReplicaSets(deployment *appsv1.Deployment, getRSList rsListFunc, chunkSize *int64) ([]*appsv1.ReplicaSet, error) { … } // 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 equalIgnoreHash(template1, template2 *corev1.PodTemplateSpec) bool { … } // FindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template). func findNewReplicaSet(deployment *appsv1.Deployment, rsList []*appsv1.ReplicaSet) *appsv1.ReplicaSet { … } type replicaSetsByCreationTimestamp … func (o replicaSetsByCreationTimestamp) Len() int { … } func (o replicaSetsByCreationTimestamp) Swap(i, j int) { … } func (o replicaSetsByCreationTimestamp) Less(i, j int) bool { … } // // FindOldReplicaSets returns the old replica sets targeted by the given Deployment, with the given slice of RSes. // // Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets. func findOldReplicaSets(deployment *appsv1.Deployment, rsList []*appsv1.ReplicaSet, newRS *appsv1.ReplicaSet) ([]*appsv1.ReplicaSet, []*appsv1.ReplicaSet) { … } // ResolveFenceposts resolves both maxSurge and maxUnavailable. This needs to happen in one // step. For example: // // 2 desired, max unavailable 1%, surge 0% - should scale old(-1), then new(+1), then old(-1), then new(+1) // 1 desired, max unavailable 1%, surge 0% - should scale old(-1), then new(+1) // 2 desired, max unavailable 25%, surge 1% - should scale new(+1), then old(-1), then new(+1), then old(-1) // 1 desired, max unavailable 25%, surge 1% - should scale new(+1), then old(-1) // 2 desired, max unavailable 0%, surge 1% - should scale new(+1), then old(-1), then new(+1), then old(-1) // 1 desired, max unavailable 0%, surge 1% - should scale new(+1), then old(-1) func ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired int32) (int32, int32, error) { … }