spot

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("spot: not implemented")

ErrNotImplemented is the error returned if a method is not implemented.

Functions

This section is empty.

Types

type Account

type Account struct {
	// Unique account ID.
	ID string `json:"accountId"`

	// Account name.
	Name string `json:"name"`

	// Organization ID.
	OrganizationID string `json:"organizationId"`

	// External ID generated by the cloud provider bounded with this account.
	ExternalID *string `json:"providerExternalId"` // nullable; used by AWS only
}

Account represents a Spot account.

type AccountsInterface

type AccountsInterface interface {
	// ListAccounts returns a list of Spot accounts.
	ListAccounts(ctx context.Context) ([]*Account, error)
}

AccountsInterface defines the interface of the Spot Accounts API.

type Client

type Client interface {
	// Accounts returns an instance of Accounts interface.
	Accounts() AccountsInterface

	// Services returns an instance of Services interface.
	Services() ServicesInterface
}

Client the interface of the Spot API.

func New

func New(options ...ClientOption) Client

type ClientOption

type ClientOption func(*ClientOptions)

ClientOption allows specifying various settings configurable by the client.

func WithBaseURL

func WithBaseURL(url string) ClientOption

WithBaseURL defines the base URL of the Spot API.

func WithCredentialsProfile

func WithCredentialsProfile(profile string) ClientOption

WithCredentialsProfile specifies credentials profile to use.

func WithCredentialsStatic

func WithCredentialsStatic(token, account string) ClientOption

WithCredentialsStatic specifies static credentials.

func WithDryRun

func WithDryRun(value bool) ClientOption

WithDryRun toggles the dry-run mode on/off.

type ClientOptions

type ClientOptions struct {
	// Credentials profile. Defaults to `default`.
	Profile string

	// Static user credentials.
	Token, Account string

	// BaseURL configures the default base URL of the Spot API.
	// Defaults to `https://api.spotinst.io`.
	BaseURL string

	// DryRun configures the client to print the actions that would be executed,
	// without executing them.
	DryRun bool
}

type CloudProviderName

type CloudProviderName string

CloudProviderName represents the name of a cloud provider.

const (
	CloudProviderAWS   CloudProviderName = "aws"
	CloudProviderGCP   CloudProviderName = "gcp"
	CloudProviderAzure CloudProviderName = "azure"
)

Cloud Providers.

type ObjectMeta

type ObjectMeta struct {
	// Unique ID.
	ID string `json:"id" table:"1,id"`

	// Object name.
	Name string `json:"name" table:"2,name"`

	// CreatedAt represents the timestamp when the cluster has been created.
	CreatedAt time.Time `json:"createdAt" table:"9,created"`

	// UpdatedAt represents the timestamp when the cluster has been updated.
	UpdatedAt time.Time `json:"updatedAt" table:"10,updated"`
}

ObjectMeta is metadata that all resources must have.

type OceanCluster

type OceanCluster struct {
	// Type's metadata.
	TypeMeta

	// Object's metadata.
	ObjectMeta

	// Obj holds the raw object which is an orchestrator-specific implementation.
	Obj interface{} `json:"-"`
}

OceanCluster represents an Ocean cluster.

type OceanClusterBuilder

type OceanClusterBuilder interface {
	Build() (*OceanCluster, error)
}

OceanClusterBuilder is the interface that every Ocean cluster concrete implementation should obey.

type OceanClusterOptions

type OceanClusterOptions struct {
	// Base.
	ClusterID    string
	ControllerID string
	Name         string
	Region       string

	// Strategy.
	SpotPercentage           float64
	UtilizeReservedInstances bool
	FallbackToOnDemand       bool
	DrainingTimeout          int
	AvailabilityVsCost       string
	SpreadNodesBy            string
	// Capacity.
	MinSize    int
	MaxSize    int
	TargetSize int

	// Compute
	SubnetIDs                []string
	InstanceTypesWhitelist   []string
	InstanceTypesBlacklist   []string
	SecurityGroupIDs         []string
	ImageID                  string
	KeyPair                  string
	UserData                 string
	RootVolumeSize           int
	AssociatePublicIPAddress bool
	EnableMonitoring         bool
	EnableEBSOptimization    bool
	IAMInstanceProfileName   string
	IAMInstanceProfileARN    string

	LoadBalancerNames               []string
	LoadBalancerARNs                []string
	LoadBalancerType                string // Deprecated: Inferred from name/arn.
	ResourceTagSpecificationVolumes bool

	// Auto Scaling.
	EnableAutoScaler       bool
	EnableAutoConfig       bool
	Cooldown               int
	HeadroomCPUPerUnit     int
	HeadroomMemoryPerUnit  int
	HeadroomGPUPerUnit     int
	HeadroomNumPerUnit     int
	ResourceLimitMaxVCPU   int
	ResourceLimitMaxMemory int
	EvaluationPeriods      int
	MaxScaleDownPercentage int
}

OceanClusterOptions represents an Ocean cluster.

type OceanClustersSorter

type OceanClustersSorter struct {
	Clusters []*OceanCluster
}

func (*OceanClustersSorter) Len

func (s *OceanClustersSorter) Len() int

func (*OceanClustersSorter) Less

func (s *OceanClustersSorter) Less(i, j int) bool

func (*OceanClustersSorter) Swap

func (s *OceanClustersSorter) Swap(i, j int)

type OceanInterface

type OceanInterface interface {
	// NewClusterBuilder returns new instance of OceanClusterBuilder
	// interface for defining fresh Ocean cluster.
	NewClusterBuilder(fs *pflag.FlagSet, opts *OceanClusterOptions) OceanClusterBuilder

	// NewLaunchSpecBuilder returns new instance of OceanLaunchSpecBuilder
	// interface for defining fresh Ocean launch spec.
	NewLaunchSpecBuilder(fs *pflag.FlagSet, opts *OceanLaunchSpecOptions) OceanLaunchSpecBuilder

	// NewRolloutBuilder returns new instance of OceanRolloutBuilder
	// interface for defining fresh Ocean rollout.
	NewRolloutBuilder(fs *pflag.FlagSet, opts *OceanRolloutOptions) OceanRolloutBuilder

	// ListClusters returns a list of Ocean clusters.
	ListClusters(ctx context.Context) ([]*OceanCluster, error)

	// ListLaunchSpecs returns a list of Ocean launch specs.
	ListLaunchSpecs(ctx context.Context) ([]*OceanLaunchSpec, error)

	// ListRollouts returns a list of Ocean rollouts.
	ListRollouts(ctx context.Context, clusterID string) ([]*OceanRollout, error)

	// GetCluster returns an Ocean cluster spec by ID.
	GetCluster(ctx context.Context, clusterID string) (*OceanCluster, error)

	// GetLaunchSpec returns an Ocean launch spec by ID.
	GetLaunchSpec(ctx context.Context, specID string) (*OceanLaunchSpec, error)

	// GetRollout returns an Ocean rollout by ID.
	GetRollout(ctx context.Context, clusterID, rolloutID string) (*OceanRollout, error)

	// CreateCluster creates a new Ocean cluster.
	CreateCluster(ctx context.Context, cluster *OceanCluster) (*OceanCluster, error)

	// CreateLaunchSpec creates a new Ocean launch spec.
	CreateLaunchSpec(ctx context.Context, spec *OceanLaunchSpec) (*OceanLaunchSpec, error)

	// CreateRollout creates a new Ocean rollout.
	CreateRollout(ctx context.Context, rollout *OceanRollout) (*OceanRollout, error)

	// UpdateCluster updates an existing Ocean cluster by ID.
	UpdateCluster(ctx context.Context, cluster *OceanCluster) (*OceanCluster, error)

	// UpdateLaunchSpec updates an existing Ocean launch spec by ID.
	UpdateLaunchSpec(ctx context.Context, spec *OceanLaunchSpec) (*OceanLaunchSpec, error)

	// UpdateRollout updates an existing Ocean rollout by ID.
	UpdateRollout(ctx context.Context, rollout *OceanRollout) (*OceanRollout, error)

	// DeleteCluster deletes an Ocean cluster spec by ID.
	DeleteCluster(ctx context.Context, clusterID string) error

	// DeleteLaunchSpec deletes an Ocean launch spec by ID.
	DeleteLaunchSpec(ctx context.Context, specID string) error
}

OceanInterface defines the interface of the Spot Ocean API.

type OceanLaunchSpec

type OceanLaunchSpec struct {
	// Type's metadata.
	TypeMeta

	// Object's metadata.
	ObjectMeta

	// Obj holds the raw object which is an orchestrator-specific implementation.
	Obj interface{} `json:"-"`
}

OceanLaunchSpec represents an Ocean launch spec.

type OceanLaunchSpecBuilder

type OceanLaunchSpecBuilder interface {
	Build() (*OceanLaunchSpec, error)
}

OceanLaunchSpecBuilder is the interface that every Ocean launch spec concrete implementation should obey.

type OceanLaunchSpecOptions

type OceanLaunchSpecOptions struct {
	// Base.
	SpecID    string
	ClusterID string
	Name      string

	// Compute.
	ImageID          string
	UserData         string
	SecurityGroupIDs []string
}

OceanLaunchSpecOptions represents an Ocean launch spec.

type OceanLaunchSpecsSorter

type OceanLaunchSpecsSorter struct {
	LaunchSpecs []*OceanLaunchSpec
}

func (*OceanLaunchSpecsSorter) Len

func (s *OceanLaunchSpecsSorter) Len() int

func (*OceanLaunchSpecsSorter) Less

func (s *OceanLaunchSpecsSorter) Less(i, j int) bool

func (*OceanLaunchSpecsSorter) Swap

func (s *OceanLaunchSpecsSorter) Swap(i, j int)

type OceanRollout

type OceanRollout struct {
	// Type's metadata.
	TypeMeta

	// Object's metadata.
	ObjectMeta

	// Obj holds the raw object which is an orchestrator-specific implementation.
	Obj interface{} `json:"-"`
}

OceanRollout represents an Ocean rollout.

type OceanRolloutBuilder

type OceanRolloutBuilder interface {
	Build() (*OceanRollout, error)
}

OceanRolloutBuilder is the interface that every Ocean rollout concrete implementation should obey.

type OceanRolloutOptions

type OceanRolloutOptions struct {
	// Base.
	RolloutID string
	ClusterID string
	Comment   string
	Status    string

	// Parameters.
	BatchSizePercentage int
	DisableAutoScaling  bool
	SpecIDs             []string
	InstanceIDs         []string
	RespectPDB          bool
}

OceanRolloutOptions represents an Ocean rollout.

type OceanRolloutsSorter

type OceanRolloutsSorter struct {
	Rollouts []*OceanRollout
}

func (*OceanRolloutsSorter) Len

func (s *OceanRolloutsSorter) Len() int

func (*OceanRolloutsSorter) Less

func (s *OceanRolloutsSorter) Less(i, j int) bool

func (*OceanRolloutsSorter) Swap

func (s *OceanRolloutsSorter) Swap(i, j int)

type OceanSparkCluster added in v0.27.0

type OceanSparkCluster struct {
	// Type's metadata.
	TypeMeta

	// Object's metadata.
	ObjectMeta

	OceanClusterID string `json:"oceanClusterId" table:"3,oceanId"`
	State          string `json:"state" table:"4,state"`

	// Obj holds the raw object
	Obj interface{} `json:"-"`
}

OceanSparkCluster represents an Ocean Spark cluster.

type OceanSparkClustersSorter added in v0.27.0

type OceanSparkClustersSorter struct {
	Clusters []*OceanSparkCluster
}

func (*OceanSparkClustersSorter) Len added in v0.27.0

func (s *OceanSparkClustersSorter) Len() int

func (*OceanSparkClustersSorter) Less added in v0.27.0

func (s *OceanSparkClustersSorter) Less(i, j int) bool

func (*OceanSparkClustersSorter) Swap added in v0.27.0

func (s *OceanSparkClustersSorter) Swap(i, j int)

type OceanSparkInterface added in v0.27.0

type OceanSparkInterface interface {
	// ListClusters returns a list of Ocean Spark clusters.
	ListClusters(ctx context.Context, controllerClusterID string, state string) ([]*OceanSparkCluster, error)

	// GetCluster returns an Ocean Spark cluster spec by ID.
	GetCluster(ctx context.Context, clusterID string) (*OceanSparkCluster, error)

	// CreateCluster creates an Ocean Spark cluster on top of the given Ocean cluster.
	CreateCluster(ctx context.Context, oceanClusterID string) (*OceanSparkCluster, error)

	// DeleteCluster deletes the given Ocean Spark cluster.
	DeleteCluster(ctx context.Context, clusterID string) error
}

OceanSparkInterface defines the interface of the Spot Ocean for Apache Spark API.

type OrchestratorName

type OrchestratorName string

OrchestratorName represents the name of a container orchestrator.

const (
	OrchestratorKubernetes OrchestratorName = "kubernetes"
	OrchestratorECS        OrchestratorName = "ecs"
)

Orchestrators.

type ResourceDoesNotExistError added in v0.19.0

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

func (ResourceDoesNotExistError) Error added in v0.19.0

func (ResourceDoesNotExistError) Unwrap added in v0.19.0

func (e ResourceDoesNotExistError) Unwrap() error

type ServicesInterface

type ServicesInterface interface {
	// Ocean returns an instance of Ocean interface by cloud provider and
	// orchestrator names.
	Ocean(provider CloudProviderName, orchestrator OrchestratorName) (OceanInterface, error)

	// OceanSpark returns an instance of Ocean Spark interface
	OceanSpark() (OceanSparkInterface, error)
}

ServicesInterface defines the interface of the Spot Services API.

type TypeMeta

type TypeMeta struct {
	// Kind represents the kind of the resource this object represents.
	Kind string `json:"kind"`
}

TypeMeta describes an individual object.

Jump to

Keyboard shortcuts

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