operator

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultWatchNamespace is the default namespace the operator
	// will watch for instances of its custom resources.
	DefaultWatchNamespace = "openshift-vertical-pod-autoscaler"

	// DefaultVerticalPodAutoscalerNamespace is the default namespace for
	// vertical-pod-autoscaler deployments.
	DefaultVerticalPodAutoscalerNamespace = "openshift-vertical-pod-autoscaler"

	// DefaultVerticalPodAutoscalerName is the default VerticalPodAutoscalerController
	// object watched by the operator.
	DefaultVerticalPodAutoscalerName = "default"

	// DefaultVerticalPodAutoscalerImage is the default image used in
	// VerticalPodAutoscalerController deployments.
	DefaultVerticalPodAutoscalerImage = "quay.io/openshift/origin-vertical-pod-autoscaler:v4.2"

	// DefaultVerticalPodAutoscalerVerbosity is the default logging
	// verbosity level for VerticalPodAutoscalerController deployments.
	DefaultVerticalPodAutoscalerVerbosity = 1
)
View Source
const (
	ReasonEmpty             = ""
	ReasonMissingDependency = "MissingDependency"
	ReasonSyncing           = "SyncingResources"
	ReasonCheckAutoscaler   = "UnableToCheckAutoscalers"
)

Reason messages used in status conditions.

View Source
const OperatorName = "vertical-pod-autoscaler"

OperatorName is the name of this operator.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ReleaseVersion is the version the operator is expected
	// to report once it has reached level.
	ReleaseVersion string

	// WatchNamespace is the namespace the operator will watch for
	// VerticalPodAutoscalerController instances.
	WatchNamespace string

	// VerticalPodAutoscalerNamespace is the namespace in which
	// vertical-pod-autoscaler deployments will be created.
	VerticalPodAutoscalerNamespace string

	// VerticalPodAutoscalerName is the name of the VerticalPodAutoscalerController
	// resource that will be watched by the operator.
	VerticalPodAutoscalerName string

	// VerticalPodAutoscalerImage is the image to be used in
	// VerticalPodAutoscalerController deployments.
	VerticalPodAutoscalerImage string

	// VerticalPodAutoscalerVerbosity is the logging verbosity level for
	// VerticalPodAutoscalerController deployments.
	VerticalPodAutoscalerVerbosity int

	// VerticalPodAutoscalerExtraArgs is a string of additional arguments
	// passed to all VerticalPodAutoscalerController deployments.
	//
	// This is not exposed in the CRD.  It is only configurable via
	// environment variable, and in a normal OpenShift install the CVO
	// will remove it if set manually.  It is only for development and
	// debugging purposes.
	VerticalPodAutoscalerExtraArgs string
}

Config represents the runtime configuration for the operator.

func ConfigFromEnvironment

func ConfigFromEnvironment() *Config

ConfigFromEnvironment returns a new Config object with defaults overridden by environment variables when set.

func NewConfig

func NewConfig() *Config

NewConfig returns a new Config object with defaults set.

type Operator

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

Operator represents an instance of the vertical-pod-autoscaler-operator.

func New

func New(cfg *Config) (*Operator, error)

New returns a new Operator instance with the given config and a manager configured with the various controllers.

func (*Operator) AddControllers

func (o *Operator) AddControllers() error

AddControllers configures the various controllers and adds them to the operator's manager instance.

func (*Operator) RelatedObjects

func (o *Operator) RelatedObjects() []configv1.ObjectReference

RelatedObjects returns a list of objects related to the operator and its operands. These are used in the ClusterOperator status.

func (*Operator) Start

func (o *Operator) Start() error

Start starts the operator's controller-manager.

type StatusReporter

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

StatusReporter reports the status of the operator to the OpenShift cluster-version-operator via ClusterOperator resource status.

func NewStatusReporter

func NewStatusReporter(mgr manager.Manager, cfg *StatusReporterConfig) (*StatusReporter, error)

NewStatusReporter returns a new StatusReporter instance.

func (*StatusReporter) AddRelatedObjects

func (r *StatusReporter) AddRelatedObjects(objs []configv1.ObjectReference)

AddRelatedObjects adds to the list of related objects.

func (*StatusReporter) ApplyStatus

func (r *StatusReporter) ApplyStatus(status configv1.ClusterOperatorStatus) error

ApplyStatus applies the given ClusterOperator status to the operator's ClusterOperator object if necessary. The currently configured RelatedObjects are automatically set on the status. If no ClusterOperator objects exists, one is created.

func (*StatusReporter) CheckVerticalPodAutoscaler

func (r *StatusReporter) CheckVerticalPodAutoscaler() (bool, error)

CheckVerticalPodAutoscaler checks the status of any vertical-pod-autoscaler deployments. It returns a bool indicating whether the deployments are available and fully updated to the latest version and an error.

func (*StatusReporter) GetClusterOperator

func (r *StatusReporter) GetClusterOperator() (*configv1.ClusterOperator, error)

GetClusterOperator fetches the the operator's ClusterOperator object.

func (*StatusReporter) GetOrCreateClusterOperator

func (r *StatusReporter) GetOrCreateClusterOperator() (*configv1.ClusterOperator, error)

GetOrCreateClusterOperator gets, or if necessary, creates the operator's ClusterOperator object and returns it.

func (*StatusReporter) ReportStatus

func (r *StatusReporter) ReportStatus() (bool, error)

ReportStatus checks the status of each dependency and operand and reports the appropriate status via the operator's ClusterOperator object.

func (*StatusReporter) SetRelatedObjects

func (r *StatusReporter) SetRelatedObjects(objs []configv1.ObjectReference)

SetRelatedObjects sets the configured related objects.

func (*StatusReporter) SetReleaseVersion

func (r *StatusReporter) SetReleaseVersion(version string)

SetReleaseVersion sets the configured release version.

func (*StatusReporter) Start

func (r *StatusReporter) Start(stopCh <-chan struct{}) error

Start checks the status of dependencies and reports the operator's status. It will poll until stopCh is closed or prerequisites are satisfied, in which case it will report the operator as available the configured version and wait for stopCh to close before returning.

type StatusReporterConfig

type StatusReporterConfig struct {
	VerticalPodAutoscalerName      string
	VerticalPodAutoscalerNamespace string
	ReleaseVersion                 string
	RelatedObjects                 []configv1.ObjectReference
}

StatusReporterConfig represents the configuration of a given StatusReporter.

Jump to

Keyboard shortcuts

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