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 ¶
- 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) 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
- func (d *Deploy) VerifyReplicaStatus() error
- type Kubeclient
- func (k *Kubeclient) Create(deployment *appsv1.Deployment) (*appsv1.Deployment, error)
- func (k *Kubeclient) Delete(name string, opts *metav1.DeleteOptions) error
- func (k *Kubeclient) Get(name string) (*appsv1.Deployment, error)
- func (k *Kubeclient) GetRaw(name string) ([]byte, error)
- func (k *Kubeclient) List(opts *metav1.ListOptions) (*appsv1.DeploymentList, error)
- func (k *Kubeclient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*appsv1.Deployment, error)
- func (k *Kubeclient) RolloutStatus(name string) (*RolloutOutput, error)
- func (k *Kubeclient) RolloutStatusf(name string) (op []byte, err error)
- func (k *Kubeclient) Update(deployment *appsv1.Deployment) (*appsv1.Deployment, error)
- func (k *Kubeclient) WithNamespace(namespace string) *Kubeclient
- type KubeclientBuildOption
- 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
func (*Deploy) VerifyReplicaStatus ¶
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 ¶
func (k *Kubeclient) List(opts *metav1.ListOptions) (*appsv1.DeploymentList, error)
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 ¶
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