v1alpha1

package
v1.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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

func (b *Builder) AddCheck(p Predicate) *Builder

AddCheck adds the predicate as a condition to be validated against the deployment instance

func (*Builder) AddChecks

func (b *Builder) AddChecks(p []Predicate) *Builder

AddChecks adds the provided predicates as conditions to be validated against the deployment instance

func (*Builder) Build

func (b *Builder) Build() (*Deploy, error)

Build returns a 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) GoString

func (d *Deploy) GoString() string

GoString implements the goStringer interface

func (*Deploy) IsNotSyncSpec

func (d *Deploy) IsNotSyncSpec() bool

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

func (d *Deploy) IsOlderReplicaActive() bool

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

func (d *Deploy) IsProgressDeadlineExceeded() bool

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

func (d *Deploy) IsTerminationInProgress() bool

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

func (d *Deploy) IsUpdateInProgress() bool

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

func (d *Deploy) RolloutStatusRaw() (op []byte, err error)

RolloutStatusRaw returns rollout message of deployment instance in byte format

func (*Deploy) String

func (d *Deploy) String() string

String implements the stringer interface

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

type Predicate func(*Deploy) bool

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

func (*Rollout) Raw

func (r *Rollout) Raw() ([]byte, error)

Raw returns raw bytes outpot of rollout

type RolloutOutput

type RolloutOutput struct {
	IsRolledout bool   `json:"isRolledout"`
	Message     string `json:"message"`
}

RolloutOutput struct contains message and boolean value to show rolloutstatus

type RolloutStatus

type RolloutStatus func(*Deploy) string

RolloutStatus is a typed function that abstracts status message formation logic

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL