local

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

README

Local cluster Plugin

This is the plugin for creating and initializing a swarm on the local machine.

Dockerfile.compiler builds the image for compiling the Go source files for the plugin.

Dockerfile builds the image for the actual plugin that will be used by the AMP cli.

For more details about the design and use, see the wiki.

Build

make (or make build) builds appcelerator/amp-local.

make vendor updates the vendors.

make clean removes the target binary (local.alpine) that is created by the compiler to be copied into the appcelerator/amp-local image when building it.

make test uses appcelerator/amp-local to create, update, and remove test clusters.

Options

The parameters available for the local plugins are:

  • advertise-addr (interface for the Swarm initialization, default=eth0)

Parameters should be passed as followed:

--advertise-addr en0 ...

Prerequisites

The host should have these prerequisites:

  • a proper storage driver (AUFS, overlay, overlay2, devicemapper on thin-pool)
  • max map count limit at least equals to 262144 (Linux only)
  • enough system resources (4GB memory, 20GB storage)

Trying it out

From the cluster/plugin/local directory, run the following:

$ make vendor
$ make image
$ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v /var/run/docker:/var/run/docker appcelerator/amp-local init

Verify output similar to the following:

$ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v /var/run/docker:/var/run/docker appcelerator/amp-local init

2017/07/29 05:16:49 ampctl (version: latest, build: 43437f20)
2017/07/29 05:16:49 Version test: PASS
2017/07/29 05:16:49 Labels test: PASS
Update Swarm

N/A

Destroy Swarm

Execute the destroy command:

$ docker run -it --rm appcelerator/amp-local destroy

Tests

$ make test

Documentation

Index

Constants

View Source
const (
	InitTimeout       = 10
	ContainerName     = "ampagent"
	ImageName         = "appcelerator/ampagent"
	DockerSocket      = "/var/run/docker.sock"
	DockerSwarmSocket = "/var/run/docker"
	CoreStackName     = "amp"
)

Variables

View Source
var (
	ContainerLabels = map[string]string{"io.amp.role": "infrastructure"}
)

Functions

func DeleteCluster

func DeleteCluster(ctx context.Context, c *client.Client, opts *RequestOptions) error

DeleteSwarm starts the delete operation

func EnsureSwarmExists

func EnsureSwarmExists(ctx context.Context, c *client.Client, opts *RequestOptions) error

EnsureSwarmExists checks that the Swarm is initialized, and does it if it's not the case

func InfoAMPCore added in v0.15.0

func InfoAMPCore(ctx context.Context, c *client.Client) (int, error)

InfoAMPCore returns the number of AMP core services

func InfoCluster

func InfoCluster(ctx context.Context, c *client.Client) (swarm.Swarm, error)

InfoCluster returns the Swarm info

func InfoNode

func InfoNode(ctx context.Context, c *client.Client) (swarm.Node, error)

InfoNode returns the Node info

func InfoToJSON

func InfoToJSON(status string, csCount int, usCount int) (string, error)

func InfoUser added in v0.15.0

func InfoUser(ctx context.Context, c *client.Client) (int, error)

InfoUser returns the number of user services

func LabelNode

func LabelNode(ctx context.Context, c *client.Client, opts *RequestOptions) error

func RunAgent

func RunAgent(ctx context.Context, c *client.Client, action string, opts *RequestOptions) error

RunAgent runs the ampagent image to init (action ="install") or destroy (action="uninstall")

func SwarmNodeStatus added in v0.15.0

func SwarmNodeStatus(client *client.Client) (swarm.LocalNodeState, error)

SwarmNodeStatus returns the swarm status for this node

Types

type FullSwarmInfo

type FullSwarmInfo struct {
	Swarm swarm.Swarm
	Node  swarm.Node
}

type RequestOptions

type RequestOptions struct {
	InitRequest swarm.InitRequest
	// Node labels
	Labels map[string]string
	// Tag of the ampagent image
	Tag           string
	Registration  string
	Notifications bool
	ForceLeave    bool
	SkipTests     bool
	NoMonitoring  bool
}

RequestOptions stores parameters for the Docker API

type ShortSwarmInfo

type ShortSwarmInfo struct {
	SwarmStatus  string `json:"Swarm Status"`
	CoreServices int    `json:"Core Services"`
	UserServices int    `json:"User Services"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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