Documentation ¶
Index ¶
- type Builder
- func (b *Builder) AddCheck(p Predicate) *Builder
- func (b *Builder) AddChecks(p []Predicate) *Builder
- func (b *Builder) Build() (*appsv1.Deployment, error)
- func (b *Builder) WithAnnotations(annotations map[string]string) *Builder
- func (b *Builder) WithAnnotationsNew(annotations map[string]string) *Builder
- func (b *Builder) WithLabels(labels map[string]string) *Builder
- func (b *Builder) WithLabelsNew(labels map[string]string) *Builder
- func (b *Builder) WithName(name string) *Builder
- func (b *Builder) WithNamespace(namespace string) *Builder
- func (b *Builder) WithNodeSelector(selector map[string]string) *Builder
- func (b *Builder) WithNodeSelectorNew(selector map[string]string) *Builder
- func (b *Builder) WithOwnerReferenceNew(ownerRefernce []metav1.OwnerReference) *Builder
- func (b *Builder) WithPodTemplateSpecBuilder(tmplbuilder *templatespec.Builder) *Builder
- func (b *Builder) WithReplicas(replicas *int32) *Builder
- func (b *Builder) WithSelectorMatchLabels(matchlabels map[string]string) *Builder
- func (b *Builder) WithSelectorMatchLabelsNew(matchlabels map[string]string) *Builder
- func (b *Builder) WithStrategyType(strategytype appsv1.DeploymentStrategyType) *Builder
- type Deploy
- func (d *Deploy) FailedRollout(name PredicateName) *RolloutOutput
- 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) SuccessRollout() *RolloutOutput
- type Predicate
- type PredicateName
- type Rollout
- type RolloutOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 (*Builder) AddCheck ¶
AddCheck adds the predicate as a condition to be validated against the deployment instance
func (*Builder) AddChecks ¶
AddChecks adds the provided predicates as conditions to be validated against the deployment instance
func (*Builder) Build ¶
func (b *Builder) Build() (*appsv1.Deployment, error)
Build returns a deployment instance
func (*Builder) WithAnnotations ¶
WithAnnotations merges existing annotations if any with the ones that are provided here
func (*Builder) WithAnnotationsNew ¶
WithAnnotationsNew resets existing annotaions if any with ones that are provided here
func (*Builder) WithLabels ¶
WithLabels merges existing labels if any with the ones that are provided here
func (*Builder) WithLabelsNew ¶
WithLabelsNew resets existing labels if any with ones that are provided here
func (*Builder) WithNamespace ¶
WithNamespace sets the Namespace field of deployment with provided value.
func (*Builder) WithNodeSelector ¶
WithNodeSelector Sets the node selector with the provided argument.
func (*Builder) WithNodeSelectorNew ¶
WithNodeSelector Sets the node selector with the provided argument.
func (*Builder) WithOwnerReferenceNew ¶
func (b *Builder) WithOwnerReferenceNew(ownerRefernce []metav1.OwnerReference) *Builder
WithOwnerReferenceNew sets ownerreference if any with ones that are provided here
func (*Builder) WithPodTemplateSpecBuilder ¶
func (b *Builder) WithPodTemplateSpecBuilder( tmplbuilder *templatespec.Builder, ) *Builder
WithPodTemplateSpecBuilder sets the template field of the deployment
func (*Builder) WithReplicas ¶
WithReplicas sets the replica field of deployment
func (*Builder) WithSelectorMatchLabels ¶
WithSelectorMatchLabels merges existing matchlabels if any with the ones that are provided here
func (*Builder) WithSelectorMatchLabelsNew ¶
WithSelectorMatchLabelsNew resets existing matchlabels if any with ones that are provided here
func (*Builder) WithStrategyType ¶
func (b *Builder) WithStrategyType( strategytype appsv1.DeploymentStrategyType, ) *Builder
WithStrategyType sets the strategy field of the deployment
type Deploy ¶
type Deploy struct {
// contains filtered or unexported fields
}
Deploy is the wrapper over k8s deployment Object
func NewForAPIObject ¶
func NewForAPIObject( obj *appsv1.Deployment, opts ...deployBuildOption, ) *Deploy
NewForAPIObject returns a new instance of builder for a given 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 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