droplet

package
v0.0.0-...-2b6d021 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PageSizeDefault = 200
	InitPageDefault = 1
	DefaultRegion   = "nyc3"
	DefaultSize     = "s-2vcpu-2gb"
)
View Source
const (
	LNDConfigBase   = "/var/app/lnd/docker/lnd"
	LNDConfigPath   = "/var/app/lnd/docker/lnd/lnd.conf"
	CredentialsPath = "/var/app/lnd/docker/lnd/data/chain/bitcoin/mainnet/admin.macaroon"
)
View Source
const (
	StartCommand = "chmod +x /var/app/lnd/docker/start-up.sh && /usr/bin/docker compose -f /var/app/lnd/docker/docker-compose.yml up -d"
)

Variables

View Source
var AllDropletSizes = map[string]bool{
	"s-1vcpu-512mb-10gb": true,
	"s-1vcpu-1gb":        true,
	"s-1vcpu-1gb-amd":    true,
	"s-1vcpu-1gb-intel":  true,
	"s-1vcpu-2gb":        true,
	"s-1vcpu-2gb-amd":    true,
	"s-1vcpu-2gb-intel":  true,
	"s-2vcpu-2gb":        true,
	"s-2vcpu-2gb-amd":    true,
	"s-2vcpu-2gb-intel":  true,
	"s-2vcpu-4gb":        true,
	"s-2vcpu-4gb-amd":    true,
	"s-2vcpu-4gb-intel":  true,
	"c-2":                true,
	"c2-2vcpu-4gb":       true,
	"s-4vcpu-8gb":        true,
	"s-4vcpu-8gb-amd":    true,
	"s-4vcpu-8gb-intel":  true,
	"g-2vcpu-8gb":        true,
	"gd-2vcpu-8gb":       true,
	"m-2vcpu-16gb":       true,
	"c-4":                true,
	"c2-4vcpu-8gb":       true,
	"s-8vcpu-16gb":       true,
	"m3-2vcpu-16gb":      true,
	"s-8vcpu-16gb-amd":   true,
	"s-8vcpu-16gb-intel": true,
	"g-4vcpu-16gb":       true,
	"so-2vcpu-16gb":      true,
	"m6-2vcpu-16gb":      true,
	"gd-4vcpu-16gb":      true,
	"so1_5-2vcpu-16gb":   true,
	"m-4vcpu-32gb":       true,
	"c-8":                true,
	"c2-8vcpu-16gb":      true,
	"m3-4vcpu-32gb":      true,
	"g-8vcpu-32gb":       true,
	"so-4vcpu-32gb":      true,
	"m6-4vcpu-32gb":      true,
	"gd-8vcpu-32gb":      true,
	"so1_5-4vcpu-32gb":   true,
	"m-8vcpu-64gb":       true,
	"c-16":               true,
	"c2-16vcpu-32gb":     true,
	"m3-8vcpu-64gb":      true,
	"g-16vcpu-64gb":      true,
	"so-8vcpu-64gb":      true,
	"m6-8vcpu-64gb":      true,
	"gd-16vcpu-64gb":     true,
	"so1_5-8vcpu-64gb":   true,
	"m-16vcpu-128gb":     true,
	"c-32":               true,
	"c2-32vcpu-64gb":     true,
	"m3-16vcpu-128gb":    true,
	"c-48":               true,
	"m-24vcpu-192gb":     true,
	"g-32vcpu-128gb":     true,
	"so-16vcpu-128gb":    true,
	"m6-16vcpu-128gb":    true,
	"gd-32vcpu-128gb":    true,
	"c2-48vcpu-96gb":     true,
	"m3-24vcpu-192gb":    true,
	"g-40vcpu-160gb":     true,
	"so1_5-16vcpu-128gb": true,
	"m-32vcpu-256gb":     true,
	"gd-40vcpu-160gb":    true,
	"so-24vcpu-192gb":    true,
	"m6-24vcpu-192gb":    true,
	"m3-32vcpu-256gb":    true,
	"so1_5-24vcpu-192gb": true,
	"so-32vcpu-256gb":    true,
	"m6-32vcpu-256gb":    true,
	"so1_5-32vcpu-256gb": true,
}
View Source
var DropletSizes = map[string]string{
	"default": "s-1vcpu-2gb",
	"small":   "s-1vcpu-2gb",
	"medium":  "s-1vcpu-2gb",
	"large":   "s-1vcpu-2gb",
}

droplet size mappings

View Source
var Regions = map[string]string{
	"nyc1": "New York 1",
	"nyc2": "New York 2",
	"nyc3": "New York 3",
	"ams1": "Amsterdam 1",
	"sfo1": "San Francisco 1",
	"sfo2": "San Francisco 2",
	"sfo3": "San Francisco 3",
}

region mappings

Functions

func AddSSHKey

func AddSSHKey(opt SshKeyOptions) (*godo.Key, error)

func AddTemplate

func AddTemplate(client *sftp.Client) error

func Apply

func Apply(name string) (*pb.ResourceResponse, error)

func Await

func Await(id int) chan *godo.Droplet

func CloudKitSSHKey

func CloudKitSSHKey() (*godo.Key, error)

func Connect

func Connect(addr string, key []byte) (*ssh.Client, *ssh.Session, error)

func CreateDroplet

func CreateDroplet(ctx context.Context, cfg *Config) (*godo.Droplet, error)

func ExtractCredentials

func ExtractCredentials(client *sftp.Client) (*lnd.Credentials, error)

func FetchNodeCert

func FetchNodeCert(client *sftp.Client) ([]byte, error)

func GenerateAndAddSSHKey

func GenerateAndAddSSHKey(name string)

GenerateAndAddSSHKey will generate a new ssh key and add it to the account

func GetDropletSize

func GetDropletSize(size string) string

func GetRegionName

func GetRegionName(region string) string

func NewClient

func NewClient() *godo.Client

func NewProvider

func NewProvider(req *pb.CreateRequest) providers.Provider

NewProvider initializes a Provider with defaults

func Provision

func Provision(ip string) ([]byte, error)

Provision uses ssh to connect to the new node place an lnd config with given parameters, start lnd and fetch the tls cert

func RecordDomain

func RecordDomain(ctx context.Context, cfg DomainConfig) error

RecordDomain will take a domainConfiguration and create a domain record for the given domain.

func RemoveKey

func RemoveKey(id int) error

func RetryProvisioner

func RetryProvisioner(ip string) ([]byte, error)

func SFTPClient

func SFTPClient(client *ssh.Client) (*sftp.Client, error)

func SelectKeys

func SelectKeys() ([]godo.Key, error)

Select keys will list all keys and filter based on the default tags

func Start

func Start(client *ssh.Client, session *ssh.Session) (io.Writer, error)

func ValidDropletSize

func ValidDropletSize(size string) bool

func ValidRegion

func ValidRegion(region string) bool

Types

type Config

type Config struct {
	ID      int
	Name    string
	Alias   string
	Size    string
	SSHKey  string
	VPC     string
	ImageID string

	// Configurations
	LND LND
}

Config holds allowed values for an implemented resource provider. Any value outside of this config is unable to be modified during an experiment

type DomainConfig

type DomainConfig struct {
	Name      string
	Alias     string
	DropletID string
	IP        string
}

DomainConfig is a configuration for a domain record.

type Image

type Image struct {
	ID         string
	Name       string
	ResourceID string
}

func FilterImages

func FilterImages(ctx context.Context, pattern string) ([]Image, error)

type LND

type LND struct {
	ImageID string
	Config  string
}

type Provider

type Provider struct {
	// Config holds our internal configuration options
	// for the instance of the Provider
	Config Config
}

Provider implements a Provider

func (*Provider) Annotate

func (p *Provider) Annotate(id string, l labels.Labels) error

Annotate should implement applying labels or tags for a given resource type

func (*Provider) Apply

func (p *Provider) Apply() error

Apply runs the Provider end to end, so calls read and clone

func (*Provider) AwaitReadiness

func (p *Provider) AwaitReadiness() chan error

AwaitReadiness should be implemented to detect when a Provider has finished setting up a variant and can begin using it in an experiment

func (*Provider) Cancel

func (p *Provider) Cancel() error

Cancel will abort and running or submitted Provider

func (*Provider) Clone

func (p *Provider) Clone() error

Clone creates a modified variant

func (*Provider) ProbeReadiness

func (p *Provider) ProbeReadiness() (bool, error)

ProbeReadiness checks that the provisioned resource is available and ready to be included in a live experiment

func (*Provider) Read

func (p *Provider) Read() error

Read fetches and stores the configuration for an existing elasticache cluster. What is read of the existing resource acts as the template/configuration to implement a clone via creating a new resource with the existing output as input for a variant

func (*Provider) Select

func (p *Provider) Select() (target.Selection, error)

Select is similar to Read yet copies a selection of resources based on the Target configuration

func (*Provider) Stop

func (p *Provider) Stop() error

Stop will stop any running Provider

func (*Provider) Teardown

func (p *Provider) Teardown() error

Teardown eradicates any resource that has been provisioned as part of a variant

type SshKeyOptions

type SshKeyOptions struct {
	Name string
	Key  []byte
}

Jump to

Keyboard shortcuts

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