Documentation ¶
Index ¶
- Variables
- type Builder
- type Deploy
- func (d *Deploy) FailedRollout(name PredicateName) *RolloutOutput
- func (d *Deploy) GoString() string
- func (d *Deploy) IsNotSyncSpec() bool
- func (d *Deploy) IsOlderReplicaActive() bool
- func (d *Deploy) IsProgressDeadlineExceeded() bool
- func (d *Deploy) IsRollout() (PredicateName, bool)
- func (d *Deploy) IsTerminationInProgress() bool
- func (d *Deploy) IsUpdateInProgress() bool
- func (d *Deploy) RolloutStatus() (op *RolloutOutput, err error)
- func (d *Deploy) RolloutStatusRaw() (op []byte, err error)
- func (d *Deploy) String() string
- func (d *Deploy) SuccessRollout() *RolloutOutput
- type Kubeclient
- type KubeclientBuildOption
- type Predicate
- type PredicateName
- type Rollout
- type RolloutOutput
- type RolloutStatus
Constants ¶
This section is empty.
Variables ¶
var RolloutChecks = map[PredicateName]Predicate{ PredicateProgressDeadlineExceeded: IsProgressDeadlineExceeded(), PredicateOlderReplicaActive: IsOlderReplicaActive(), PredicateTerminationInProgress: IsTerminationInProgress(), PredicateUpdateInProgress: IsUpdateInProgress(), PredicateNotSpecSynced: IsNotSyncSpec(), }
RolloutChecks contains a group of predicate it uses predicateName as key.
var RolloutStatuses = map[PredicateName]RolloutStatus{ PredicateProgressDeadlineExceeded: func(d *Deploy) string { return "deployment exceeded its progress deadline" }, PredicateOlderReplicaActive: func(d *Deploy) string { if d.object.Spec.Replicas == nil { return "replica update in-progress: some older replicas were updated" } return fmt.Sprintf( "replica update in-progress: %d of %d new replicas were updated", d.object.Status.UpdatedReplicas, *d.object.Spec.Replicas) }, PredicateTerminationInProgress: func(d *Deploy) string { return fmt.Sprintf( "replica termination in-progress: %d old replicas are pending termination", d.object.Status.Replicas-d.object.Status.UpdatedReplicas) }, PredicateUpdateInProgress: func(d *Deploy) string { return fmt.Sprintf( "replica update in-progress: %d of %d updated replicas are available", d.object.Status.AvailableReplicas, d.object.Status.UpdatedReplicas) }, PredicateNotSpecSynced: func(d *Deploy) string { return "deployment rollout in-progress: waiting for deployment spec update" }, }
RolloutStatuses contains a group of status message for each predicate checks. It uses predicateName as key.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder enables building an instance of deployment
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder returns a new instance of builder meant for deployment
func NewBuilderForAPIObject ¶
func NewBuilderForAPIObject(deployment *extnv1beta1.Deployment) *Builder
NewBuilderForAPIObject returns a new instance of builder for a given deployment object
func (*Builder) AddCheck ¶
AddCheck adds the predicate as a condition to be validated against the deployment instance
type Deploy ¶
type Deploy struct {
// contains filtered or unexported fields
}
Deploy is the wrapper over k8s deployment object
func (*Deploy) FailedRollout ¶
func (d *Deploy) FailedRollout(name PredicateName) *RolloutOutput
FailedRollout returns rollout status message for fail condition
func (*Deploy) IsNotSyncSpec ¶
IsNotSyncSpec compare generation in status and spec and check if deployment spec is synced or not. If Generation <= Status.ObservedGeneration then deployment spec is not updated yet.
func (*Deploy) IsOlderReplicaActive ¶
IsOlderReplicaActive check if older replica's are still active or not if Status.UpdatedReplicas < *Spec.Replicas then some of the replicas are updated and some of them are not.
func (*Deploy) IsProgressDeadlineExceeded ¶
IsProgressDeadlineExceeded is used to check update is timed out or not. If `Progressing` condition's reason is `ProgressDeadlineExceeded` then it is not rolled out.
func (*Deploy) IsRollout ¶
func (d *Deploy) IsRollout() (PredicateName, bool)
IsRollout range over rolloutChecks map and check status of each predicate also it generates status message from rolloutStatuses using predicate key
func (*Deploy) IsTerminationInProgress ¶
IsTerminationInProgress checks for older replicas are waiting to terminate or not. If Status.Replicas > Status.UpdatedReplicas then some of the older replicas are in running state because newer replicas are not in running state. It waits for newer replica to come into running state then terminate.
func (*Deploy) IsUpdateInProgress ¶
IsUpdateInProgress Checks if all the replicas are updated or not. If Status.AvailableReplicas < Status.UpdatedReplicas then all the older replicas are not there but there are less number of availableReplicas
func (*Deploy) RolloutStatus ¶
func (d *Deploy) RolloutStatus() (op *RolloutOutput, err error)
RolloutStatus returns rollout message of deployment instance
func (*Deploy) RolloutStatusRaw ¶
RolloutStatusRaw returns rollout message of deployment instance in byte format
func (*Deploy) SuccessRollout ¶
func (d *Deploy) SuccessRollout() *RolloutOutput
SuccessRollout returns rollout status message for success condition
type Kubeclient ¶
type Kubeclient struct {
// contains filtered or unexported fields
}
Kubeclient enables kubernetes API operations on deployment instance
func KubeClient ¶
func KubeClient(opts ...KubeclientBuildOption) *Kubeclient
KubeClient returns a new instance of kubeclient meant for deployment. caller can configure it with different kubeclientBuildOption
func (*Kubeclient) Get ¶
func (k *Kubeclient) Get(name string) (*extnv1beta1.Deployment, error)
Get returns deployment object for given name
func (*Kubeclient) GetRaw ¶
func (k *Kubeclient) GetRaw(name string) ([]byte, error)
GetRaw returns deployment object for given name in byte format
func (*Kubeclient) RolloutStatus ¶
func (k *Kubeclient) RolloutStatus(name string) (*RolloutOutput, error)
RolloutStatus returns deployment's rollout status for given name
func (*Kubeclient) RolloutStatusf ¶
func (k *Kubeclient) RolloutStatusf(name string) ([]byte, error)
RolloutStatusf returns deployment's rollout status for given name in raw bytes
type KubeclientBuildOption ¶
type KubeclientBuildOption func(*Kubeclient)
KubeclientBuildOption defines the abstraction to build a kubeclient instance
func WithClientset ¶
func WithClientset(c *kubernetes.Clientset) KubeclientBuildOption
WithClientset sets the kubernetes client against the kubeclient instance
func WithNamespace ¶
func WithNamespace(namespace string) KubeclientBuildOption
WithNamespace set namespace in kubeclient object
type Predicate ¶
Predicate abstracts conditional logic w.r.t the deployment instance
NOTE: predicate is a functional approach versus traditional approach to mix conditions such as *if-else* within blocks of business logic
NOTE: predicate approach enables clear separation of conditionals from imperatives i.e. actions that form the business logic
func IsNotSyncSpec ¶
func IsNotSyncSpec() Predicate
IsNotSyncSpec compare generation in status and spec and check if deployment spec is synced or not. If Generation <= Status.ObservedGeneration then deployment spec is not updated yet.
func IsOlderReplicaActive ¶
func IsOlderReplicaActive() Predicate
IsOlderReplicaActive check if older replica's are still active or not if Status.UpdatedReplicas < *Spec.Replicas then some of the replicas are updated and some of them are not.
func IsProgressDeadlineExceeded ¶
func IsProgressDeadlineExceeded() Predicate
IsProgressDeadlineExceeded is used to check update is timed out or not. If `Progressing` condition's reason is `ProgressDeadlineExceeded` then it is not rolled out.
func IsTerminationInProgress ¶
func IsTerminationInProgress() Predicate
IsTerminationInProgress checks for older replicas are waiting to terminate or not. If Status.Replicas > Status.UpdatedReplicas then some of the older replicas are in running state because newer replicas are not in running state. It waits for newer replica to come into running state then terminate.
func IsUpdateInProgress ¶
func IsUpdateInProgress() Predicate
IsUpdateInProgress Checks if all the replicas are updated or not. If Status.AvailableReplicas < Status.UpdatedReplicas then all the older replicas are not there but there are less number of availableReplicas
type PredicateName ¶
type PredicateName string
PredicateName type is wrapper over string. It is used to refer predicate and status msg.
const ( // PredicateProgressDeadlineExceeded refer to // predicate IsProgressDeadlineExceeded. PredicateProgressDeadlineExceeded PredicateName = "ProgressDeadlineExceeded" // PredicateNotSpecSynced refer to predicate IsNotSpecSynced PredicateNotSpecSynced PredicateName = "NotSpecSynced" // PredicateOlderReplicaActive refer to predicate IsOlderReplicaActive PredicateOlderReplicaActive PredicateName = "OlderReplicaActive" // PredicateTerminationInProgress refer to predicate IsTerminationInProgress PredicateTerminationInProgress PredicateName = "TerminationInProgress" // PredicateUpdateInProgress refer to predicate IsUpdateInProgress. PredicateUpdateInProgress PredicateName = "UpdateInProgress" )
type Rollout ¶
type Rollout struct {
// contains filtered or unexported fields
}
Rollout enables getting various output format of rolloutOutput
func NewRollout ¶
func NewRollout(opts ...rolloutBuildOption) *Rollout
NewRollout returns new instance of rollout meant for rolloutOutput. caller can configure it with different rolloutOutputBuildOption
type RolloutOutput ¶
RolloutOutput struct contains message and boolean value to show rolloutstatus
type RolloutStatus ¶
RolloutStatus is a typed function that abstracts status message formation logic