Documentation ¶
Index ¶
- Constants
- func CountAvailablePodsForReplicaSets(podList *api.PodList, rss []*extensions.ReplicaSet, minReadySeconds int32) (int32, error)
- func DeploymentDeepCopy(deployment *extensions.Deployment) (*extensions.Deployment, 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, c clientset.Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, *extensions.ReplicaSet, ...)
- func GetAvailablePodsForDeployment(c clientset.Interface, deployment *extensions.Deployment, ...) (int32, error)
- func GetAvailablePodsForReplicaSets(c clientset.Interface, deployment *extensions.Deployment, ...) (int32, error)
- func GetDesiredReplicasAnnotation(rs *extensions.ReplicaSet) (int32, bool)
- func GetNewReplicaSet(deployment *extensions.Deployment, c clientset.Interface) (*extensions.ReplicaSet, error)
- func GetNewReplicaSetTemplate(deployment *extensions.Deployment) api.PodTemplateSpec
- func GetOldReplicaSets(deployment *extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error)
- func GetProportion(rs *extensions.ReplicaSet, d extensions.Deployment, ...) int32
- func GetReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
- func IsPodAvailable(pod *api.Pod, minReadySeconds int32, now time.Time) bool
- func IsRollingUpdate(deployment *extensions.Deployment) bool
- func IsSaturated(deployment *extensions.Deployment, rs *extensions.ReplicaSet) bool
- func LabelPodsWithHash(podList *api.PodList, rs *extensions.ReplicaSet, c clientset.Interface, ...) (bool, error)
- func LastRevision(allRSs []*extensions.ReplicaSet) int64
- func ListPods(deployment *extensions.Deployment, getPodList podListFunc) (*api.PodList, error)
- func ListReplicaSets(deployment *extensions.Deployment, getRSList rsListFunc) ([]extensions.ReplicaSet, error)
- func MaxRevision(allRSs []*extensions.ReplicaSet) int64
- func MaxSurge(deployment extensions.Deployment) int32
- func MaxUnavailable(deployment extensions.Deployment) int32
- func NewRSNewReplicas(deployment *extensions.Deployment, allRSs []*extensions.ReplicaSet, ...) (int32, error)
- func ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired int32) (int32, int32, error)
- func Revision(rs *extensions.ReplicaSet) (int64, error)
- func SetDeploymentAnnotationsTo(deployment *extensions.Deployment, rollbackToRS *extensions.ReplicaSet)
- func SetFromReplicaSetTemplate(deployment *extensions.Deployment, template api.PodTemplateSpec) *extensions.Deployment
- func SetNewReplicaSetAnnotations(deployment *extensions.Deployment, newRS *extensions.ReplicaSet, ...) bool
- func SetReplicasAnnotations(rs *extensions.ReplicaSet, desiredReplicas, maxReplicas int32) bool
- func WaitForObservedDeployment(getDeploymentFunc func() (*extensions.Deployment, error), ...) error
- func WaitForPodsHashPopulated(c clientset.Interface, desiredGeneration int64, namespace, name string) error
- func WaitForReplicaSetUpdated(c clientset.Interface, desiredGeneration int64, namespace, name string) error
Constants ¶
const ( // RevisionAnnotation is the revision annotation of a deployment's replica sets which records its rollout sequence RevisionAnnotation = "deployment.kubernetes.io/revision" // 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" )
Variables ¶
This section is empty.
Functions ¶
func CountAvailablePodsForReplicaSets ¶
func CountAvailablePodsForReplicaSets(podList *api.PodList, rss []*extensions.ReplicaSet, minReadySeconds int32) (int32, error)
CountAvailablePodsForReplicaSets returns the number of available pods corresponding to the given pod list and replica sets. Note that the input pod list should be the pods targeted by the deployment of input replica sets.
func DeploymentDeepCopy ¶
func DeploymentDeepCopy(deployment *extensions.Deployment) (*extensions.Deployment, error)
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, podList *api.PodList) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error)
FindOldReplicaSets returns the old replica sets targeted by the given Deployment, with the given PodList and 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 clientset.Interface) ([]*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 GetAvailablePodsForDeployment ¶
func GetAvailablePodsForDeployment(c clientset.Interface, deployment *extensions.Deployment, minReadySeconds int32) (int32, error)
GetAvailablePodsForDeployment returns the number of available pods (listed from clientset) corresponding to the given deployment.
func GetAvailablePodsForReplicaSets ¶
func GetAvailablePodsForReplicaSets(c clientset.Interface, deployment *extensions.Deployment, rss []*extensions.ReplicaSet, minReadySeconds int32) (int32, error)
GetAvailablePodsForReplicaSets returns the number of available pods (listed from clientset) corresponding to the given replica sets.
func GetDesiredReplicasAnnotation ¶
func GetDesiredReplicasAnnotation(rs *extensions.ReplicaSet) (int32, bool)
GetDesiredReplicasAnnotation returns the number of desired replicas
func GetNewReplicaSet ¶
func GetNewReplicaSet(deployment *extensions.Deployment, c clientset.Interface) (*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 GetNewReplicaSetTemplate ¶
func GetNewReplicaSetTemplate(deployment *extensions.Deployment) api.PodTemplateSpec
GetNewReplicaSetTemplate returns the desired PodTemplateSpec for the new ReplicaSet corresponding to the given ReplicaSet.
func GetOldReplicaSets ¶
func GetOldReplicaSets(deployment *extensions.Deployment, c clientset.Interface) ([]*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 GetReplicaCountForReplicaSets ¶
func GetReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32
GetReplicaCountForReplicaSets returns the sum of Replicas of the given replica sets.
func IsPodAvailable ¶
IsPodAvailable return true if the pod is available.
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.
func LabelPodsWithHash ¶
func LabelPodsWithHash(podList *api.PodList, rs *extensions.ReplicaSet, c clientset.Interface, namespace, hash string) (bool, error)
LabelPodsWithHash labels all pods in the given podList with the new hash label. The returned bool value can be used to tell if all pods are actually labeled.
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, getPodList podListFunc) (*api.PodList, error)
ListPods returns a list of pods the given deployment targets.
func ListReplicaSets ¶
func ListReplicaSets(deployment *extensions.Deployment, getRSList rsListFunc) ([]extensions.ReplicaSet, error)
ListReplicaSets returns a slice of RSes the given deployment targets.
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 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 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 Revision ¶
func Revision(rs *extensions.ReplicaSet) (int64, error)
Revision returns the revision number of the input replica set
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 SetFromReplicaSetTemplate ¶
func SetFromReplicaSetTemplate(deployment *extensions.Deployment, template api.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 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.
Types ¶
This section is empty.