core

package
v1.4.70 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion   = "zalando.org/v1"
	KindStackSet = "StackSet"
	KindStack    = "Stack"
)
View Source
const (
	SegmentSuffix       = "-traffic-segment"
	IngressPredicateKey = "zalando.org/skipper-predicate"
)
View Source
const (
	StacksetHeritageLabelKey = "stackset"
	StackVersionLabelKey     = "stack-version"
)

Variables

View Source
var (

	// PathTypeImplementationSpecific is the used implementation path type
	// for k8s.io/api/networking/v1.HTTPIngressPath resources.
	PathTypeImplementationSpecific = networking.PathTypeImplementationSpecific
)

Functions

func AreAnnotationsUpToDate added in v1.4.23

func AreAnnotationsUpToDate(updated, existing metav1.ObjectMeta) bool

AreAnnotationsUpToDate checks whether the annotations of the existing and updated resource are up to date.

func GetSegmentLimits added in v1.4.60

func GetSegmentLimits(predicates ...string) (float64, float64, error)

GetSegmentLimits returns the lower and upper limit of the TrafficSegment predicate.

Returns an error if it fails to parse.

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

func (*MetricsReporter) ReportError added in v1.1.23

func (reporter *MetricsReporter) ReportError()

func (*MetricsReporter) ReportPanic added in v1.3.28

func (reporter *MetricsReporter) ReportPanic()

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 (sc *StackContainer) GenerateHPA() (
	*autoscaling.HorizontalPodAutoscaler,
	error,
)

func (*StackContainer) GenerateIngress

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

func (*StackContainer) GenerateIngressSegment added in v1.4.23

func (sc *StackContainer) GenerateIngressSegment() (
	*networking.Ingress,
	error,
)

func (*StackContainer) GeneratePlatformCredentialsSet added in v1.4.67

func (sc *StackContainer) GeneratePlatformCredentialsSet(pcs *zv1.PCS) (*zv1.PlatformCredentialsSet, error)

func (*StackContainer) GenerateRouteGroup added in v1.3.5

func (sc *StackContainer) GenerateRouteGroup() (*rgv1.RouteGroup, error)

func (*StackContainer) GenerateRouteGroupSegment added in v1.4.23

func (sc *StackContainer) GenerateRouteGroupSegment() (
	*rgv1.RouteGroup,
	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

func (*StackContainer) UpdateObjectMeta added in v1.4.22

func (sc *StackContainer) UpdateObjectMeta(objMeta *metav1.ObjectMeta) *metav1.ObjectMeta

type StackResources

type StackResources struct {
	Deployment              *appsv1.Deployment
	HPA                     *autoscaling.HorizontalPodAutoscaler
	Service                 *v1.Service
	Ingress                 *networking.Ingress
	IngressSegment          *networking.Ingress
	RouteGroup              *rgv1.RouteGroup
	RouteGroupSegment       *rgv1.RouteGroup
	ConfigMaps              []*v1.ConfigMap
	Secrets                 []*v1.Secret
	PlatformCredentialsSets []*zv1.PlatformCredentialsSet
}

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 *networking.Ingress

	// RouteGroups defines the current RouteGroup resource belonging to the
	// StackSet. This is a reference to the actual resource while
	// `StackSet.Spec.RouteGroup` defines the route group configuration
	// specified by the user on the StackSet.
	RouteGroup *rgv1.RouteGroup

	// 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 represents 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 represents the full state of the individual Stacks part of the StackSet.

func NewContainer added in v1.1.20

func NewContainer(
	stackset *zv1.StackSet,
	reconciler TrafficReconciler,
	backendWeightsAnnotationKey string,
	clusterDomains []string,
	syncIngressAnnotations []string,
) *StackSetContainer

func (*StackSetContainer) ComputeTrafficSegments added in v1.4.23

func (ssc *StackSetContainer) ComputeTrafficSegments() ([]types.UID, error)

ComputeTrafficSegments returns the stack segments necessary to fulfill the actual traffic configured in the main StackSet.

Returns an ordered list of traffic segments, to ensure no gaps in traffic assignment.

func (*StackSetContainer) GenerateIngress

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

func (*StackSetContainer) GenerateRouteGroup added in v1.3.5

func (ssc *StackSetContainer) GenerateRouteGroup() (*rgv1.RouteGroup, 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