workload

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatePartitionReplicas

func CalculatePartitionReplicas(totalReplicas *int32, partition intstr.IntOrString) (int32, error)

func GetClusterFromLabel

func GetClusterFromLabel(labels map[string]string) string

func IsWaitingRollout added in v0.1.1

func IsWaitingRollout(info Info) bool

func PatchMetadata added in v0.1.0

func PatchMetadata(meta *metav1.ObjectMeta, patch rolloutv1alpha1.MetadataPatch)

PatchMetadata patches metadata with the given patch

Types

type Accessor added in v0.1.1

type Accessor interface {
	GroupVersionKind() schema.GroupVersionKind
	// NewObject returns a new instance of the workload type
	NewObject() client.Object
	// NewObjectList returns a new instance of the workload list type
	NewObjectList() client.ObjectList
	// Watchable indicates whether this workload type can be watched from the API server.
	Watchable() bool
	// GetInfo returns a info represent workload
	GetInfo(cluster string, obj client.Object) (*Info, error)
	// ReleaseControl returns the release control for the workload
	ReleaseControl() ReleaseControl
}

Accessor defines the functions to access the workload.

type Info

type Info struct {
	metav1.ObjectMeta
	// GVK is the GroupVersionKind of the workload.
	schema.GroupVersionKind
	// Status is the status of the workload.
	Status InfoStatus
	// Object is the object representing the workload.
	Object client.Object
}

workload info

func Get added in v0.1.1

func Get(ctx context.Context, c client.Client, inter Accessor, cluster, namespace, name string) (*Info, error)

func List added in v0.1.1

func List(ctx context.Context, c client.Client, inter Accessor, namespace string, match rolloutv1alpha1.ResourceMatch) ([]*Info, error)

func NewInfo

func NewInfo(cluster string, gvk schema.GroupVersionKind, obj client.Object, status InfoStatus) *Info

func (*Info) APIStatus added in v0.1.0

func (*Info) CheckUpdatedReady added in v0.1.1

func (o *Info) CheckUpdatedReady(replicas int32) bool

func (*Info) NamespacedName added in v0.1.0

func (o *Info) NamespacedName() types.NamespacedName

func (*Info) String added in v0.1.0

func (o *Info) String() string

func (*Info) UpdateOnConflict added in v0.1.1

func (o *Info) UpdateOnConflict(ctx context.Context, client client.Client, mutateFn func(client.Object) error) (bool, error)

type InfoStatus added in v0.1.1

type InfoStatus struct {
	// ObservedGeneration is the most recent generation observed for this workload.
	ObservedGeneration int64
	// StableRevision is the old stable revision used to generate pods.
	StableRevision string
	// UpdatedRevision is the updated template revision used to generate pods.
	UpdatedRevision string
	// Replicas is the desired number of pods targeted by workload
	Replicas int32
	// UpdatedReplicas is the number of pods targeted by workload that have the updated template spec.
	UpdatedReplicas int32
	// UpdatedReadyReplicas is the number of ready pods targeted by workload that have the updated template spec.
	UpdatedReadyReplicas int32
	// UpdatedAvailableReplicas is the number of service available pods targeted by workload that have the updated template spec.
	UpdatedAvailableReplicas int32
}

workload status

type Matcher added in v0.1.1

type Matcher interface {
	Matches(cluster, name string, label map[string]string) bool
}

func MatchAsMatcher

func MatchAsMatcher(match rolloutv1alpha1.ResourceMatch) Matcher

type Registry added in v0.1.1

type Registry interface {
	// SetupWithManger initialize registry with manager.
	SetupWithManger(mgr manager.Manager)
	// Register add a new workload Accessor for given gvk
	Register(accessor Accessor)
	// Delete delete a new workload Accessor for given gvk
	Delete(gvk schema.GroupVersionKind)
	// If the gvk is registered and supported by all member clusters, Get returns the workload Accessor.
	Get(gvk schema.GroupVersionKind) (Accessor, error)
	// Watchables return all watchable and supported Accessor.
	Watchables() []Accessor
}

func NewRegistry added in v0.1.1

func NewRegistry() Registry

type ReleaseControl added in v0.1.1

type ReleaseControl interface {
	// BatchPreCheck checks object before batch release.
	BatchPreCheck(obj client.Object) error
	// ApplyPartition applies partition to the workload
	ApplyPartition(obj client.Object, partition intstr.IntOrString) error
	// CanaryPreCheck checks object before canary release.
	CanaryPreCheck(obj client.Object) error
	// Scale scales the workload replicas.
	Scale(obj client.Object, replicas int32) error
	// ApplyCanaryPatch applies canary to the workload.
	ApplyCanaryPatch(canary client.Object, podTemplatePatch *v1alpha1.MetadataPatch) error
}

ReleaseControl defines the control functions for workload release

type Set

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

func NewSet added in v0.1.1

func NewSet(workloads ...*Info) *Set

func (*Set) Get

func (s *Set) Get(cluster, name string) *Info

func (*Set) ToSlice

func (s *Set) ToSlice() []*Info

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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