localkube

package module
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: 33 Imported by: 0

README

⚡ localkube ⚡

Build Status

localkube is the easiest way to use Kubernetes. It provides a Kubernetes cluster configured to run locally and optimized for rapid development.

The environment is intended to be used with Kubernetes development tool spread.

localkube is a full Kubernetes 1.2 cluster, and has everything you need for a cluster in regards to networking (proxy, DNS, etc). Some more highlights:

  • Single executable
  • Single container
  • Single process
  • One command to start with spread

It's great for:

  • Playing around with Kubernetes without having to set up a cluster on GCP or AWS
  • Offline and rapid development with Kubernetes

###Requirements

  • spread
  • kubectl
  • Make sure Docker is set up correctly, including starting docker-machine to bring up a VM [1]

###Getting started

  • Run spread cluster start to start localkube
  • Sanity check: kubectl cluster-info [2]

###Suggested workflow

  • docker build the image that you want to work with [2]
  • Create Kubernetes objects that use the image build above
  • Run spread build . to deploy to cluster [3]
  • Iterate on your application, updating image and objects running spread build . each time you want to deploy changes
  • To preview changes, grab the IP of your docker daemon and use kubectl describe services/'SERVICE-NAME' for the NodePort, then put the IP:NodePort in your browser
  • When finished, run spread cluster stop to stop localkube

[1] For now, we recommend everyone use a VM when working with localkube
[2] There will be a delay in returning info the first time you start localkube, as the Weave networking container needs to download. This pause will be fixed in future releases.
[3] spread will soon integrate building (#59)
[4] Since localkube shares a Docker daemon with your host, there is no need to push images :)

###Developing on localkube

For those interested in contributing to development, this will compile localkube executable, build an image with it inside, and run a container with the build image.

The docker command should be setup for the Docker daemon you want to run the cluster with.

Linux

make run-image

OS X/Windows

make docker-build run-image

The apiserver will run on port 8080 of the Docker host.

###FAQ

Why use a local Kubernetes cluster in the first place?

Setting up a remote Kubernetes cluster takes too long, and you can't develop and test on a Kubernetes cluster offline with a remote cluster.

Why not use hyperkube or monokube for local dev?

We built localkube to integrate with spread for an interactive workflow when developing with Kubernetes. localkube is built as a full Kubernetes 1.2 cluster, has pod networking set up with Weave, and uses spread for a rapid development workflow.

Documentation

Index

Constants

View Source
const (
	APIServerName = "apiserver"
	APIServerHost = "0.0.0.0"
	APIServerPort = 8080
)
View Source
const (
	DNSName = "dns"

	DNSServiceName      = "kube-dns"
	DNSServiceNamespace = "kube-system"
)
View Source
const (
	// Stopped indicates the server is not running.
	Stopped Status = "Stopped"

	// Started indicates the server is running.
	Started = "Started"

	// NotImplemented is returned when Status cannot be determined.
	NotImplemented = "NotImplemented"
)
View Source
const (
	ControllerManagerName = "controller-manager"
)
View Source
const (
	EtcdName = "etcd"
)
View Source
const (
	KubeletName = "kubelet"
)
View Source
const (
	ProxyName = "proxy"
)
View Source
const (
	SchedulerName = "scheduler"
)

Variables

View Source
var (
	APIServerURL   string
	ServiceIPRange = "10.1.30.0/24"
	APIServerStop  chan struct{}
)
View Source
var (
	DNSEtcdURLs = []string{"http://localhost:9090"}

	DNSEtcdDataDirectory = "/var/dns/data"
)
View Source
var (
	// EtcdClientURLs have listeners created and handle etcd API traffic
	KubeEtcdClientURLs = []string{"http://localhost:2379"}

	// EtcdPeerURLs don't have listeners created for them, they are used to pass Etcd validation
	KubeEtcdPeerURLs = []string{"http://localhost:2380"}

	// EtcdDataDirectory is where all state is stored. Can be changed with env var ETCD_DATA_DIRECTORY
	KubeEtcdDataDirectory = "/var/etcd/data"
)
View Source
var (
	WeaveProxySock = "unix:///var/run/weave/weave.sock"
	KubeletStop    chan struct{}
)
View Source
var (
	MasqueradeBit = 14
	ProxyStop     chan struct{}
)
View Source
var (
	CMStop chan struct{}
)
View Source
var (
	SchedulerStop chan struct{}
)

Functions

func StartAPIServer

func StartAPIServer()

func StartControllerManagerServer

func StartControllerManagerServer()

func StartKubeletServer

func StartKubeletServer(clusterDomain, clusterDNS string) func()

func StartProxyServer

func StartProxyServer()

func StartSchedulerServer

func StartSchedulerServer()

Types

type DNSServer

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

func NewDNSServer

func NewDNSServer(rootDomain, clusterIP, serverAddress, kubeAPIServer string) (*DNSServer, error)

func (DNSServer) Name

func (DNSServer) Name() string

Name returns the servers unique name

func (*DNSServer) Start

func (dns *DNSServer) Start()

func (*DNSServer) Status

func (dns *DNSServer) Status() Status

Status is currently not support by DNSServer

func (*DNSServer) Stop

func (dns *DNSServer) Stop()

type EtcdServer

type EtcdServer struct {
	*etcdserver.EtcdServer
	// contains filtered or unexported fields
}

Etcd is a Server which manages an Etcd cluster

func NewEtcd

func NewEtcd(clientURLStrs, peerURLStrs []string, name, dataDirectory string) (*EtcdServer, error)

NewEtcd creates a new default etcd Server using 'dataDir' for persistence. Panics if could not be configured.

func (EtcdServer) Name

func (EtcdServer) Name() string

Name returns the servers unique name

func (*EtcdServer) Start

func (e *EtcdServer) Start()

Starts starts the etcd server and listening for client connections

func (EtcdServer) Status

func (EtcdServer) Status() Status

Status is currently not support by Etcd

func (*EtcdServer) Stop

func (e *EtcdServer) Stop()

Stop closes all connections and stops the Etcd server

type LocalKube

type LocalKube struct {
	Servers
}

LocalKube provides a fully functional Kubernetes cluster running entirely through goroutines

func (*LocalKube) Add

func (lk *LocalKube) Add(server Server)

func (*LocalKube) Run

func (lk *LocalKube) Run(args []string, out io.Writer) error

type Server

type Server interface {
	// Start immediately starts the component.
	Start()
	// Stop begins the process of stopping the components.
	Stop()

	// Name returns a unique identifier for the component.
	Name() string

	// Status provides the state of the server.
	Status() Status
}

Server represents a component that Kubernetes depends on. It allows for the management of the lifecycle of the component.

func NewAPIServer

func NewAPIServer() Server

func NewControllerManagerServer

func NewControllerManagerServer() Server

func NewKubeletServer

func NewKubeletServer(clusterDomain, clusterDNS string) Server

func NewProxyServer

func NewProxyServer() Server

func NewSchedulerServer

func NewSchedulerServer() Server

type Servers

type Servers []Server

Servers allows operations to be performed on many servers at once. Uses slice to preserve ordering.

func (Servers) Get

func (servers Servers) Get(name string) (Server, error)

Get returns a server matching name, returns nil if server doesn't exit.

func (Servers) Start

func (servers Servers) Start(serverName string) error

Start is a helper method to start the Server specified, returns error if server doesn't exist.

func (Servers) StartAll

func (servers Servers) StartAll()

StartAll starts all services, starting from 0th item and ascending.

func (Servers) Status

func (servers Servers) Status() (statuses map[string]Status)

Status returns a map with the Server name as the key and it's Status as the value.

func (Servers) Stop

func (servers Servers) Stop(serverName string) error

Stop is a helper method to start the Server specified, returns error if server doesn't exist.

func (Servers) StopAll

func (servers Servers) StopAll()

StopAll stops all services, starting with the last item.

type SimpleServer

type SimpleServer struct {
	ComponentName string
	StartupFn     func()
	ShutdownFn    func()
	StatusFn      func() Status
}

SimpleServer provides a minimal implementation of Server.

func (SimpleServer) Name

func (s SimpleServer) Name() string

Name returns the name of the service.

func (SimpleServer) NoShutdown

func (s SimpleServer) NoShutdown() *SimpleServer

NoShutdown sets the ShutdownFn to print an error when the server gets shutdown. It returns itself to be chainable.

func (*SimpleServer) Start

func (s *SimpleServer) Start()

Start calls startup function.

func (*SimpleServer) Status

func (s *SimpleServer) Status() Status

Status calls the status function and returns the the Server's status.

func (*SimpleServer) Stop

func (s *SimpleServer) Stop()

Stop calls shutdown function.

type Status

type Status string

Status indicates the condition of a Server.

Directories

Path Synopsis
cmd
kube2sky is a bridge between Kubernetes and SkyDNS.
kube2sky is a bridge between Kubernetes and SkyDNS.
pkg
localkubectl
Package localkubectl allows the lifecycle of the localkube container to be controlled
Package localkubectl allows the lifecycle of the localkube container to be controlled

Jump to

Keyboard shortcuts

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