core

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion   = "zalando.org/v1"
	KindStackSet = "StackSet"
	KindStack    = "Stack"
)
View Source
const (
	StacksetHeritageLabelKey = "stackset"
	StackVersionLabelKey     = "stack-version"
)

Variables

This section is empty.

Functions

func IsResourceUpToDate

func IsResourceUpToDate(stack *zv1.Stack, resourceMeta metav1.ObjectMeta) bool

IsResourceUpToDate checks whether the stack is assigned to the resource by comparing the stack generation with the corresponding resource annotation.

Types

type MetricsList

type MetricsList []autoscaling.MetricSpec

func (MetricsList) Len

func (l MetricsList) Len() int

func (MetricsList) Less

func (l MetricsList) Less(i, j int) bool

func (MetricsList) Swap

func (l MetricsList) Swap(i, j int)

type MetricsReporter

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

func NewMetricsReporter

func NewMetricsReporter(registry prometheus.Registerer) (*MetricsReporter, error)

func (*MetricsReporter) Report

func (reporter *MetricsReporter) Report(stacksets map[types.UID]*StackSetContainer) error

type PrescalingTrafficReconciler

type PrescalingTrafficReconciler struct {
	ResetHPAMinReplicasTimeout time.Duration
}

PrescalingTrafficReconciler is a traffic reconciler that forcibly scales up the deployment before switching traffic

func (PrescalingTrafficReconciler) Reconcile

func (r PrescalingTrafficReconciler) Reconcile(stacks map[string]*StackContainer, currentTimestamp time.Time) error

type SimpleTrafficReconciler

type SimpleTrafficReconciler struct{}

SimpleTrafficReconciler is the most simple traffic reconciler which implements the default traffic switching supported in the stackset-controller.

func (SimpleTrafficReconciler) Reconcile

func (SimpleTrafficReconciler) Reconcile(stacks map[string]*StackContainer, currentTimestamp time.Time) error

type StackContainer

type StackContainer struct {
	// Stack represents the desired state of the stack, updated by the reconciliation logic
	Stack *zv1.Stack

	// PendingRemoval is set to true if the stack should be deleted
	PendingRemoval bool

	// Resources contains Kubernetes entities for the Stack's resources (Deployment, Ingress, etc)
	Resources StackResources
	// contains filtered or unexported fields
}

StackContainer is a container for storing the full state of a Stack including all the managed sub-resources. This includes the Stack resource itself and all the sub resources like Deployment, HPA and Service.

func (*StackContainer) GenerateDeployment

func (sc *StackContainer) GenerateDeployment() *appsv1.Deployment

func (*StackContainer) GenerateHPA

func (*StackContainer) GenerateIngress

func (sc *StackContainer) GenerateIngress() (*extensions.Ingress, error)

func (*StackContainer) GenerateService

func (sc *StackContainer) GenerateService() (*v1.Service, error)

func (*StackContainer) GenerateStackStatus

func (sc *StackContainer) GenerateStackStatus() *zv1.StackStatus

func (*StackContainer) HasBackendPort added in v1.1.0

func (sc *StackContainer) HasBackendPort() bool

func (*StackContainer) HasTraffic

func (sc *StackContainer) HasTraffic() bool

func (*StackContainer) IsAutoscaled

func (sc *StackContainer) IsAutoscaled() bool

func (*StackContainer) IsReady

func (sc *StackContainer) IsReady() bool

func (*StackContainer) MaxReplicas

func (sc *StackContainer) MaxReplicas() int32

func (*StackContainer) Name

func (sc *StackContainer) Name() string

func (*StackContainer) Namespace

func (sc *StackContainer) Namespace() string

func (*StackContainer) ScaledDown

func (sc *StackContainer) ScaledDown() bool

type StackResources

type StackResources struct {
	Deployment *appsv1.Deployment
	HPA        *autoscaling.HorizontalPodAutoscaler
	Service    *v1.Service
	Ingress    *extensions.Ingress
}

StackResources describes the resources of a stack.

type StackSetContainer

type StackSetContainer struct {
	StackSet *zv1.StackSet

	// StackContainers is a set of stacks belonging to the StackSet
	// including the Stack sub resources like Deployments and Services.
	StackContainers map[types.UID]*StackContainer

	// Ingress defines the current Ingress resource belonging to the
	// StackSet. This is a reference to the actual resource while
	// `StackSet.Spec.Ingress` defines the ingress configuration specified
	// by the user on the StackSet.
	Ingress *extensions.Ingress

	// TrafficReconciler is the reconciler implementation used for
	// switching traffic between stacks. E.g. for prescaling stacks before
	// switching traffic.
	TrafficReconciler TrafficReconciler
	// contains filtered or unexported fields
}

StackSetContainer is a container for storing the full state of a StackSet including the sub-resources which are part of the StackSet. It respresents a snapshot of the resources currently in the Cluster. This includes an optional Ingress resource as well as the current Traffic distribution. It also contains a set of StackContainers which respresents the full state of the individual Stacks part of the StackSet.

func (*StackSetContainer) GenerateIngress

func (ssc *StackSetContainer) GenerateIngress() (*extensions.Ingress, error)

func (*StackSetContainer) GenerateStackSetStatus

func (ssc *StackSetContainer) GenerateStackSetStatus() *zv1.StackSetStatus

func (*StackSetContainer) GenerateStackSetTraffic added in v1.1.0

func (ssc *StackSetContainer) GenerateStackSetTraffic() []*zv1.DesiredTraffic

func (*StackSetContainer) ManageTraffic

func (ssc *StackSetContainer) ManageTraffic(currentTimestamp time.Time) error

ManageTraffic handles the traffic reconciler logic

func (*StackSetContainer) MarkExpiredStacks

func (ssc *StackSetContainer) MarkExpiredStacks()

MarkExpiredStacks marks stacks that should be deleted

func (*StackSetContainer) NewStack

func (ssc *StackSetContainer) NewStack() (*StackContainer, string)

NewStack returns an (optional) stack that should be created

func (*StackSetContainer) TrafficChanges

func (ssc *StackSetContainer) TrafficChanges() []TrafficChange

func (*StackSetContainer) UpdateFromResources

func (ssc *StackSetContainer) UpdateFromResources() error

UpdateFromResources populates stack state information (e.g. replica counts or traffic) from related resources

type TrafficChange

type TrafficChange struct {
	StackName        string
	OldTrafficWeight float64
	NewTrafficWeight float64
}

TrafficChange contains information about a traffic change event

func (TrafficChange) String

func (tc TrafficChange) String() string

type TrafficReconciler

type TrafficReconciler interface {
	// Handle the traffic switching and/or scaling logic.
	Reconcile(stacks map[string]*StackContainer, currentTimestamp time.Time) error
}

Jump to

Keyboard shortcuts

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