triton

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MPL-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobTypeService         = "service"
	JobTypeBatch           = "batch"
	APITypeCloud           = "cloudapi"
	APITypeDocker          = "dockerapi"
	DockerRestartNever     = "Never"
	DockerRestartAlways    = "Always"
	DockerRestartOnFailure = "OnFailure"
)

Variables

This section is empty.

Functions

func NewTritonDriver

func NewTritonDriver(logger hclog.Logger) drivers.DriverPlugin

NewTritonDriver returns a new DriverPlugin implementation

Types

type Client

type Client struct {
	Config                *triton.ClientConfig
	InsecureSkipTLSVerify bool
	AffinityLock          *sync.RWMutex
}

Client represents all internally accessible Triton APIs utilized by this driver and the configuration necessary to connect to them.

func (Client) Account

func (c Client) Account() (*account.AccountClient, error)

func (Client) Compute

func (c Client) Compute() (*compute.ComputeClient, error)

func (Client) Identity

func (c Client) Identity() (*identity.IdentityClient, error)

func (Client) Network

func (c Client) Network() (*network.NetworkClient, error)

func (Client) Services

func (c Client) Services() (*services.ServiceGroupClient, error)

type CloudAPI

type CloudAPI struct {
	CloudConfig string     `codec:"cloud_config" json:"cloud_config"`
	Image       CloudImage `codec:"image" json:"image"`
	Networks    []Network  `codec:"networks" json:"networks"`
	UserData    string     `codec:"user_data" json:"user_data"`
	UserScript  string     `codec:"user_script" json:"user_script"`
}

type CloudImage

type CloudImage struct {
	Name       string `codec:"name" json:"name"`
	MostRecent bool   `codec:"most_recent" json:"most_recent"`
	Version    string `codec:"version" json:"version"`
}

type DockerAPI

type DockerAPI struct {
	Cmd            []string          `codec:"cmd" json:"cmd"`
	Entrypoint     []string          `codec:"entrypoint" json:"entrypoint"`
	OpenStdin      bool              `codec:"openstdin" json:"openstdin"`
	StdInOnce      bool              `codec:"stdinonce" json:"stdinonce"`
	TTY            bool              `codec:"tty" json:"tty"`
	WorkingDir     string            `codec:"workingdir" json:"workingdir"`
	Image          DockerImage       `codec:"image" json:"image"`
	Auth           DockerAuth        `codec:"auth" json:"auth"`
	Labels         map[string]string `codec:"labels" json:"labels"`
	PublicNetwork  string            `codec:"public_network" json:"public_network"`
	PrivateNetwork string            `codec:"private_network" json:"private_network"`
	RestartPolicy  string            `codec:"restart_policy" json:"restart_policy"`
	Ports          Ports             `codec:"ports" json:"ports"`
	Hostname       string            `codec:"hostname" json:"hostname"`
	DNS            []string          `codec:"dns" json:"dns"`
	DNSSearch      []string          `codec:"dns_search" json:"dns_search"`
	User           string            `codec:"user" json:"user"`
	Domainname     string            `codec:"domain_name" json:"domain_name"`
	ExtraHosts     []string          `codec:"extra_hosts" json:"extra_hosts"`
	LogConfig      LogConfig         `codec:"log_config" json:"log_config"`
}

type DockerAuth

type DockerAuth struct {
	Username   string `codec:"username" json:"username"`
	Password   string `codec:"password" json:"password"`
	Email      string `codec:"email" json:"email"`
	ServerAddr string `codec:"server_address" json:" server_address"`
}

type DockerImage

type DockerImage struct {
	Name     string `codec:"name" json:"name"`
	Tag      string `codec:"tag" json:"tag"`
	AutoPull bool   `codec:"auto_pull" json:"auto_pull"`
}

type Driver

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

Driver is a nomad driver plugin for provisioning instances on triton

func (*Driver) Capabilities

func (d *Driver) Capabilities() (*drivers.Capabilities, error)

Capabilities returns the features supported by the driver.

func (*Driver) ConfigSchema

func (d *Driver) ConfigSchema() (*hclspec.Spec, error)

ConfigSchema returns the plugin configuration schema.

func (*Driver) DestroyTask

func (d *Driver) DestroyTask(taskID string, force bool) error

DestroyTask cleans up and removes a task that has terminated.

func (*Driver) ExecTask

func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)

ExecTask returns the result of executing the given command inside a task. This is an optional capability.

func (*Driver) Fingerprint

func (d *Driver) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)

Fingerprint returns a channel that will be used to send health information and other driver specific node attributes.

func (*Driver) InspectTask

func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error)

InspectTask returns detailed status information for the referenced taskID.

func (*Driver) PluginInfo

func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error)

PluginInfo returns information describing the plugin.

func (*Driver) RecoverTask

func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error

RecoverTask recreates the in-memory state of a task from a TaskHandle.

func (*Driver) SetConfig

func (d *Driver) SetConfig(cfg *base.Config) error

SetConfig is called by the client to pass the configuration for the plugin.

func (*Driver) Shutdown added in v0.0.4

func (d *Driver) Shutdown(ctx context.Context) error

func (*Driver) SignalTask

func (d *Driver) SignalTask(taskID string, signal string) error

SignalTask forwards a signal to a task. This is an optional capability.

func (*Driver) StartTask

StartTask returns a task handle and a driver network if necessary.

func (*Driver) StopTask

func (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) error

StopTask stops a running task with the given signal and within the timeout window.

func (*Driver) TaskConfigSchema

func (d *Driver) TaskConfigSchema() (*hclspec.Spec, error)

TaskConfigSchema returns the HCL schema for the configuration of a task.

func (*Driver) TaskEvents

func (d *Driver) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)

TaskEvents returns a channel that the plugin can use to emit task related events.

func (*Driver) TaskStats

func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)

TaskStats returns a channel which the driver should send stats to at the given interval.

func (*Driver) WaitTask

func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)

WaitTask returns a channel used to notify Nomad when a task exits.

type DriverConfig

type DriverConfig struct {
	// decoded plugin configuration struct
	//
	// This struct is the decoded version of the schema defined in the
	// configSpec variable above. It's used to convert the HCL configuration
	// passed by the Nomad agent into Go contructs.
	//Shell string `codec:"shell"`
	Cluster          string `codec:"cluster"`
	Enabled          bool   `codec:"enabled"`
	CloudAPIEnabled  bool   `codec:"cloudapi"`
	DockerAPIEnabled bool   `codec:"dockerapi"`
	Region           string `codec:"region"`
}

DriverConfig contains configuration information for the plugin

type LogConfig

type LogConfig struct {
	Type   string            `codec:"type" json:"type"`
	Config map[string]string `codec:"config" json:"config"`
}

type Network

type Network struct {
	Name string `codec:"name" json:"name"`
}

type Package

type Package struct {
	Name    string `codec:"name" json:"name"`
	Version string `codec:"version" json:"version"`
}

type Ports

type Ports struct {
	TCP        []int `codec:"tcp" json:"tcp"`
	UDP        []int `codec:"udp" json:"udp"`
	PublishAll bool  `codec:"publish_all" json:"publish_all"`
}

type RebootTask added in v0.0.4

type RebootTask struct {
	InstanceUUID string `json:"instance_uuid"`
}

type StateChange added in v0.0.4

type StateChange struct {
	PreviousState string `json:"previous_state"`
	CurrentState  string `json:"current_state"`
	InstanceUUID  string `json:"instance_uuid"`
}

type TaskConfig

type TaskConfig struct {
	Affinity           []string          `codec:"affinity" json:"affinity"`
	CNS                []string          `codec:"cns" json:"cns"`
	Cloud              CloudAPI          `codec:"cloud_api" json:"cloud_api"`
	DeletionProtection bool              `codec:"deletion_protection" json:"deletion_protection"`
	Docker             DockerAPI         `codec:"docker_api" json:"docker_api"`
	FWEnabled          bool              `codec:"fwenabled" json:"fwenabled"`
	Package            Package           `codec:"package" json:"package"`
	Tags               map[string]string `codec:"tags" json:"tags"`
}

type TaskState

type TaskState struct {
	TaskConfig *drivers.TaskConfig
	StartedAt  time.Time
	// The plugin keeps track of its running tasks in a in-memory data
	// structure. If the plugin crashes, this data will be lost, so Nomad
	// will respawn a new instance of the plugin and try to restore its
	// in-memory representation of the running tasks using the RecoverTask()
	// method below.
	InstUUID string
}

TaskState is the runtime state which is encoded in the handle returned to Nomad client. This information is needed to rebuild the task state and handler during recovery.

Jump to

Keyboard shortcuts

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