ec2cluster

package
v0.0.0-...-0f4c570 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package ec2cluster implements support for maintaining elastic clusters of Reflow instances on EC2.

The EC2 instances created launch reflowlet agent processes that are given the user's profile token so that they can set up HTTPS servers that can perform mutual authentication to the reflow driver process and other reflowlets (for transferring objects) and also access external services like caching.

The VM instances are configured to terminate if they are idle on EC2's billing hour boundary. They also terminate on any fatal reflowlet error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	pool.Mux

	// HTTPClient is used to communicate to the reflowlet servers
	// running on the individual instances. In Cluster, this is done for
	// liveness/health checking.
	HTTPClient *http.Client
	// Logger for cluster events.
	Log *log.Logger
	// File stores the cluster's state.
	File *state.File
	// EC2 is the EC2 API instance through which EC2 calls are made.
	EC2 ec2iface.EC2API
	// Authenticator authenticates the ECR repository that stores the
	// Reflowlet container.
	Authenticator ecrauth.Interface
	// Tag is the tag that's attached instance types created by this cluster.
	Tag string
	// Labels is the set of labels that should be associated with newly created instances.
	Labels pool.Labels
	// Spot is set to true when a spot instance is desired.
	Spot bool
	// InstanceProfile is the EC2 instance profile to use for the cluster instances.
	InstanceProfile string
	// SecurityGroup is the EC2 security group to use for cluster instances.
	SecurityGroup string
	// Region is the AWS availability region to use for launching new EC2 instances.
	Region string
	// InstanceTypes stores the set of admissible instance types.
	// If nil, all instance types are permitted.
	InstanceTypes map[string]bool
	// ReflowletImage is the Docker URI of the image used for instance reflowlets.
	// The image must be retrievable by the cluster's authenticator.
	ReflowletImage string
	// MaxInstances is the maximum number of concurrent instances permitted.
	MaxInstances int
	// DiskType is the EBS disk type to use.
	DiskType string
	// DiskSpace is the number of GiB of disk space to allocate for each node.
	DiskSpace int
	// DiskSlices is the number of EBS volumes that are used. When DiskSlices > 1,
	// they are arranged in a RAID0 array to increase throughput.
	DiskSlices int
	// AMI is the VM image used to launch new instances.
	AMI string
	// The config for this Reflow instantiation. Used to provide configs to
	// EC2 instances.
	Config config.Config
	// User's public SSH key.
	SshKey string
	// AWS key name for launching instances.
	KeyName string
	// Immortal determines whether instances should be made immortal.
	Immortal bool
	// CloudConfig is merged into the instance's cloudConfig before launching.
	CloudConfig cloudConfig

	// Status is used to report cluster and instance status.
	Status *status.Group
	// contains filtered or unexported fields
}

A Cluster implements a runner.Cluster backed by EC2. The cluster is stateful (stored by a local state.File), and expands with demand. Instances are configured so that they shut down when they are idle on a billing boundary.

Cluster supports safely sharing state across many processes. In this case, the processes coordinate to maintain a shared cluster, where instances can be used by any of the constituent processes. In the case of Reflow, this means that multiple runs (single or batch) share the same cluster efficiently.

func (*Cluster) Allocate

func (c *Cluster) Allocate(ctx context.Context, req reflow.Requirements, labels pool.Labels) (alloc pool.Alloc, err error)

Allocate reserves an alloc with within the resource requirement boundaries form this cluster. If an existing instance can serve the request, it is returned immediately; otherwise new instance(s) are spun up to handle the allocation.

func (*Cluster) Init

func (c *Cluster) Init() error

Init initializes the cluster's data structures. It must be called before use. Init also starts maintenance goroutines.

type Config

type Config struct {
	config.Config `yaml:"-"`

	// InstanceProfile defines the EC2 instance profile with which to launch
	// new instances.
	InstanceProfile string `yaml:"instanceprofile,omitempty"`

	// SecurityGroup defines the EC2 security group with which to launch
	// new instances.
	SecurityGroup string `yaml:"securitygroup,omitempty"`

	// Region specifies the AWS region used for launching EC2 instances.
	// Instances are launched into any availability zone.
	Region string `yaml:"region,omitempty"`

	// Spot determines whether to use spot instances.
	Spot bool `yaml:"spot,omitempty"`
	// DiskType defines the EBS disk type (e.g., gp2) to use when
	// configuring EBS volumes.
	DiskType string `yaml:"disktype"`
	// DiskSpace determines the amount of EBS disk space to allocate for
	// each node, in gigabytes.
	DiskSpace int `yaml:"diskspace"`
	// DiskSlices is the number of EBS volumes to use. When DiskSlices > 1,
	// the volumes are arranged in a RAID0 array to increase throughput.
	DiskSlices int `yaml:"diskslices"`
	// AMI defines the AMI to use when launching new instances. CoreOS
	// is assumed.
	AMI string `yaml:"ami"`
	// MaxInstances limits the number of instances that that may be
	// running at any given time.
	MaxInstances int `yaml:"maxinstances,omitempty"`
	// InstanceTypes defines the set of allowable EC2 instance types for
	// this cluster. If empty, all instance types are permitted.
	InstanceTypes []string `yaml:"instancetypes,omitempty"`
	// Additional public SSH key to add to the instance.
	SshKey string
	// KeyName is the AWS SSH key with which to launch new instances.
	// If unspecified, instances are launched without keys.
	KeyName string
	// Immortal determines whether instances should be made immortal.
	Immortal bool `yaml:"immortal,omitempty"`

	// CloudConfig stores a cloud config that is merged into ec2cluster's
	// cloud config. It is merged before the reflowlet unit is added, so
	// the user has an opportunity to introduce additional systemd units.
	CloudConfig cloudConfig `yaml:"cloudconfig"`
}

Config defines a configuration for ec2cluster, providing Config.Cluster. It may be configured with the parameters defined directly in the struct. This configuration is overriden by the configuration specified in the key "ec2cluster".

func (*Config) Cluster

func (c *Config) Cluster() (runner.Cluster, error)

Cluster returns an EC2-based cluster using the provided parameters.

func (*Config) Init

func (c *Config) Init() error

Init initializes this EC2 configuration from the underlying configuration key "ec2cluster". It returns an error if this key cannot be unmarshaled into a valid EC2 configuration.

func (*Config) Marshal

func (c *Config) Marshal(keys config.Keys) error

Marshal adds this config's ec2 parameters.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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