Documentation ¶
Index ¶
- Constants
- func DeploymentComplete(deployment *extensions.Deployment, newStatus *extensions.DeploymentStatus) bool
- func DeploymentDeepCopy(deployment *extensions.Deployment) (*extensions.Deployment, error)
- func DeploymentProgressing(deployment *extensions.Deployment, newStatus *extensions.DeploymentStatus) bool
- func DeploymentTimedOut(deployment *extensions.Deployment, newStatus *extensions.DeploymentStatus) bool
- func EqualIgnoreHash(template1, template2 *v1.PodTemplateSpec) (bool, error)
- func FindActiveOrLatest(newRS *extensions.ReplicaSet, oldRSs []*extensions.ReplicaSet) *extensions.ReplicaSet
- func FindNewReplicaSet(deployment *extensions.Deployment, rsList []*extensions.ReplicaSet) (*extensions.ReplicaSet, error)
- func FindOldReplicaSets(deployment *extensions.Deployment, rsList []*extensions.ReplicaSet) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error)
- func GetActualReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
- func GetAllReplicaSets(deployment *extensions.Deployment, ...) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, *extensions.ReplicaSet, ...)
- func GetAvailableReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
- func GetDeploymentCondition(status extensions.DeploymentStatus, ...) *extensions.DeploymentCondition
- func GetDeploymentConditionInternal(status internalextensions.DeploymentStatus, ...) *internalextensions.DeploymentCondition
- func GetDesiredReplicasAnnotation(rs *extensions.ReplicaSet) (int32, bool)
- func GetNewReplicaSet(deployment *extensions.Deployment, ...) (*extensions.ReplicaSet, error)
- func GetOldReplicaSets(deployment *extensions.Deployment, ...) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error)
- func GetProportion(rs *extensions.ReplicaSet, d extensions.Deployment, ...) int32
- func GetReadyReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
- func GetReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
- func GetReplicaSetHash(rs *extensions.ReplicaSet, uniquifier *int32) (string, error)
- func IsRollingUpdate(deployment *extensions.Deployment) bool
- func IsSaturated(deployment *extensions.Deployment, rs *extensions.ReplicaSet) bool
- func LabelPodsWithHash(podList *v1.PodList, c clientset.Interface, podLister corelisters.PodLister, ...) error
- func LastRevision(allRSs []*extensions.ReplicaSet) int64
- func ListPods(deployment *extensions.Deployment, rsList []*extensions.ReplicaSet, ...) (*v1.PodList, error)
- func ListReplicaSets(deployment *extensions.Deployment, getRSList RsListFunc) ([]*extensions.ReplicaSet, error)
- func ListReplicaSetsInternal(deployment *internalextensions.Deployment, ...) ([]*internalextensions.ReplicaSet, error)
- func MaxRevision(allRSs []*extensions.ReplicaSet) int64
- func MaxSurge(deployment extensions.Deployment) int32
- func MaxUnavailable(deployment extensions.Deployment) int32
- func MinAvailable(deployment *extensions.Deployment) int32
- func NewDeploymentCondition(condType extensions.DeploymentConditionType, status v1.ConditionStatus, ...) *extensions.DeploymentCondition
- func NewRSNewReplicas(deployment *extensions.Deployment, allRSs []*extensions.ReplicaSet, ...) (int32, error)
- func RemoveDeploymentCondition(status *extensions.DeploymentStatus, ...)
- func ReplicaSetToDeploymentCondition(cond extensions.ReplicaSetCondition) extensions.DeploymentCondition
- func ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired int32) (int32, int32, error)
- func Revision(obj runtime.Object) (int64, error)
- func SetDeploymentAnnotationsTo(deployment *extensions.Deployment, rollbackToRS *extensions.ReplicaSet)
- func SetDeploymentCondition(status *extensions.DeploymentStatus, condition extensions.DeploymentCondition)
- func SetDeploymentRevision(deployment *extensions.Deployment, revision string) bool
- func SetFromReplicaSetTemplate(deployment *extensions.Deployment, template v1.PodTemplateSpec) *extensions.Deployment
- func SetNewReplicaSetAnnotations(deployment *extensions.Deployment, newRS *extensions.ReplicaSet, ...) bool
- func SetReplicasAnnotations(rs *extensions.ReplicaSet, desiredReplicas, maxReplicas int32) bool
- func UpdatePodWithRetries(podClient v1core.PodInterface, podLister corelisters.PodLister, ...) (*v1.Pod, error)
- func UpdateRSWithRetries(rsClient unversionedextensions.ReplicaSetInterface, ...) (*extensions.ReplicaSet, error)
- func WaitForObservedDeployment(getDeploymentFunc func() (*extensions.Deployment, error), ...) error
- func WaitForObservedDeploymentInternal(getDeploymentFunc func() (*internalextensions.Deployment, error), ...) error
- func WaitForPodsHashPopulated(c extensionslisters.ReplicaSetLister, desiredGeneration int64, ...) error
- func WaitForReplicaSetUpdated(c extensionslisters.ReplicaSetLister, desiredGeneration int64, ...) error
- type RsListFunc
Constants ¶
const ( // RevisionAnnotation is the revision annotation of a deployment's replica sets which records its rollout sequence RevisionAnnotation = "deployment.kubernetes.io/revision" // RevisionHistoryAnnotation maintains the history of all old revisions that a replica set has served for a deployment. RevisionHistoryAnnotation = "deployment.kubernetes.io/revision-history" // DesiredReplicasAnnotation is the desired replicas for a deployment recorded as an annotation // in its replica sets. Helps in separating scaling events from the rollout process and for // determining if the new replica set for a deployment is really saturated. DesiredReplicasAnnotation = "deployment.kubernetes.io/desired-replicas" // MaxReplicasAnnotation is the maximum replicas a deployment can have at a given point, which // is deployment.spec.replicas + maxSurge. Used by the underlying replica sets to estimate their // proportions in case the deployment has surge replicas. MaxReplicasAnnotation = "deployment.kubernetes.io/max-replicas" // RollbackRevisionNotFound is not found rollback event reason RollbackRevisionNotFound = "DeploymentRollbackRevisionNotFound" // RollbackTemplateUnchanged is the template unchanged rollback event reason RollbackTemplateUnchanged = "DeploymentRollbackTemplateUnchanged" // RollbackDone is the done rollback event reason RollbackDone = "DeploymentRollback" // Reasons for deployment conditions // // Progressing: // // ReplicaSetUpdatedReason is added in a deployment when one of its replica sets is updated as part // of the rollout process. ReplicaSetUpdatedReason = "ReplicaSetUpdated" // FailedRSCreateReason is added in a deployment when it cannot create a new replica set. FailedRSCreateReason = "ReplicaSetCreateError" // NewReplicaSetReason is added in a deployment when it creates a new replica set. NewReplicaSetReason = "NewReplicaSetCreated" // FoundNewRSReason is added in a deployment when it adopts an existing replica set. FoundNewRSReason = "FoundNewReplicaSet" // NewRSAvailableReason is added in a deployment when its newest replica set is made available // ie. the number of new pods that have passed readiness checks and run for at least minReadySeconds // is at least the minimum available pods that need to run for the deployment. NewRSAvailableReason = "NewReplicaSetAvailable" // TimedOutReason is added in a deployment when its newest replica set fails to show any progress // within the given deadline (progressDeadlineSeconds). TimedOutReason = "ProgressDeadlineExceeded" // PausedDeployReason is added in a deployment when it is paused. Lack of progress shouldn't be // estimated once a deployment is paused. PausedDeployReason = "DeploymentPaused" // ResumedDeployReason is added in a deployment when it is resumed. Useful for not failing accidentally // deployments that paused amidst a rollout and are bounded by a deadline. ResumedDeployReason = "DeploymentResumed" // // Available: // // MinimumReplicasAvailable is added in a deployment when it has its minimum replicas required available. MinimumReplicasAvailable = "MinimumReplicasAvailable" // available. MinimumReplicasUnavailable = "MinimumReplicasUnavailable" )
Variables ¶
This section is empty.
Functions ¶
func DeploymentComplete ¶
func DeploymentComplete(deployment *extensions.Deployment, newStatus *extensions.DeploymentStatus) bool
DeploymentComplete considers a deployment to be complete once all of its desired replicas are updated and available, and no old pods are running.
func DeploymentDeepCopy ¶
func DeploymentDeepCopy(deployment *extensions.Deployment) (*extensions.Deployment, error)
func DeploymentProgressing ¶
func DeploymentProgressing(deployment *extensions.Deployment, newStatus *extensions.DeploymentStatus) bool
DeploymentProgressing reports progress for a deployment. Progress is estimated by comparing the current with the new status of the deployment that the controller is observing. More specifically, when new pods are scaled up or become ready or available, or old pods are scaled down, then we consider the deployment is progressing.
func DeploymentTimedOut ¶
func DeploymentTimedOut(deployment *extensions.Deployment, newStatus *extensions.DeploymentStatus) bool
DeploymentTimedOut considers a deployment to have timed out once its condition that reports progress is older than progressDeadlineSeconds or a Progressing condition with a TimedOutReason reason already exists.
func EqualIgnoreHash ¶
func EqualIgnoreHash(template1, template2 *v1.PodTemplateSpec) (bool, 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 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) Note that we assume input podTemplateSpecs contain non-empty labels
func FindActiveOrLatest ¶
func FindActiveOrLatest(newRS *extensions.ReplicaSet, oldRSs []*extensions.ReplicaSet) *extensions.ReplicaSet
FindActiveOrLatest returns the only active or the latest replica set in case there is at most one active replica set. If there are more active replica sets, then we should proportionally scale them.
func FindNewReplicaSet ¶
func FindNewReplicaSet(deployment *extensions.Deployment, rsList []*extensions.ReplicaSet) (*extensions.ReplicaSet, error)
FindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template).
func FindOldReplicaSets ¶
func FindOldReplicaSets(deployment *extensions.Deployment, rsList []*extensions.ReplicaSet) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error)
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 GetActualReplicaCountForReplicaSets ¶
func GetActualReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
GetActualReplicaCountForReplicaSets returns the sum of actual replicas of the given replica sets.
func GetAllReplicaSets ¶
func GetAllReplicaSets(deployment *extensions.Deployment, c extensionsv1beta1.ExtensionsV1beta1Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, *extensions.ReplicaSet, 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 GetAvailableReplicaCountForReplicaSets ¶
func GetAvailableReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
GetAvailableReplicaCountForReplicaSets returns the number of available pods corresponding to the given replica sets.
func GetDeploymentCondition ¶
func GetDeploymentCondition(status extensions.DeploymentStatus, condType extensions.DeploymentConditionType) *extensions.DeploymentCondition
GetDeploymentCondition returns the condition with the provided type.
func GetDeploymentConditionInternal ¶
func GetDeploymentConditionInternal(status internalextensions.DeploymentStatus, condType internalextensions.DeploymentConditionType) *internalextensions.DeploymentCondition
TODO: remove the duplicate GetDeploymentConditionInternal returns the condition with the provided type.
func GetDesiredReplicasAnnotation ¶
func GetDesiredReplicasAnnotation(rs *extensions.ReplicaSet) (int32, bool)
GetDesiredReplicasAnnotation returns the number of desired replicas
func GetNewReplicaSet ¶
func GetNewReplicaSet(deployment *extensions.Deployment, c extensionsv1beta1.ExtensionsV1beta1Interface) (*extensions.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 GetOldReplicaSets ¶
func GetOldReplicaSets(deployment *extensions.Deployment, c extensionsv1beta1.ExtensionsV1beta1Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error)
GetOldReplicaSets returns the old replica sets targeted by the given Deployment; get 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.
func GetProportion ¶
func GetProportion(rs *extensions.ReplicaSet, d extensions.Deployment, deploymentReplicasToAdd, deploymentReplicasAdded int32) int32
GetProportion will estimate the proportion for the provided replica set using 1. the current size of the parent deployment, 2. the replica count that needs be added on the replica sets of the deployment, and 3. the total replicas added in the replica sets of the deployment so far.
func GetReadyReplicaCountForReplicaSets ¶
func GetReadyReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
GetReadyReplicaCountForReplicaSets returns the number of ready pods corresponding to the given replica sets.
func GetReplicaCountForReplicaSets ¶
func GetReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
GetReplicaCountForReplicaSets returns the sum of Replicas of the given replica sets.
func GetReplicaSetHash ¶
func GetReplicaSetHash(rs *extensions.ReplicaSet, uniquifier *int32) (string, error)
GetReplicaSetHash returns the pod template hash of a ReplicaSet's pod template space
func IsRollingUpdate ¶
func IsRollingUpdate(deployment *extensions.Deployment) bool
IsRollingUpdate returns true if the strategy type is a rolling update.
func IsSaturated ¶
func IsSaturated(deployment *extensions.Deployment, rs *extensions.ReplicaSet) bool
IsSaturated checks if the new replica set is saturated by comparing its size with its deployment size. Both the deployment and the replica set have to believe this replica set can own all of the desired replicas in the deployment and the annotation helps in achieving that. All pods of the ReplicaSet need to be available.
func LabelPodsWithHash ¶
func LabelPodsWithHash(podList *v1.PodList, c clientset.Interface, podLister corelisters.PodLister, namespace, name, hash string) error
LabelPodsWithHash labels all pods in the given podList with the new hash label.
func LastRevision ¶
func LastRevision(allRSs []*extensions.ReplicaSet) int64
LastRevision finds the second max revision number in all replica sets (the last revision)
func ListPods ¶
func ListPods(deployment *extensions.Deployment, rsList []*extensions.ReplicaSet, getPodList podListFunc) (*v1.PodList, error)
ListPods 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 ListReplicaSets ¶
func ListReplicaSets(deployment *extensions.Deployment, getRSList RsListFunc) ([]*extensions.ReplicaSet, error)
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 ListReplicaSetsInternal ¶
func ListReplicaSetsInternal(deployment *internalextensions.Deployment, getRSList func(string, metav1.ListOptions) ([]*internalextensions.ReplicaSet, error)) ([]*internalextensions.ReplicaSet, error)
ListReplicaSetsInternal is ListReplicaSets for internalextensions. TODO: Remove the duplicate when call sites are updated to ListReplicaSets.
func MaxRevision ¶
func MaxRevision(allRSs []*extensions.ReplicaSet) int64
MaxRevision finds the highest revision in the replica sets
func MaxSurge ¶
func MaxSurge(deployment extensions.Deployment) int32
MaxSurge returns the maximum surge pods a rolling deployment can take.
func MaxUnavailable ¶
func MaxUnavailable(deployment extensions.Deployment) int32
MaxUnavailable returns the maximum unavailable pods a rolling deployment can take.
func MinAvailable ¶
func MinAvailable(deployment *extensions.Deployment) int32
MinAvailable returns the minimum available pods of a given deployment
func NewDeploymentCondition ¶
func NewDeploymentCondition(condType extensions.DeploymentConditionType, status v1.ConditionStatus, reason, message string) *extensions.DeploymentCondition
NewDeploymentCondition creates a new deployment condition.
func NewRSNewReplicas ¶
func NewRSNewReplicas(deployment *extensions.Deployment, allRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaSet) (int32, error)
NewRSNewReplicas calculates the number of replicas a deployment's new RS should have. When one of the followings is true, we're rolling out the deployment; otherwise, we're scaling it. 1) The new RS is saturated: newRS's replicas == deployment's replicas 2) Max number of pods allowed is reached: deployment's replicas + maxSurge == all RSs' replicas
func RemoveDeploymentCondition ¶
func RemoveDeploymentCondition(status *extensions.DeploymentStatus, condType extensions.DeploymentConditionType)
RemoveDeploymentCondition removes the deployment condition with the provided type.
func ReplicaSetToDeploymentCondition ¶
func ReplicaSetToDeploymentCondition(cond extensions.ReplicaSetCondition) extensions.DeploymentCondition
ReplicaSetToDeploymentCondition converts a replica set condition into a deployment condition. Useful for promoting replica set failure conditions into deployments.
func ResolveFenceposts ¶
func ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired int32) (int32, int32, error)
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 SetDeploymentAnnotationsTo ¶
func SetDeploymentAnnotationsTo(deployment *extensions.Deployment, rollbackToRS *extensions.ReplicaSet)
SetDeploymentAnnotationsTo sets deployment's annotations as given RS's annotations. This action should be done if and only if the deployment is rolling back to this rs. Note that apply and revision annotations are not changed.
func SetDeploymentCondition ¶
func SetDeploymentCondition(status *extensions.DeploymentStatus, condition extensions.DeploymentCondition)
SetDeploymentCondition updates the deployment to include the provided condition. If the condition that we are about to add already exists and has the same status and reason then we are not going to update.
func SetDeploymentRevision ¶
func SetDeploymentRevision(deployment *extensions.Deployment, revision string) bool
SetDeploymentRevision updates the revision for a deployment.
func SetFromReplicaSetTemplate ¶
func SetFromReplicaSetTemplate(deployment *extensions.Deployment, template v1.PodTemplateSpec) *extensions.Deployment
SetFromReplicaSetTemplate sets the desired PodTemplateSpec from a replica set template to the given deployment.
func SetNewReplicaSetAnnotations ¶
func SetNewReplicaSetAnnotations(deployment *extensions.Deployment, newRS *extensions.ReplicaSet, newRevision string, exists bool) bool
SetNewReplicaSetAnnotations sets new replica set's annotations appropriately by updating its revision and copying required deployment annotations to it; it returns true if replica set's annotation is changed.
func SetReplicasAnnotations ¶
func SetReplicasAnnotations(rs *extensions.ReplicaSet, desiredReplicas, maxReplicas int32) bool
SetReplicasAnnotations sets the desiredReplicas and maxReplicas into the annotations
func UpdatePodWithRetries ¶
func UpdatePodWithRetries(podClient v1core.PodInterface, podLister corelisters.PodLister, namespace, name string, applyUpdate updatePodFunc) (*v1.Pod, error)
UpdatePodWithRetries updates a pod with given applyUpdate function. Note that pod not found error is ignored. The returned bool value can be used to tell if the pod is actually updated.
func UpdateRSWithRetries ¶
func UpdateRSWithRetries(rsClient unversionedextensions.ReplicaSetInterface, rsLister extensionslisters.ReplicaSetLister, namespace, name string, applyUpdate updateRSFunc) (*extensions.ReplicaSet, error)
UpdateRSWithRetries updates a RS with given applyUpdate function. Note that RS not found error is ignored. The returned bool value can be used to tell if the RS is actually updated.
func WaitForObservedDeployment ¶
func WaitForObservedDeployment(getDeploymentFunc func() (*extensions.Deployment, error), desiredGeneration int64, interval, timeout time.Duration) error
WaitForObservedDeployment polls for deployment to be updated so that deployment.Status.ObservedGeneration >= desiredGeneration. Returns error if polling timesout.
func WaitForObservedDeploymentInternal ¶
func WaitForObservedDeploymentInternal(getDeploymentFunc func() (*internalextensions.Deployment, error), desiredGeneration int64, interval, timeout time.Duration) error
TODO: remove the duplicate WaitForObservedInternalDeployment polls for deployment to be updated so that deployment.Status.ObservedGeneration >= desiredGeneration. Returns error if polling timesout.
func WaitForPodsHashPopulated ¶
func WaitForPodsHashPopulated(c extensionslisters.ReplicaSetLister, desiredGeneration int64, namespace, name string) error
WaitForPodsHashPopulated polls the replica set until updated and fully labeled.
func WaitForReplicaSetUpdated ¶
func WaitForReplicaSetUpdated(c extensionslisters.ReplicaSetLister, desiredGeneration int64, namespace, name string) error
WaitForReplicaSetUpdated polls the replica set until it is updated.
Types ¶
type RsListFunc ¶
type RsListFunc func(string, metav1.ListOptions) ([]*extensions.ReplicaSet, error)
TODO: switch this to full namespacers
func RsListFromClient ¶
func RsListFromClient(c extensionsv1beta1.ExtensionsV1beta1Interface) RsListFunc
RsListFromClient returns an rsListFunc that wraps the given client.