v1alpha1

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: Apache-2.0 Imports: 12 Imported by: 10

Documentation

Overview

Copyright 2019 The OpenEBS Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

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

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() (*appsv1.Deployment, error)

Build returns a deployment instance

func (*Builder) WithAnnotations

func (b *Builder) WithAnnotations(annotations map[string]string) *Builder

WithAnnotations merges existing annotations if any with the ones that are provided here

func (*Builder) WithAnnotationsNew

func (b *Builder) WithAnnotationsNew(annotations map[string]string) *Builder

WithAnnotationsNew resets existing annotaions if any with ones that are provided here

func (*Builder) WithLabels

func (b *Builder) WithLabels(labels map[string]string) *Builder

WithLabels merges existing labels if any with the ones that are provided here

func (*Builder) WithLabelsNew

func (b *Builder) WithLabelsNew(labels map[string]string) *Builder

WithLabelsNew resets existing labels if any with ones that are provided here

func (*Builder) WithName

func (b *Builder) WithName(name string) *Builder

WithName sets the Name field of deployment with provided value.

func (*Builder) WithNamespace

func (b *Builder) WithNamespace(namespace string) *Builder

WithNamespace sets the Namespace field of deployment with provided value.

func (*Builder) WithNodeSelector

func (b *Builder) WithNodeSelector(selector map[string]string) *Builder

WithNodeSelector Sets the node selector with the provided argument.

func (*Builder) WithNodeSelectorNew

func (b *Builder) WithNodeSelectorNew(selector map[string]string) *Builder

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

func (b *Builder) WithReplicas(replicas *int32) *Builder

WithReplicas sets the replica field of deployment

func (*Builder) WithSelectorMatchLabels

func (b *Builder) WithSelectorMatchLabels(matchlabels map[string]string) *Builder

WithSelectorMatchLabels merges existing matchlabels if any with the ones that are provided here

func (*Builder) WithSelectorMatchLabelsNew

func (b *Builder) WithSelectorMatchLabelsNew(matchlabels map[string]string) *Builder

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) 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

func (*Deploy) VerifyReplicaStatus

func (d *Deploy) VerifyReplicaStatus() error

VerifyReplicaStatus verifies whether all the replicas of the deployment are up and running

type Kubeclient

type Kubeclient struct {
	// contains filtered or unexported fields
}

Kubeclient enables kubernetes API operations on deployment instance

func NewKubeClient

func NewKubeClient(opts ...KubeclientBuildOption) *Kubeclient

NewKubeClient returns a new instance of kubeclient meant for deployment. caller can configure it with different kubeclientBuildOption

func (*Kubeclient) Create

func (k *Kubeclient) Create(deployment *appsv1.Deployment) (*appsv1.Deployment, error)

Create creates a deployment in specified namespace in kubernetes cluster

func (*Kubeclient) Delete

func (k *Kubeclient) Delete(name string, opts *metav1.DeleteOptions) error

Delete deletes a deployment instance from the kubernetes cluster

func (*Kubeclient) Get

func (k *Kubeclient) Get(name string) (*appsv1.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

func (*Kubeclient) List

List returns deployment object for given name

func (*Kubeclient) Patch

func (k *Kubeclient) Patch(
	name string,
	pt types.PatchType,
	data []byte,
	subresources ...string,
) (*appsv1.Deployment, error)

Patch patches deployment object for given name

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) (op []byte, err error)

RolloutStatusf returns deployment's rollout status for given name in raw bytes

func (*Kubeclient) Update

func (k *Kubeclient) Update(deployment *appsv1.Deployment) (*appsv1.Deployment, error)

Update updates a deployment in specified namespace in kubernetes cluster

func (*Kubeclient) WithNamespace

func (k *Kubeclient) WithNamespace(namespace string) *Kubeclient

WithNamespace sets the kubernetes client against the provided namespace

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 WithKubeConfigPath

func WithKubeConfigPath(path string) KubeclientBuildOption

WithKubeConfigPath sets the kubeConfig path against client 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

Jump to

Keyboard shortcuts

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