Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigureIPTablesRules(delete bool, interfaces []string) error
- func DownloadImage(url, name, verify, imageType string, force bool, logger hclog.Logger) error
- func NewNspawnDriver(logger hclog.Logger) drivers.DriverPlugin
- func PullDocker(c *import1.Conn, url, image string, force bool) (*import1.Transfer, error)
- type Config
- type Driver
- func (d *Driver) Capabilities() (*drivers.Capabilities, error)
- func (d *Driver) ConfigSchema() (*hclspec.Spec, error)
- func (d *Driver) DestroyTask(taskID string, force bool) error
- func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
- func (d *Driver) ExecTaskStreamingRaw(ctx context.Context, taskID string, command []string, tty bool, ...) error
- func (d *Driver) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)
- func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error)
- func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error)
- func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error
- func (d *Driver) SetConfig(cfg *base.Config) error
- func (d *Driver) Shutdown(ctx context.Context) error
- func (d *Driver) SignalTask(taskID string, signal string) error
- func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
- func (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) error
- func (d *Driver) TaskConfigSchema() (*hclspec.Spec, error)
- func (d *Driver) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)
- func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
- func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)
- type ImageDownloadOpts
- type ImageProps
- type ImageType
- type MachineAddrs
- type MachineConfig
- type MachineProps
- type TaskState
Constants ¶
const ( DockerImage string = "docker" TarImage string = "tar" RawImage string = "raw" ImagePath string = "/var/lib/machines" )
Variables ¶
var ( NspawnMeasuredCpuStats = []string{"System Mode", "User Mode", "Percent"} NspawnMeasuredMemStats = []string{"RSS", "Cache"} )
Functions ¶
func ConfigureIPTablesRules ¶ added in v0.5.0
func DownloadImage ¶ added in v0.2.0
func NewNspawnDriver ¶
func NewNspawnDriver(logger hclog.Logger) drivers.DriverPlugin
NewNspawnDriver returns a new DriverPlugin implementation
Types ¶
type Config ¶
type Config struct { // Enabled is set to true to enable the nspawn driver Enabled bool `codec:"enabled"` Volumes bool `codec:"volumes"` }
Config is the driver configuration set by the SetConfig RPC call
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is a driver for running nspawn containers
func (*Driver) Capabilities ¶
func (d *Driver) Capabilities() (*drivers.Capabilities, error)
Capabilities define what features the driver implements.
func (*Driver) ConfigSchema ¶
ConfigSchema function allows a plugin to tell Nomad the schema for its configuration. This configuration is given in a plugin block of the client configuration. The schema is defined with the hclspec package.
func (*Driver) DestroyTask ¶
DestroyTask function cleans up and removes a task that has terminated. If force is set to true, the driver must destroy the task even if it is still running.
func (*Driver) ExecTask ¶
func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
ExecTask function is used by the Nomad client to execute scripted health checks inside the task execution context.
func (*Driver) ExecTaskStreamingRaw ¶ added in v0.2.0
func (d *Driver) ExecTaskStreamingRaw(ctx context.Context, taskID string, command []string, tty bool, stream drivers.ExecTaskStream) error
ExecTaskStreamingRaw function is used by the Nomad client to execute commands inside the task execution context. i.E. nomad alloc exec ....
func (*Driver) Fingerprint ¶
Fingerprint is called by the client when the plugin is started. It allows the driver to indicate its health to the client. The channel returned should immediately send an initial Fingerprint, then send periodic updates at an interval that is appropriate for the driver until the context is canceled.
func (*Driver) InspectTask ¶
func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error)
InspectTask function returns detailed status information for the referenced taskID.
func (*Driver) PluginInfo ¶
func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error)
PluginInfo returns metadata about the nspawn driver plugin
func (*Driver) RecoverTask ¶
func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error
RecoverTask detects running tasks when nomad client or task driver is restarted. When a driver is restarted it is not expected to persist any internal state to disk. To support this, Nomad will attempt to recover a task that was previously started if the driver does not recognize the task ID. During task recovery, Nomad calls RecoverTask passing the TaskHandle that was returned by the StartTask function.
func (*Driver) SetConfig ¶
SetConfig function is called when starting the plugin for the first time. The Config given has two different configuration fields. The first PluginConfig, is an encoded configuration from the plugin block of the client config. The second, AgentConfig, is the Nomad agent's configuration which is given to all plugins.
func (*Driver) SignalTask ¶
SignalTask function is used by drivers which support sending OS signals (SIGHUP, SIGKILL, SIGUSR1 etc.) to the task. It is an optional function and is listed as a capability in the driver Capabilities struct.
func (*Driver) StartTask ¶
func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
StartTask creates and starts a new nspawn Container based on the given TaskConfig.
func (*Driver) StopTask ¶
StopTask function is expected to stop a running task by sending the given signal to it. If the task does not stop during the given timeout, the driver must forcefully kill the task. StopTask does not clean up resources of the task or remove it from the driver's internal state.
func (*Driver) TaskConfigSchema ¶
TaskConfigSchema returns the schema for the driver configuration of the task.
func (*Driver) TaskEvents ¶
TaskEvents function allows the driver to publish driver specific events about tasks and the Nomad client publishes events associated with an allocation.
func (*Driver) TaskStats ¶
func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
TaskStats function returns a channel which the driver should send stats to at the given interval. The driver must send stats at the given interval until the given context is canceled or the task terminates.
func (*Driver) WaitTask ¶
WaitTask function is expected to return a channel that will send an *ExitResult when the task exits or close the channel when the context is canceled. It is also expected that calling WaitTask on an exited task will immediately send an *ExitResult on the returned channel. A call to WaitTask after StopTask is valid and should be handled. If WaitTask is called after DestroyTask, it should return drivers.ErrTaskNotFound as no task state should exist after DestroyTask is called.
type ImageDownloadOpts ¶ added in v0.2.0
type ImageProps ¶ added in v0.2.0
type ImageProps struct { CreationTimestamp uint64 Limit uint64 LimitExclusive uint64 ModificationTimestamp uint64 Name string Path string ReadOnly bool Type string Usage uint64 UsageExclusive uint64 }
func DescribeImage ¶ added in v0.2.0
func DescribeImage(name string) (*ImageProps, error)
type MachineAddrs ¶
func MachineAddresses ¶
func MachineAddresses(name string, timeout time.Duration) (*MachineAddrs, error)
type MachineConfig ¶
type MachineConfig struct { Bind hclutils.MapStrStr `codec:"bind"` BindReadOnly hclutils.MapStrStr `codec:"bind_read_only"` Boot bool `codec:"boot"` Capability []string `codec:"capability"` Command []string `codec:"command"` Console string `codec:"console"` Environment hclutils.MapStrStr `codec:"environment"` Ephemeral bool `codec:"ephemeral"` Image string `codec:"image"` ImageDownload *ImageDownloadOpts `codec:"image_download,omitempty"` Machine string `codec:"machine"` NetworkNamespace string `codec:"network_namespace"` NetworkVeth bool `codec:"network_veth"` NetworkZone string `codec:"network_zone"` NetworkBridge string `codec:"network_bridge"` PivotRoot string `codec:"pivot_root"` Port hclutils.MapStrStr `codec:"port"` Ports []string `codec:"ports"` // :-( // Deprecated: Nomad dropped support for task network resources in 0.12 PortMap hclutils.MapStrInt `codec:"port_map"` PrivateUsers string `codec:"private_users"` PrivateUsersOwnership string `codec:"private_users_ownership"` ProcessTwo bool `codec:"process_two"` Properties hclutils.MapStrStr `codec:"properties"` ReadOnly bool `codec:"read_only"` ResolvConf string `codec:"resolv_conf"` User string `codec:"user"` UserNamespacing bool `codec:"user_namespacing"` Volatile string `codec:"volatile"` WorkingDirectory string `codec:"working_directory"` // contains filtered or unexported fields }
func (*MachineConfig) ConfigArray ¶
func (c *MachineConfig) ConfigArray() ([]string, error)
func (*MachineConfig) GetImagePath ¶ added in v0.2.0
func (c *MachineConfig) GetImagePath() (string, error)
func (*MachineConfig) Validate ¶ added in v0.1.0
func (c *MachineConfig) Validate() error
type MachineProps ¶
type MachineProps struct { Name string TimestampMonotonic uint64 Timestamp uint64 NetworkInterfaces []int32 ID []uint8 Class string Leader uint32 RootDirectory string Service string State string Unit string }
func DescribeMachine ¶
func DescribeMachine(name string, timeout time.Duration) (*MachineProps, error)
func (*MachineProps) GetNetworkInterfaces ¶ added in v0.5.0
func (p *MachineProps) GetNetworkInterfaces() ([]string, error)