Documentation ¶
Index ¶
- Constants
- type Autoscaling
- type ClusterManager
- type ClusterUpdate
- type DefaultImageSelector
- type ExistingNodePool
- type ImageSelectionCriteria
- type ImageSelector
- type ImageSelectors
- type KubernetesVersionImageSelector
- type MockNodePoolProcessor
- type MockNodePoolStore
- func (_m *MockNodePoolStore) CreateNodePool(ctx context.Context, organizationID uint, clusterID uint, clusterName string, ...) (err error)
- func (_m *MockNodePoolStore) DeleteNodePool(ctx context.Context, organizationID uint, clusterID uint, clusterName string, ...) (_result_0 error)
- func (_m *MockNodePoolStore) ListNodePools(ctx context.Context, organizationID uint, clusterID uint, clusterName string) (existingNodePools map[string]ExistingNodePool, err error)
- func (_m *MockNodePoolStore) UpdateNodePoolStackID(ctx context.Context, organizationID uint, clusterID uint, clusterName string, ...) (err error)
- func (_m *MockNodePoolStore) UpdateNodePoolStatus(ctx context.Context, organizationID uint, clusterID uint, clusterName string, ...) (err error)
- type MockNodePoolValidator
- type MockService
- func (_m *MockService) CreateNodePools(ctx context.Context, clusterID uint, nodePools map[string]NewNodePool) (err error)
- func (_m *MockService) DeleteNodePool(ctx context.Context, clusterID uint, nodePoolName string) (isDeleted bool, err error)
- func (_m *MockService) ListNodePools(ctx context.Context, clusterID uint) (_result_0 []NodePool, _result_1 error)
- func (_m *MockService) UpdateCluster(ctx context.Context, clusterID uint, clusterUpdate ClusterUpdate) (_result_0 error)
- func (_m *MockService) UpdateNodePool(ctx context.Context, clusterID uint, nodePoolName string, ...) (_result_0 string, _result_1 error)
- type NewNodePool
- type NodePool
- func NewNodePoolFromCFStack(name string, labels map[string]string, stack *cloudformation.Stack) (nodePool NodePool)
- func NewNodePoolFromCFStackDescriptionError(err error, existingNodePool ExistingNodePool) (nodePool NodePool)
- func NewNodePoolWithNoValues(name string, status NodePoolStatus, statusMessage string) (nodePool NodePool)
- type NodePoolManager
- type NodePoolProcessor
- type NodePoolStatus
- type NodePoolStore
- type NodePoolUpdate
- type NodePoolUpdateDrainOptions
- type NodePoolUpdateOptions
- type NodePoolValidator
- type NodePoolVolumeEncryption
- type RegionMapImageSelector
- type Service
- type Store
Constants ¶
const (
DefaultSpotPrice = "0.0" // 0 spot price stands for on-demand instances
)
const ImageNotFoundError = errors.Sentinel("no images found matching the selection criteria")
ImageNotFoundError is returned by an ImageSelector when it cannot find an image matching the provided criteria.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Autoscaling ¶
type Autoscaling struct { Enabled bool `mapstructure:"enabled"` MinSize int `mapstructure:"minSize"` MaxSize int `mapstructure:"maxSize"` }
Autoscaling describes the EKS node pool's autoscaling settings.
type ClusterManager ¶
type ClusterManager interface { // UpdateCluster updates an existing cluster. UpdateCluster(ctx context.Context, c cluster.Cluster, clusterUpdate ClusterUpdate) error }
ClusterManager is responsible for managing clusters.
type ClusterUpdate ¶
type ClusterUpdate struct {
Version string `mapstructure:"version"`
}
ClusterUpdate describes a cluster update request.
A cluster update contains a partial representation of the cluster resource, updating only the changed values.
type DefaultImageSelector ¶
type DefaultImageSelector struct { DefaultImages ImageSelector DefaultAcceleratedImages ImageSelector DefaultARMImages ImageSelector }
DefaultImageSelector selects an image from the local fallback images based on the instance type (ie. GPU or not).
Note: this process should be refactored once image sourcing is improved (eg. move to cloudinfo).
func NewDefaultImageSelector ¶
func NewDefaultImageSelector() DefaultImageSelector
NewDefaultImageSelector returns a new DefaultImageSelector.
func (DefaultImageSelector) SelectImage ¶
func (s DefaultImageSelector) SelectImage(ctx context.Context, criteria ImageSelectionCriteria) (string, error)
type ExistingNodePool ¶
type ExistingNodePool struct { Name string StackID string Status NodePoolStatus StatusMessage string }
type ImageSelectionCriteria ¶
ImageSelectionCriteria contains all parameters for selecting an image.
type ImageSelector ¶
type ImageSelector interface {
SelectImage(ctx context.Context, criteria ImageSelectionCriteria) (string, error)
}
ImageSelector chooses an image based on the selection criteria. It returns an ImageNotFoundError when no images can be found matching the provided criteria.
func DefaultARMImages ¶
func DefaultARMImages() ImageSelector
DefaultARMImages returns an image selector that returns fallback images if no other images are found.
func DefaultAcceleratedImages ¶
func DefaultAcceleratedImages() ImageSelector
DefaultAcceleratedImages returns an image selector that returns fallback images if no other images are found.
func DefaultImages ¶
func DefaultImages() ImageSelector
DefaultImages returns an image selector that returns fallback images if no other images are found.
type ImageSelectors ¶
type ImageSelectors []ImageSelector
ImageSelectors select an image using a number of selectors. When one fails, it moves onto the next.
func (ImageSelectors) SelectImage ¶
func (s ImageSelectors) SelectImage(ctx context.Context, criteria ImageSelectionCriteria) (string, error)
type KubernetesVersionImageSelector ¶
type KubernetesVersionImageSelector struct { Constraint *semver.Constraints ImageSelector ImageSelector }
KubernetesVersionImageSelector selects an image from the delegated selector if the kubernetes version criteria matches the constraint.
func (KubernetesVersionImageSelector) SelectImage ¶
func (s KubernetesVersionImageSelector) SelectImage(ctx context.Context, criteria ImageSelectionCriteria) (string, error)
type MockNodePoolProcessor ¶
MockNodePoolProcessor is an autogenerated mock for the NodePoolProcessor type.
func (*MockNodePoolProcessor) ProcessNewNodePool ¶
func (_m *MockNodePoolProcessor) ProcessNewNodePool(ctx context.Context, c cluster.Cluster, nodePool NewNodePool) (updatedNodePool NewNodePool, err error)
ProcessNewNodePool provides a mock function.
type MockNodePoolStore ¶
MockNodePoolStore is an autogenerated mock for the NodePoolStore type.
func (*MockNodePoolStore) CreateNodePool ¶
func (_m *MockNodePoolStore) CreateNodePool(ctx context.Context, organizationID uint, clusterID uint, clusterName string, createdBy uint, nodePool NewNodePool) (err error)
CreateNodePool provides a mock function.
func (*MockNodePoolStore) DeleteNodePool ¶
func (_m *MockNodePoolStore) DeleteNodePool(ctx context.Context, organizationID uint, clusterID uint, clusterName string, nodePoolName string) (_result_0 error)
DeleteNodePool provides a mock function.
func (*MockNodePoolStore) ListNodePools ¶
func (_m *MockNodePoolStore) ListNodePools(ctx context.Context, organizationID uint, clusterID uint, clusterName string) (existingNodePools map[string]ExistingNodePool, err error)
ListNodePools provides a mock function.
func (*MockNodePoolStore) UpdateNodePoolStackID ¶
func (_m *MockNodePoolStore) UpdateNodePoolStackID(ctx context.Context, organizationID uint, clusterID uint, clusterName string, nodePoolName string, nodePoolStackID string) (err error)
UpdateNodePoolStackID provides a mock function.
func (*MockNodePoolStore) UpdateNodePoolStatus ¶
func (_m *MockNodePoolStore) UpdateNodePoolStatus(ctx context.Context, organizationID uint, clusterID uint, clusterName string, nodePoolName string, nodePoolStatus NodePoolStatus, nodePoolStatusMessage string) (err error)
UpdateNodePoolStatus provides a mock function.
type MockNodePoolValidator ¶
MockNodePoolValidator is an autogenerated mock for the NodePoolValidator type.
func (*MockNodePoolValidator) ValidateNewNodePool ¶
func (_m *MockNodePoolValidator) ValidateNewNodePool(ctx context.Context, c cluster.Cluster, newNodePool NewNodePool) (err error)
ValidateNewNodePool provides a mock function.
type MockService ¶
MockService is an autogenerated mock for the Service type.
func (*MockService) CreateNodePools ¶
func (_m *MockService) CreateNodePools(ctx context.Context, clusterID uint, nodePools map[string]NewNodePool) (err error)
CreateNodePools provides a mock function.
func (*MockService) DeleteNodePool ¶
func (_m *MockService) DeleteNodePool(ctx context.Context, clusterID uint, nodePoolName string) (isDeleted bool, err error)
DeleteNodePool provides a mock function.
func (*MockService) ListNodePools ¶
func (_m *MockService) ListNodePools(ctx context.Context, clusterID uint) (_result_0 []NodePool, _result_1 error)
ListNodePools provides a mock function.
func (*MockService) UpdateCluster ¶
func (_m *MockService) UpdateCluster(ctx context.Context, clusterID uint, clusterUpdate ClusterUpdate) (_result_0 error)
UpdateCluster provides a mock function.
func (*MockService) UpdateNodePool ¶
func (_m *MockService) UpdateNodePool(ctx context.Context, clusterID uint, nodePoolName string, nodePoolUpdate NodePoolUpdate) (_result_0 string, _result_1 error)
UpdateNodePool provides a mock function.
type NewNodePool ¶
type NewNodePool struct { Name string `mapstructure:"name"` Labels map[string]string `mapstructure:"labels"` Size int `mapstructure:"size"` Autoscaling struct { Enabled bool `mapstructure:"enabled"` MinSize int `mapstructure:"minSize"` MaxSize int `mapstructure:"maxSize"` } `mapstructure:"autoscaling"` VolumeEncryption *NodePoolVolumeEncryption `mapstructure:"volumeEncryption,omitempty"` VolumeSize int `mapstructure:"volumeSize"` VolumeType string `mapstructure:"volumeType"` InstanceType string `mapstructure:"instanceType"` Image string `mapstructure:"image"` SpotPrice string `mapstructure:"spotPrice"` SecurityGroups []string `mapstructure:"securityGroups"` SubnetID string `mapstructure:"subnetId"` UseInstanceStore *bool `mapstructure:"useInstanceStore,omitempty"` }
NewNodePool describes new a Kubernetes node pool in an Amazon EKS cluster.
func (NewNodePool) Validate ¶
func (n NewNodePool) Validate() error
Validate semantically validates the new node pool.
Some cluster specific compatibility information (eg. subnet settings) should be validated by an external validator.
type NodePool ¶
type NodePool struct { Name string `mapstructure:"name"` Labels map[string]string `mapstructure:"labels"` Size int `mapstructure:"size"` Autoscaling Autoscaling `mapstructure:"autoscaling"` VolumeEncryption *NodePoolVolumeEncryption `mapstructure:"volumeEncryption,omitempty"` VolumeSize int `mapstructure:"volumeSize"` VolumeType string `mapstructure:"volumeType"` InstanceType string `mapstructure:"instanceType"` Image string `mapstructure:"image"` SpotPrice string `mapstructure:"spotPrice"` SecurityGroups []string `mapstructure:"securityGroups,omitempty"` SubnetID string `mapstructure:"subnetId"` UseInstanceStore bool `mapstructure:"UseInstanceStore"` Status NodePoolStatus `mapstructure:"status"` StatusMessage string `mapstructure:"statusMessage"` }
NodePool encapsulates information about a cluster node pool.
func NewNodePoolFromCFStack ¶
func NewNodePoolFromCFStack(name string, labels map[string]string, stack *cloudformation.Stack) (nodePool NodePool)
NewNodePoolFromCFStack initializes a node pool object from a CloudFormation stack.
func NewNodePoolFromCFStackDescriptionError ¶
func NewNodePoolFromCFStackDescriptionError(err error, existingNodePool ExistingNodePool) (nodePool NodePool)
NewNodePoolFromCFStackDescriptionError initializes a node pool with the information derived from the CloudFormation stack description error.
func NewNodePoolWithNoValues ¶
func NewNodePoolWithNoValues(name string, status NodePoolStatus, statusMessage string) (nodePool NodePool)
type NodePoolManager ¶
type NodePoolManager interface { // CreateNodePools creates new node pools in a cluster with the specified // attributes. CreateNodePools(ctx context.Context, c cluster.Cluster, nodePools map[string]NewNodePool) (err error) // DeleteNodePool deletes an existing node pool in a cluster. DeleteNodePool( ctx context.Context, c cluster.Cluster, existingNodePool ExistingNodePool, shouldUpdateClusterStatus bool, ) (err error) // UpdateNodePool updates an existing node pool in a cluster. UpdateNodePool(ctx context.Context, c cluster.Cluster, nodePoolName string, nodePoolUpdate NodePoolUpdate) (string, error) // ListNodePools lists node pools from a cluster. ListNodePools( ctx context.Context, c cluster.Cluster, existingNodePools map[string]ExistingNodePool, ) ([]NodePool, error) }
NodePoolManager is responsible for managing node pools.
type NodePoolProcessor ¶
type NodePoolProcessor interface { // ProcessNewNodePool processes a new node pool descriptor. ProcessNewNodePool( ctx context.Context, c cluster.Cluster, nodePool NewNodePool, ) (updatedNodePool NewNodePool, err error) }
NodePoolProcessor processes a node pool descriptor.
type NodePoolStatus ¶
type NodePoolStatus string
NodePoolStatus represents the possible states of a node pool.
const ( // NodePoolStatusCreating is the status used when the node pool resources // are being provisioned. NodePoolStatusCreating NodePoolStatus = "CREATING" // NodePoolStatusDeleted is the status used when the node pool resources // are already removed. NodePoolStatusDeleted NodePoolStatus = "DELETED" // NodePoolStatusDeleting is the status used when the node pool resources // are being removed. NodePoolStatusDeleting NodePoolStatus = "DELETING" // NodePoolStatusEmpty is the status used when the node pool status needs to // be explicitly set to an empty value. This is also the type's default // value. NodePoolStatusEmpty NodePoolStatus = "" // NodePoolStatusCreating is the status returned when the node pool // is in an invalid state or an operation cannot be performed on it. NodePoolStatusError NodePoolStatus = "ERROR" // NodePoolStatusCreating is the status returned when the node pool // is in a healthy, idle state. NodePoolStatusReady NodePoolStatus = "READY" // NodePoolStatusUnknown is the status returned when the node pool cannot be // examined. NodePoolStatusUnknown NodePoolStatus = "UNKNOWN" // NodePoolStatusUpdating is the status returned when the node pool // resources are being changed. NodePoolStatusUpdating NodePoolStatus = "UPDATING" )
func NewNodePoolStatusFromCFStackStatus ¶
func NewNodePoolStatusFromCFStackStatus(cfStackStatus string) (nodePoolStatus NodePoolStatus)
NewNodePoolStatusFromCFStackStatus translates a CloudFormation stack status into a node pool status.
type NodePoolStore ¶
type NodePoolStore interface { // CreateNodePool saves a new node pool. CreateNodePool( ctx context.Context, organizationID uint, clusterID uint, clusterName string, createdBy uint, nodePool NewNodePool, ) (err error) // DeleteNodePool deletes an existing node pool from the storage. DeleteNodePool(ctx context.Context, organizationID, clusterID uint, clusterName string, nodePoolName string) error // ListNodePools retrieves the node pools for the cluster specified by its // cluster ID. ListNodePools( ctx context.Context, organizationID uint, clusterID uint, clusterName string, ) (existingNodePools map[string]ExistingNodePool, err error) // UpdateNodePoolStackID sets the stack ID in the node pool storage to the // specified value. UpdateNodePoolStackID( ctx context.Context, organizationID uint, clusterID uint, clusterName string, nodePoolName string, nodePoolStackID string, ) (err error) // UpdateNodePoolStackID sets the status and status message in the node pool // storage to the specified value. UpdateNodePoolStatus( ctx context.Context, organizationID uint, clusterID uint, clusterName string, nodePoolName string, nodePoolStatus NodePoolStatus, nodePoolStatusMessage string, ) (err error) }
NodePoolStore provides an interface for EKS node pool persistence.
type NodePoolUpdate ¶
type NodePoolUpdate struct { VolumeEncryption *NodePoolVolumeEncryption `mapstructure:"volumeEncryption,omitempty"` VolumeSize int `mapstructure:"volumeSize"` VolumeType string `mapstructure:"volumeType"` Image string `mapstructure:"image"` SecurityGroups []string `mapstructure:"securityGroups"` UseInstanceStore *bool `mapstructure:"useInstanceStore,omitempty"` Options NodePoolUpdateOptions `mapstructure:"options"` }
NodePoolUpdate describes a node pool update request.
A node pool update contains a partial representation of the node pool resource, updating only the changed values.
type NodePoolUpdateOptions ¶
type NodePoolUpdateOptions struct { // Maximum number of extra nodes that can be created during the update. MaxSurge int `mapstructure:"maxSurge"` // Maximum number of nodes that can be updated simultaneously. MaxBatchSize int `mapstructure:"maxBatchSize"` MaxUnavailable int `mapstructure:"maxUnavailable"` // Kubernetes node drain specific options. Drain NodePoolUpdateDrainOptions `mapstructure:"drain"` }
type NodePoolValidator ¶
type NodePoolValidator interface { // ValidateNewNodePool validates a new node pool descriptor. ValidateNewNodePool(ctx context.Context, c cluster.Cluster, newNodePool NewNodePool) (err error) }
NodePoolValidator validates a node pool descriptor.
type NodePoolVolumeEncryption ¶
type NodePoolVolumeEncryption struct { Enabled bool `mapstructure:"enabled"` EncryptionKeyARN string `mapstructure:"encryptionKeyARN"` }
NodePoolVolumeEncryption describes the EKS node pool encryption details.
type RegionMapImageSelector ¶
RegionMapImageSelector selects an image based on the region in the selection criteria.
func (RegionMapImageSelector) SelectImage ¶
func (r RegionMapImageSelector) SelectImage(_ context.Context, criteria ImageSelectionCriteria) (string, error)
type Service ¶
type Service interface { // CreateNodePools creates new node pools with the specified attributes. CreateNodePools(ctx context.Context, clusterID uint, nodePools map[string]NewNodePool) (err error) // DeleteNodePool deletes an existing node pool. DeleteNodePool(ctx context.Context, clusterID uint, nodePoolName string) (isDeleted bool, err error) // UpdateCluster updates a cluster. // // This method accepts a partial body representation. UpdateCluster(ctx context.Context, clusterID uint, clusterUpdate ClusterUpdate) error // UpdateNodePool updates an existing node pool in a cluster. // // This method accepts a partial body representation. UpdateNodePool(ctx context.Context, clusterID uint, nodePoolName string, nodePoolUpdate NodePoolUpdate) (string, error) // ListNodePools lists node pools from a cluster. ListNodePools(ctx context.Context, clusterID uint) ([]NodePool, error) }
Service provides an interface to EKS clusters.
func NewService ¶
func NewService( genericClusters Store, clusterManager ClusterManager, nodePools NodePoolStore, nodePoolManager NodePoolManager, nodePoolProcessor NodePoolProcessor, nodePoolValidator NodePoolValidator, ) Service
NewService returns a new Service instance.
type Store ¶
type Store interface { // GetCluster returns a generic Cluster. // Returns an error with the NotFound behavior when the cluster cannot be found. GetCluster(ctx context.Context, id uint) (cluster.Cluster, error) // SetStatus sets the cluster status. SetStatus(ctx context.Context, id uint, status string, statusMessage string) error }
Store provides an interface to the generic Cluster model persistence.