activator

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

README

The Activator Network Configurations

Traffic configuration overview

An ingress object is created per Route to direct external traffic to reach desired revisions. This ingress object has annotations "istio" so Istio is the ingress controller which fulfills the ingress. The ingress uses domain based routing to map the requests to the placeholder service. The placeholder service is then mapped to Istio routerules which control traffic across revisions and the activator service.

The picture below shows traffic configuration for a route "abc-route".

traffic

Istio Route Rules Configurations

Knative Serving Route objects control traffic split via Istio route rules. When a revision is in Reserve state due to inactivity, instead of letting the revision get traffic assignment directly, Route defines route rules such that the activator gets the portion of traffic for the revision. Below are detailed description for three cases.

All revisions are active

When all revisions are active, the activator service does not get any traffic. Below is an example where the route (my-service) has two traffic targets, Revision a and Revision b, and both revisions are active. Note activator does not serve traffic.

active revision

One revision is in Reserve state

When one revision is in Reserve state, the activator services gets its traffic assignment. Below is an example where Revision a is active and Revision b is in Reserve. In this case, the Activator gets traffic assignment for Revision b. Upon receiving requests, Activator activates Revision b and forwards requests to Revision b after it is ready. After the revision is activated and ready to serve traffic, the Revision b gets assigned portion of traffic directly.

reserve revision

Multiple revisions are in Reserve state

When there are two or more revisions are in Reserve state, the Activator service gets traffic for all Reserve revisions. Among Reserve revisions, Activator activates the revision with the largest traffic weight, and forwards traffic to it. There is room for improvement for this behavior (#882). After the revision is activated and ready to serve traffic, activator gets the portion of traffic for all the rest Reserve revisions.

Documentation

Index

Constants

View Source
const (
	// K8sServiceName is the name of the activator service
	K8sServiceName = "activator-service"
	// RequestCountHTTPHeader is the header key for number of tries
	RequestCountHTTPHeader string = "knative-activator-num-retries"
	// RevisionHeaderName is the header key for revision name
	RevisionHeaderName string = "knative-serving-revision"
	// RevisionHeaderNamespace is the header key for revision's namespace
	RevisionHeaderNamespace string = "knative-serving-namespace"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivationResult added in v0.2.0

type ActivationResult struct {
	Status            int
	Endpoint          Endpoint
	ServiceName       string
	ConfigurationName string
	Error             error
}

ActivationResult is used to return the result of an ActivateEndpoint call

type Activator

type Activator interface {
	ActiveEndpoint(namespace, name string) ActivationResult
	Shutdown()
}

Activator provides an active endpoint for a revision or an error and status code indicating why it could not.

func NewDedupingActivator

func NewDedupingActivator(a Activator) Activator

NewDedupingActivator creates an Activator that deduplicates activations requests for the same revision id and namespace.

func NewRevisionActivator

func NewRevisionActivator(kubeClient kubernetes.Interface, servingClient clientset.Interface, logger *zap.SugaredLogger, reporter StatsReporter) Activator

NewRevisionActivator creates an Activator that changes revision serving status to active if necessary, then returns the endpoint once the revision is ready to serve traffic.

type Endpoint

type Endpoint struct {
	FQDN string
	Port int32
}

Endpoint is a fully-qualified domain name / port pair for an active revision.

type Measurement added in v0.2.0

type Measurement int

Measurement represents the type of the autoscaler metric to be reported

const (
	// RequestCountM is the requests count that are routed to the activator
	RequestCountM Measurement = iota

	//ResponseCountM is the response count when activator proxy the request
	ResponseCountM

	// ResponseTimeInMsecM is the response time in millisecond
	ResponseTimeInMsecM
)

type Reporter added in v0.2.0

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

Reporter holds cached metric objects to report autoscaler metrics

func NewStatsReporter added in v0.2.0

func NewStatsReporter() (*Reporter, error)

NewStatsReporter creates a reporter that collects and reports activator metrics

func (*Reporter) ReportRequest added in v0.2.0

func (r *Reporter) ReportRequest(ns, service, config, rev string, v float64) error

ReportRequest captures request metrics

func (*Reporter) ReportResponseCount added in v0.2.0

func (r *Reporter) ReportResponseCount(ns, service, config, rev string, responseCode, numTries int, v float64) error

ReportResponseCount captures response count metric with value v.

func (*Reporter) ReportResponseTime added in v0.2.0

func (r *Reporter) ReportResponseTime(ns, service, config, rev string, responseCode int, d time.Duration) error

ReportResponseTime captures response time requests

type StatsReporter added in v0.2.0

type StatsReporter interface {
	ReportRequest(ns, service, config, rev string, v float64) error
	ReportResponseCount(ns, service, config, rev string, responseCode, numTries int, v float64) error
	ReportResponseTime(ns, service, config, rev string, responseCode int, d time.Duration) error
}

StatsReporter defines the interface for sending activator metrics

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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