cloudprovider

package
v0.0.0-...-73e42e7 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// DefaultArch is the default Arch for GenericLabels
	DefaultArch = "amd64"
	// DefaultOS is the default OS for GenericLabels
	DefaultOS = "linux"
	// KubeProxyCpuRequestMillis is the amount of cpu requested by Kubeproxy
	KubeProxyCpuRequestMillis = 100
)

Variables

ErrAlreadyExist is returned if a method is not implemented.

View Source
var ErrNotImplemented errors.AutorepairError = errors.NewAutorepairError(errors.InternalError, "Not implemented")

ErrNotImplemented is returned if a method is not implemented.

Functions

func BuildKubeProxy

func BuildKubeProxy(name string) *apiv1.Pod

BuildKubeProxy builds a KubeProxy pod definition

func BuildReadyConditions

func BuildReadyConditions() []apiv1.NodeCondition

BuildReadyConditions sets up mock NodeConditions

func JoinStringMaps

func JoinStringMaps(items ...map[string]string) map[string]string

JoinStringMaps joins node labels

Types

type CloudProvider

type CloudProvider interface {
	// Name returns name of the cloud provider.
	Name() string

	// NodeGroups returns all node groups configured for this cloud provider.
	NodeGroups() []NodeGroup

	// NodeGroupForNode returns the node group for the given node, nil if the node
	// should not be processed by Cluster autorepair, or non-nil error if such
	// occurred. Must be implemented.
	NodeGroupForNode(*apiv1.Node) (NodeGroup, error)

	// Pricing returns pricing model for this cloud provider or error if not available.
	// Implementation optional.
	Pricing() (PricingModel, errors.AutorepairError)

	// GetAvailableMachineTypes get all machine types that can be requested from the cloud provider.
	// Implementation optional.
	GetAvailableMachineTypes() ([]string, error)

	// NewNodeGroup builds a theoretical node group based on the node definition provided. The node group is not automatically
	// created on the cloud provider side. The node group is not returned by NodeGroups() until it is created.
	// Implementation optional.
	NewNodeGroup(machineType string, labels map[string]string, extraResources map[string]resource.Quantity) (NodeGroup, error)
}

CloudProvider contains configuration info and functions for interacting with cloud provider (GCE, AWS, etc).

type NodeGroup

type NodeGroup interface {
	// MaxSize returns maximum size of the node group.
	MaxSize() int

	// MinSize returns minimum size of the node group.
	MinSize() int

	// TargetSize returns the current target size of the node group. It is possible that the
	// number of nodes in Kubernetes is different at the moment but should be equal
	// to Size() once everything stabilizes (new nodes finish startup and registration or
	// removed nodes are deleted completely). Implementation required.
	TargetSize() (int, error)

	// IncreaseSize increases the size of the node group. To delete a node you need
	// to explicitly name it and use DeleteNode. This function should wait until
	// node group size is updated. Implementation required.
	IncreaseSize(delta int) error

	// DeleteNodes deletes nodes from this node group. Error is returned either on
	// failure or if the given node doesn't belong to this node group. This function
	// should wait until node group size is updated. Implementation required.
	DeleteNodes([]*apiv1.Node) error

	// DecreaseTargetSize decreases the target size of the node group. This function
	// doesn't permit to delete any existing node and can be used only to reduce the
	// request for new nodes that have not been yet fulfilled. Delta should be negative.
	// It is assumed that cloud provider will not delete the existing nodes when there
	// is an option to just decrease the target. Implementation required.
	DecreaseTargetSize(delta int) error

	// Id returns an unique identifier of the node group.
	Id() string

	// Debug returns a string containing all information regarding this node group.
	Debug() string

	// Nodes returns a list of all nodes that belong to this node group.
	Nodes() ([]string, error)

	// TemplateNodeInfo returns a schedulercache.NodeInfo structure of an empty
	// (as if just started) node. This will be used in scale-up simulations to
	// predict what would a new node look like if a node group was expanded. The returned
	// NodeInfo is expected to have a fully populated Node object, with all of the labels,
	// capacity and allocatable information as well as all pods that are started on
	// the node by default, using manifest (most likely only kube-proxy). Implementation optional.
	TemplateNodeInfo() (*schedulercache.NodeInfo, error)

	// Exist checks if the node group really exists on the cloud provider side. Allows to tell the
	// theoretical node group from the real one. Implementation required.
	Exist() bool

	// Create creates the node group on the cloud provider side. Implementation optional.
	Create() error

	// Delete deletes the node group on the cloud provider side.
	// This will be executed only for autoprovisioned node groups, once their size drops to 0.
	// Implementation optional.
	Delete() error

	// Autoprovisioned returns true if the node group is autoprovisioned. An autoprovisioned group
	// was created by CA and can be deleted when scaled to 0.
	Autoprovisioned() bool
}

NodeGroup contains configuration info and functions to control a set of nodes that have the same capacity and set of labels.

type NodeGroupDiscoveryOptions

type NodeGroupDiscoveryOptions struct {
	// NodeGroupSpecs is specified to statically discover node groups listed in it
	NodeGroupSpecs []string
	// NodeGroupAutoDiscoverySpec is specified for automatically discovering node groups according to the specs
	NodeGroupAutoDiscoverySpec string
}

NodeGroupDiscoveryOptions contains various options to configure how a cloud provider discovers node groups

func (NodeGroupDiscoveryOptions) AutoDiscoverySpecified

func (o NodeGroupDiscoveryOptions) AutoDiscoverySpecified() bool

AutoDiscoverySpecified returns true only when there is --node-group-auto-discovery specified

func (NodeGroupDiscoveryOptions) StaticDiscoverySpecified

func (o NodeGroupDiscoveryOptions) StaticDiscoverySpecified() bool

StaticDiscoverySpecified returns true only when there are 1 or more --nodes flags are specified

func (NodeGroupDiscoveryOptions) Validate

func (o NodeGroupDiscoveryOptions) Validate() error

Validate returns and error when both --nodes and --node-group-auto-discovery are specified

type PricingModel

type PricingModel interface {
	// NodePrice returns a price of running the given node for a given period of time.
	// All prices returned by the structure should be in the same currency.
	NodePrice(node *apiv1.Node, startTime time.Time, endTime time.Time) (float64, error)

	// PodePrice returns a theoretical minimum priece of running a pod for a given
	// period of time on a perfectly matching machine.
	PodPrice(pod *apiv1.Pod, startTime time.Time, endTime time.Time) (float64, error)
}

PricingModel contains information about the node price and how it changes in time.

Directories

Path Synopsis
aws

Jump to

Keyboard shortcuts

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