{"modulePath":"github.com/stackpointcloud/kubernetes","version":"v1.4.0-alpha.2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package util\n\n## Constants\n\n```go\nconst (\n\t// RevisionAnnotation is the revision annotation of a deployment's replica sets which records its rollout sequence\n\tRevisionAnnotation = \"deployment.kubernetes.io/revision\"\n\t// DesiredReplicasAnnotation is the desired replicas for a deployment recorded as an annotation\n\t// in its replica sets. Helps in separating scaling events from the rollout process and for\n\t// determining if the new replica set for a deployment is really saturated.\n\tDesiredReplicasAnnotation = \"deployment.kubernetes.io/desired-replicas\"\n\t// MaxReplicasAnnotation is the maximum replicas a deployment can have at a given point, which\n\t// is deployment.spec.replicas + maxSurge. Used by the underlying replica sets to estimate their\n\t// proportions in case the deployment has surge replicas.\n\tMaxReplicasAnnotation = \"deployment.kubernetes.io/max-replicas\"\n\n\t// RollbackRevisionNotFound is not found rollback event reason\n\tRollbackRevisionNotFound = \"DeploymentRollbackRevisionNotFound\"\n\t// RollbackTemplateUnchanged is the template unchanged rollback event reason\n\tRollbackTemplateUnchanged = \"DeploymentRollbackTemplateUnchanged\"\n\t// RollbackDone is the done rollback event reason\n\tRollbackDone = \"DeploymentRollback\"\n)\n```\n\n## Functions\n\n```go\nfunc CountAvailablePodsForReplicaSets(podList *api.PodList, rss []*extensions.ReplicaSet, minReadySeconds int32) (int32, error)\n```\nCountAvailablePodsForReplicaSets 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.\n\n```go\nfunc DeploymentDeepCopy(deployment *extensions.Deployment) (*extensions.Deployment, error)\n```\n\n```go\nfunc FindActiveOrLatest(newRS *extensions.ReplicaSet, oldRSs []*extensions.ReplicaSet) *extensions.ReplicaSet\n```\nFindActiveOrLatest 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.\n\n```go\nfunc FindNewReplicaSet(deployment *extensions.Deployment, rsList []extensions.ReplicaSet) (*extensions.ReplicaSet, error)\n```\nFindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template).\n\n```go\nfunc FindOldReplicaSets(deployment *extensions.Deployment, rsList []extensions.ReplicaSet, podList *api.PodList) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error)\n```\nFindOldReplicaSets 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.\n\n```go\nfunc GetActualReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32\n```\nGetActualReplicaCountForReplicaSets returns the sum of actual replicas of the given replica sets.\n\n```go\nfunc GetAllReplicaSets(deployment *extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, *extensions.ReplicaSet, error)\n```\nGetAllReplicaSets 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.\n\n```go\nfunc GetAvailablePodsForDeployment(c clientset.Interface, deployment *extensions.Deployment, minReadySeconds int32) (int32, error)\n```\nGetAvailablePodsForDeployment returns the number of available pods (listed from clientset) corresponding to the given deployment.\n\n```go\nfunc GetAvailablePodsForReplicaSets(c clientset.Interface, deployment *extensions.Deployment, rss []*extensions.ReplicaSet, minReadySeconds int32) (int32, error)\n```\nGetAvailablePodsForReplicaSets returns the number of available pods (listed from clientset) corresponding to the given replica sets.\n\n```go\nfunc GetDesiredReplicasAnnotation(rs *extensions.ReplicaSet) (int32, bool)\n```\nGetDesiredReplicasAnnotation returns the number of desired replicas\n\n```go\nfunc GetNewReplicaSet(deployment *extensions.Deployment, c clientset.Interface) (*extensions.ReplicaSet, error)\n```\nGetNewReplicaSet 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.\n\n```go\nfunc GetNewReplicaSetTemplate(deployment *extensions.Deployment) api.PodTemplateSpec\n```\nGetNewReplicaSetTemplate returns the desired PodTemplateSpec for the new ReplicaSet corresponding to the given ReplicaSet.\n\n```go\nfunc GetOldReplicaSets(deployment *extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error)\n```\nGetOldReplicaSets 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.\n\n```go\nfunc GetProportion(rs *extensions.ReplicaSet, d extensions.Deployment, deploymentReplicasToAdd, deploymentReplicasAdded int32) int32\n```\nGetProportion 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.\n\n```go\nfunc GetReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32\n```\nGetReplicaCountForReplicaSets returns the sum of Replicas of the given replica sets.\n\n```go\nfunc IsPodAvailable(pod *api.Pod, minReadySeconds int32, now time.Time) bool\n```\nIsPodAvailable return true if the pod is available.\n\n```go\nfunc IsRollingUpdate(deployment *extensions.Deployment) bool\n```\nIsRollingUpdate returns true if the strategy type is a rolling update.\n\n```go\nfunc IsSaturated(deployment *extensions.Deployment, rs *extensions.ReplicaSet) bool\n```\nIsSaturated 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.\n\n```go\nfunc LabelPodsWithHash(podList *api.PodList, rs *extensions.ReplicaSet, c clientset.Interface, namespace, hash string) (bool, error)\n```\nLabelPodsWithHash 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.\n\n```go\nfunc LastRevision(allRSs []*extensions.ReplicaSet) int64\n```\nLastRevision finds the second max revision number in all replica sets (the last revision)\n\n```go\nfunc ListPods(deployment *extensions.Deployment, getPodList podListFunc) (*api.PodList, error)\n```\nListPods returns a list of pods the given deployment targets.\n\n```go\nfunc ListReplicaSets(deployment *extensions.Deployment, getRSList rsListFunc) ([]extensions.ReplicaSet, error)\n```\nListReplicaSets returns a slice of RSes the given deployment targets.\n\n```go\nfunc MaxRevision(allRSs []*extensions.ReplicaSet) int64\n```\nMaxRevision finds the highest revision in the replica sets\n\n```go\nfunc MaxSurge(deployment extensions.Deployment) int32\n```\nMaxSurge returns the maximum surge pods a rolling deployment can take.\n\n```go\nfunc MaxUnavailable(deployment extensions.Deployment) int32\n```\nMaxUnavailable returns the maximum unavailable pods a rolling deployment can take.\n\n```go\nfunc NewRSNewReplicas(deployment *extensions.Deployment, allRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaSet) (int32, error)\n```\nNewRSNewReplicas 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\n\n```go\nfunc ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired int32) (int32, int32, error)\n```\nResolveFenceposts resolves both maxSurge and maxUnavailable. This needs to happen in one step. For example:\n\n2 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)\n\n```go\nfunc Revision(rs *extensions.ReplicaSet) (int64, error)\n```\nRevision returns the revision number of the input replica set\n\n```go\nfunc SetDeploymentAnnotationsTo(deployment *extensions.Deployment, rollbackToRS *extensions.ReplicaSet)\n```\nSetDeploymentAnnotationsTo 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.\n\n```go\nfunc SetFromReplicaSetTemplate(deployment *extensions.Deployment, template api.PodTemplateSpec) *extensions.Deployment\n```\nSetFromReplicaSetTemplate sets the desired PodTemplateSpec from a replica set template to the given deployment.\n\n```go\nfunc SetNewReplicaSetAnnotations(deployment *extensions.Deployment, newRS *extensions.ReplicaSet, newRevision string, exists bool) bool\n```\nSetNewReplicaSetAnnotations 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.\n\n```go\nfunc SetReplicasAnnotations(rs *extensions.ReplicaSet, desiredReplicas, maxReplicas int32) bool\n```\nSetReplicasAnnotations sets the desiredReplicas and maxReplicas into the annotations\n\n```go\nfunc WaitForObservedDeployment(getDeploymentFunc func() (*extensions.Deployment, error), desiredGeneration int64, interval, timeout time.Duration) error\n```\nWaitForObservedDeployment polls for deployment to be updated so that deployment.Status.ObservedGeneration \u003e= desiredGeneration. Returns error if polling timesout.\n\n```go\nfunc WaitForPodsHashPopulated(c clientset.Interface, desiredGeneration int64, namespace, name string) error\n```\nWaitForPodsHashPopulated polls the replica set until updated and fully labeled.\n\n```go\nfunc WaitForReplicaSetUpdated(c clientset.Interface, desiredGeneration int64, namespace, name string) error\n```\nWaitForReplicaSetUpdated polls the replica set until it is updated.\n\n","path":"github.com/stackpointcloud/kubernetes/pkg/controller/deployment/util","name":"util","synopsis":"","isRedistributable":true}
