Documentation ¶
Overview ¶
Package localkubectl allows the lifecycle of the localkube container to be controlled
Index ¶
- Variables
- func Command(out io.Writer) *cli.Command
- func GetCurrentContext() (string, error)
- func SetCurrentContext(context string) error
- func SetupContext(clusterName, contextName, kubeAPIServer string, setCurrent bool) error
- func SwitchContextInstructions(contextName string) string
- type Controller
- func (d *Controller) CreateCtr(name, imageTag string) (ctrId string, running bool, err error)
- func (d *Controller) ListLocalkubeCtrs(all bool) ([]docker.APIContainers, error)
- func (d *Controller) OnlyLocalkubeCtr() (ctrId string, running bool, err error)
- func (d *Controller) PullImage(imageTag string, silent bool) error
- func (d *Controller) StartCtr(ctrId, etcdDataDir string) error
- func (d *Controller) StopCtr(ctrId string, remove bool) error
Constants ¶
This section is empty.
Variables ¶
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" )
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") )
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 ¶
Command returns a Command with subcommands for starting and stopping a localkube cluster
func GetCurrentContext ¶
GetCurrentContext returns the context currently being used by kubectl
func SetCurrentContext ¶
SetCurrentContext changes the kubectl context to the given value
func SetupContext ¶
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 ¶
SwitchContextInstructions returns instructions about how to switch kubectl to use the given context
Types ¶
type Controller ¶
Controller provides a wrapper around the Docker client for easy control of localkube.
func NewController ¶
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.