localkubectl

package
v1.2.1-v1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package localkubectl allows the lifecycle of the localkube container to be controlled

Index

Constants

This section is empty.

Variables

View Source
var (
	// LocalkubeLabel is the label that identifies localkube containers
	LocalkubeLabel = "rsprd.com/name=localkube"

	// LocalkubeContainerName is the name of the container that localkube runs in
	LocalkubeContainerName = "localkube"

	// LocalkubeImageName is the image of localkube that is started
	LocalkubeImageName = "redspreadapps/localkube"

	// ContainerDataDir is the path inside the container for etcd data
	ContainerDataDir = "/var/localkube/data"

	// RedspreadName is a Redspread specific identifier for Name
	RedspreadName = "rsprd.com/name"
)
View Source
var (
	// ErrNoContainer is returned when the localkube container hasn't been created yet
	ErrNoContainer = errors.New("localkube container doesn't exist")

	// ErrTooManyLocalkubes is returned when there are more than one localkube containers on the Docker daemon
	ErrTooManyLocalkubes = errors.New("multiple localkube containers have been started")
)
View Source
var (
	// DefaultHostDataDir is the directory on the host which is mounted for localkube data if no directory is specified
	DefaultHostDataDir = "~/.localkube/data"

	// LocalkubeDefaultTag is the tag to use for the localkube image
	LocalkubeDefaultTag = "latest"

	// LocalkubeClusterName is the name the cluster configuration is stored under
	LocalkubeClusterName = "localkube"

	// LocalkubeContext is the name of the context used by localkube
	LocalkubeContext = "localkube"
)

Functions

func Command

func Command(out io.Writer) *cli.Command

Command returns a Command with subcommands for starting and stopping a localkube cluster

func GetCurrentContext

func GetCurrentContext() (string, error)

GetCurrentContext returns the context currently being used by kubectl

func SetCurrentContext

func SetCurrentContext(context string) error

SetCurrentContext changes the kubectl context to the given value

func SetupContext

func SetupContext(clusterName, contextName, kubeAPIServer string, setCurrent bool) error

SetupContext creates a new cluster and context in ~/.kube using the provided API Server. If setCurrent is true, it is made the current context.

func SwitchContextInstructions

func SwitchContextInstructions(contextName string) string

SwitchContextInstructions returns instructions about how to switch kubectl to use the given context

Types

type Controller

type Controller struct {
	*docker.Client
	// contains filtered or unexported fields
}

Controller provides a wrapper around the Docker client for easy control of localkube.

func NewController

func NewController(client *docker.Client, out io.Writer) (*Controller, error)

NewController returns a localkube Docker client from a created *docker.Client

func NewControllerFromEnv

func NewControllerFromEnv(out io.Writer) (*Controller, error)

NewControllerFromEnv creates a new Docker client using environment clues.

func (*Controller) CreateCtr

func (d *Controller) CreateCtr(name, imageTag string) (ctrId string, running bool, err error)

CreateCtr creates the localkube container. The image is pulled if it doesn't already exist.

func (*Controller) ListLocalkubeCtrs

func (d *Controller) ListLocalkubeCtrs(all bool) ([]docker.APIContainers, error)

ListLocalkubeCtrs returns a list of localkube containers on this Docker daemon. If a is true only non-running containers will also be displayed

func (*Controller) OnlyLocalkubeCtr

func (d *Controller) OnlyLocalkubeCtr() (ctrId string, running bool, err error)

OnlyLocalkubeCtr returns the localkube container. If there are multiple possible containers an error is returned

func (*Controller) PullImage

func (d *Controller) PullImage(imageTag string, silent bool) error

PullImage will pull the localkube image on the connected Docker daemon

func (*Controller) StartCtr

func (d *Controller) StartCtr(ctrId, etcdDataDir string) error

StartCtr starts the specified Container with options specific to localkube. If etcdDataDir is empty, no directory will be mounted for etcd.

func (*Controller) StopCtr

func (d *Controller) StopCtr(ctrId string, remove bool) error

StopCtr stops the container with the given id. If delete is true, deletes container after stopping.

Jump to

Keyboard shortcuts

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