cloudprovider

package
v0.0.0-...-386b7fa Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ResourceNameCores is string name for cores. It's used by ResourceLimiter.
	ResourceNameCores = "cpu"
	// ResourceNameMemory is string name for memory. It's used by ResourceLimiter.
	// Memory should always be provided in bytes.
	ResourceNameMemory = "memory"
)
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

View Source
var ErrAlreadyExist = errors.NewAutoscalerError(errors.InternalError, "Already exist")

ErrAlreadyExist is returned if a method is not implemented.

View Source
var ErrIllegalConfiguration = errors.NewAutoscalerError(errors.InternalError, "Configuration not allowed by cloud provider")

ErrIllegalConfiguration is returned when trying to create NewNodeGroup with configuration that is not supported by cloudprovider.

View Source
var ErrNotImplemented = errors.NewAutoscalerError(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 ContainsGpuResources

func ContainsGpuResources(resources []string) bool

ContainsGpuResources returns true iff given list contains any resource name denoting a gpu type

func IsGpuResource

func IsGpuResource(resourceName string) bool

IsGpuResource checks if given resource name point denotes a gpu type

func JoinStringMaps

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

JoinStringMaps joins node labels

Types

type ASGAutoDiscoveryConfig

type ASGAutoDiscoveryConfig struct {
	// Tags to match on.
	// Any ASG with all of the provided tag keys will be autoscaled.
	Tags map[string]string
}

An ASGAutoDiscoveryConfig specifies how to autodiscover AWS ASGs.

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 autoscaler, 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.AutoscalerError)

	// 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, systemLabels map[string]string,
		taints []apiv1.Taint, extraResources map[string]resource.Quantity) (NodeGroup, error)

	// GetResourceLimiter returns struct containing limits (max, min) for resources (cores, memory etc.).
	GetResourceLimiter() (*ResourceLimiter, error)

	// GPULabel returns the label added to nodes with GPU resource.
	GPULabel() string

	// GetAvailableGPUTypes return all available GPU types cloud provider supports.
	GetAvailableGPUTypes() map[string]struct{}

	// Cleanup cleans up open resources before the cloud provider is destroyed, i.e. go routines etc.
	Cleanup() error

	// Refresh is called before every main loop and can be used to dynamically update cloud provider state.
	// In particular the list of node groups returned by NodeGroups can change as a result of CloudProvider.Refresh().
	Refresh() error
}

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

type Instance

type Instance struct {
	// Id is instance id.
	Id string
	// Status represents status of node. (Optional)
	Status *InstanceStatus
}

Instance represents a cloud-provider node. The node does not necessarily map to k8s node i.e it does not have to be registered in k8s cluster despite being returned by NodeGroup.Nodes() method. Also it is sane to have Instance object for nodes which are being created or deleted.

type InstanceErrorClass

type InstanceErrorClass int

InstanceErrorClass defines class of error condition

const (
	// OutOfResourcesErrorClass means that error is related to lack of resources (e.g. due to
	// stockout or quota-exceeded situation)
	OutOfResourcesErrorClass InstanceErrorClass = 1
	// OtherErrorClass means some non-specific error situation occurred
	OtherErrorClass InstanceErrorClass = 99
)

type InstanceErrorInfo

type InstanceErrorInfo struct {
	// ErrorClass tells what is class of error on instance
	ErrorClass InstanceErrorClass
	// ErrorCode is cloud-provider specific error code for error condition
	ErrorCode string
	// ErrorMessage is human readable description of error condition
	ErrorMessage string
}

InstanceErrorInfo provides information about error condition on instance

type InstanceState

type InstanceState int

InstanceState tells if instance is running, being created or being deleted

const (
	// InstanceRunning means instance is running
	InstanceRunning InstanceState = 1
	// InstanceCreating means instance is being created
	InstanceCreating InstanceState = 2
	// InstanceDeleting means instance is being deleted
	InstanceDeleting InstanceState = 3
)

type InstanceStatus

type InstanceStatus struct {
	// State tells if instance is running, being created or being deleted
	State InstanceState
	// ErrorInfo is not nil if there is error condition related to instance.
	// E.g instance cannot be created.
	ErrorInfo *InstanceErrorInfo
}

InstanceStatus represents instance status.

type LabelAutoDiscoveryConfig

type LabelAutoDiscoveryConfig struct {
	// Key-values to match on.
	Selector map[string]string
}

A LabelAutoDiscoveryConfig specifies how to autodiscover Azure scale sets.

type MIGAutoDiscoveryConfig

type MIGAutoDiscoveryConfig struct {
	// Re is a regexp passed using the eq filter to the GCE list API.
	Re *regexp.Regexp
	// MinSize specifies the minimum size for all MIGs that match Re.
	MinSize int
	// MaxSize specifies the maximum size for all MIGs that match Re.
	MaxSize int
}

A MIGAutoDiscoveryConfig specifies how to autodiscover GCE MIGs.

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.
	// It is required that Instance objects returned by this method have Id field set.
	// Other fields are optional.
	Nodes() ([]Instance, error)

	// TemplateNodeInfo returns a schedulernodeinfo.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() (*schedulernodeinfo.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() (NodeGroup, 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
	NodeGroupAutoDiscoverySpecs []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 are 1 or more --node-group-auto-discovery flags specified

func (NodeGroupDiscoveryOptions) DiscoverySpecified

func (o NodeGroupDiscoveryOptions) DiscoverySpecified() bool

DiscoverySpecified returns true when at least one of the --nodes or --node-group-auto-discovery flags specified.

func (NodeGroupDiscoveryOptions) ParseASGAutoDiscoverySpecs

func (o NodeGroupDiscoveryOptions) ParseASGAutoDiscoverySpecs() ([]ASGAutoDiscoveryConfig, error)

ParseASGAutoDiscoverySpecs returns any provided NodeGroupAutoDiscoverySpecs parsed into configuration appropriate for ASG autodiscovery.

func (NodeGroupDiscoveryOptions) ParseLabelAutoDiscoverySpecs

func (o NodeGroupDiscoveryOptions) ParseLabelAutoDiscoverySpecs() ([]LabelAutoDiscoveryConfig, error)

ParseLabelAutoDiscoverySpecs returns any provided NodeGroupAutoDiscoverySpecs parsed into configuration appropriate for ASG autodiscovery.

func (NodeGroupDiscoveryOptions) ParseMIGAutoDiscoverySpecs

func (o NodeGroupDiscoveryOptions) ParseMIGAutoDiscoverySpecs() ([]MIGAutoDiscoveryConfig, error)

ParseMIGAutoDiscoverySpecs returns any provided NodeGroupAutoDiscoverySpecs parsed into configuration appropriate for MIG autodiscovery.

func (NodeGroupDiscoveryOptions) StaticDiscoverySpecified

func (o NodeGroupDiscoveryOptions) StaticDiscoverySpecified() bool

StaticDiscoverySpecified returns true only when there are 1 or more --nodes flags 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)

	// PodPrice returns a theoretical minimum price 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.

type ResourceLimiter

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

ResourceLimiter contains limits (max, min) for resources (cores, memory etc.).

func NewResourceLimiter

func NewResourceLimiter(minLimits map[string]int64, maxLimits map[string]int64) *ResourceLimiter

NewResourceLimiter creates new ResourceLimiter for map. Maps are deep copied.

func (*ResourceLimiter) GetMax

func (r *ResourceLimiter) GetMax(resourceName string) int64

GetMax returns maximal number of resources for a given resource type.

func (*ResourceLimiter) GetMin

func (r *ResourceLimiter) GetMin(resourceName string) int64

GetMin returns minimal number of resources for a given resource type.

func (*ResourceLimiter) GetResources

func (r *ResourceLimiter) GetResources() []string

GetResources returns list of all resource names for which min or max limits are defined

func (*ResourceLimiter) HasMaxLimitSet

func (r *ResourceLimiter) HasMaxLimitSet(resourceName string) bool

HasMaxLimitSet returns true iff maximal limit is set for given resource.

func (*ResourceLimiter) HasMinLimitSet

func (r *ResourceLimiter) HasMinLimitSet(resourceName string) bool

HasMinLimitSet returns true iff minimal limit is set for given resource.

func (*ResourceLimiter) String

func (r *ResourceLimiter) String() string

Directories

Path Synopsis
baiducloud-sdk-go/bce
Package bce defined a set of core data structure and functions for Baidu Cloud API.
Package bce defined a set of core data structure and functions for Baidu Cloud API.
baiducloud-sdk-go/util
Package util implements a set of util functions.
Package util implements a set of util functions.
gophercloud
Package gophercloud provides a multi-vendor interface to OpenStack-compatible clouds.
Package gophercloud provides a multi-vendor interface to OpenStack-compatible clouds.
gophercloud/openstack
Package openstack contains resources for the individual OpenStack projects supported in Gophercloud.
Package openstack contains resources for the individual OpenStack projects supported in Gophercloud.
gophercloud/openstack/blockstorage/extensions/volumeactions
Package volumeactions provides information and interaction with volumes in the OpenStack Block Storage service.
Package volumeactions provides information and interaction with volumes in the OpenStack Block Storage service.
gophercloud/openstack/blockstorage/v1/volumes
Package volumes provides information and interaction with volumes in the OpenStack Block Storage service.
Package volumes provides information and interaction with volumes in the OpenStack Block Storage service.
gophercloud/openstack/blockstorage/v2/volumes
Package volumes provides information and interaction with volumes in the OpenStack Block Storage service.
Package volumes provides information and interaction with volumes in the OpenStack Block Storage service.
gophercloud/openstack/blockstorage/v3/volumes
Package volumes provides information and interaction with volumes in the OpenStack Block Storage service.
Package volumes provides information and interaction with volumes in the OpenStack Block Storage service.
gophercloud/openstack/common/extensions
Package extensions provides information and interaction with the different extensions available for an OpenStack service.
Package extensions provides information and interaction with the different extensions available for an OpenStack service.
gophercloud/openstack/compute/v2/extensions/attachinterfaces
Package attachinterfaces provides the ability to retrieve and manage network interfaces through Nova.
Package attachinterfaces provides the ability to retrieve and manage network interfaces through Nova.
gophercloud/openstack/compute/v2/extensions/volumeattach
Package volumeattach provides the ability to attach and detach volumes from servers.
Package volumeattach provides the ability to attach and detach volumes from servers.
gophercloud/openstack/compute/v2/flavors
Package flavors provides information and interaction with the flavor API in the OpenStack Compute service.
Package flavors provides information and interaction with the flavor API in the OpenStack Compute service.
gophercloud/openstack/compute/v2/images
Package images provides information and interaction with the images through the OpenStack Compute service.
Package images provides information and interaction with the images through the OpenStack Compute service.
gophercloud/openstack/compute/v2/servers
Package servers provides information and interaction with the server API resource in the OpenStack Compute service.
Package servers provides information and interaction with the server API resource in the OpenStack Compute service.
gophercloud/openstack/containerinfra/v1/clusters
Package clusters contains functionality for working with Magnum Cluster resources.
Package clusters contains functionality for working with Magnum Cluster resources.
gophercloud/openstack/identity/v2/tenants
Package tenants provides information and interaction with the tenants API resource for the OpenStack Identity service.
Package tenants provides information and interaction with the tenants API resource for the OpenStack Identity service.
gophercloud/openstack/identity/v2/tokens
Package tokens provides information and interaction with the token API resource for the OpenStack Identity service.
Package tokens provides information and interaction with the token API resource for the OpenStack Identity service.
gophercloud/openstack/identity/v3/extensions/trusts
Package trusts enables management of OpenStack Identity Trusts.
Package trusts enables management of OpenStack Identity Trusts.
gophercloud/openstack/identity/v3/tokens
Package tokens provides information and interaction with the token API resource for the OpenStack Identity service.
Package tokens provides information and interaction with the token API resource for the OpenStack Identity service.
gophercloud/openstack/networking/v2/extensions/external
Package external provides information and interaction with the external extension for the OpenStack Networking service.
Package external provides information and interaction with the external extension for the OpenStack Networking service.
gophercloud/openstack/networking/v2/extensions/layer3/floatingips
package floatingips enables management and retrieval of Floating IPs from the OpenStack Networking service.
package floatingips enables management and retrieval of Floating IPs from the OpenStack Networking service.
gophercloud/openstack/networking/v2/extensions/layer3/routers
Package routers enables management and retrieval of Routers from the OpenStack Networking service.
Package routers enables management and retrieval of Routers from the OpenStack Networking service.
gophercloud/openstack/networking/v2/extensions/lbaas_v2/l7policies
Package l7policies provides information and interaction with L7Policies and Rules of the LBaaS v2 extension for the OpenStack Networking service.
Package l7policies provides information and interaction with L7Policies and Rules of the LBaaS v2 extension for the OpenStack Networking service.
gophercloud/openstack/networking/v2/extensions/lbaas_v2/listeners
Package listeners provides information and interaction with Listeners of the LBaaS v2 extension for the OpenStack Networking service.
Package listeners provides information and interaction with Listeners of the LBaaS v2 extension for the OpenStack Networking service.
gophercloud/openstack/networking/v2/extensions/lbaas_v2/loadbalancers
Package loadbalancers provides information and interaction with Load Balancers of the LBaaS v2 extension for the OpenStack Networking service.
Package loadbalancers provides information and interaction with Load Balancers of the LBaaS v2 extension for the OpenStack Networking service.
gophercloud/openstack/networking/v2/extensions/lbaas_v2/monitors
Package monitors provides information and interaction with Monitors of the LBaaS v2 extension for the OpenStack Networking service.
Package monitors provides information and interaction with Monitors of the LBaaS v2 extension for the OpenStack Networking service.
gophercloud/openstack/networking/v2/extensions/lbaas_v2/pools
Package pools provides information and interaction with Pools and Members of the LBaaS v2 extension for the OpenStack Networking service.
Package pools provides information and interaction with Pools and Members of the LBaaS v2 extension for the OpenStack Networking service.
gophercloud/openstack/networking/v2/extensions/security/groups
Package groups provides information and interaction with Security Groups for the OpenStack Networking service.
Package groups provides information and interaction with Security Groups for the OpenStack Networking service.
gophercloud/openstack/networking/v2/extensions/security/rules
Package rules provides information and interaction with Security Group Rules for the OpenStack Networking service.
Package rules provides information and interaction with Security Group Rules for the OpenStack Networking service.
gophercloud/openstack/networking/v2/networks
Package networks contains functionality for working with Neutron network resources.
Package networks contains functionality for working with Neutron network resources.
gophercloud/openstack/networking/v2/ports
Package ports contains functionality for working with Neutron port resources.
Package ports contains functionality for working with Neutron port resources.
gophercloud/openstack/orchestration/v1/stackresources
Package stackresources provides operations for working with stack resources.
Package stackresources provides operations for working with stack resources.
gophercloud/openstack/orchestration/v1/stacks
Package stacks provides operation for working with Heat stacks.
Package stacks provides operation for working with Heat stacks.
gophercloud/pagination
Package pagination contains utilities and convenience structs that implement common pagination idioms within OpenStack APIs.
Package pagination contains utilities and convenience structs that implement common pagination idioms within OpenStack APIs.
gophercloud/testhelper
Package testhelper container methods that are useful for writing unit tests.
Package testhelper container methods that are useful for writing unit tests.

Jump to

Keyboard shortcuts

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