swarm

package
v0.0.0-...-a355528 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HostNotSpecified is a constant that indicates no host information is provided
	// so a route / listener derived from this Swarm service should apply to any (or all) loadbalancers.
	HostNotSpecified = ""
)
View Source
const (

	// LabelExternalLoadBalancerSpec is the label for marking a service as public facing.
	// The value is a url.  The protocol, host and port will be extracted from the URL
	// to configure the external load balancer.  The ELB will be configured to listen
	// at the specified port (or 80), using the specified protocol, and the host is used to
	// select which load balancer in the config file on the manager nodes /var/lib/docker/editions/lb.config
	// TODO(chungers) - While the hostname is used to select the ELB to use, we will also provide support
	// for HTTP/S vhosts in the future if the hostname is not matched to an ELB, we will select a top level ELB
	// and then use the subdomain in the hostname to configure a HAProxy with http header routing.
	LabelExternalLoadBalancerSpec = "docker.swarm.lb"
)

Variables

View Source
var (
	// AnyLabels matches any labels in a service
	AnyLabels = map[string]string{
		"*": "",
	}

	// AnyServices is a matcher that will match any service.
	AnyServices = func(s swarm.Service) bool {
		return true
	}
)

Functions

func AmISwarmLeader

func AmISwarmLeader(ctx context.Context, client client.APIClient) (bool, error)

AmISwarmLeader determines if the current node is the swarm manager leader

func RoutesFromSwarmServices

func RoutesFromSwarmServices() (ingress.RouteHandler, error)

RoutesFromSwarmServices determines the routes based on the services running in the Docker swarm

Types

type Docker

type Docker docker.ConnectInfo

Docker is alias for docker connection information

type Routes

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

Routes can derive a list of routes based on Docker services

func (*Routes) List

func (p *Routes) List() (map[ingress.Vhost][]loadbalancer.Route, error)

List will return all the known routes for this Docker swarm of matching services.

func (*Routes) RoutesFromServices

func (p *Routes) RoutesFromServices(services []swarm.Service) (map[ingress.Vhost][]loadbalancer.Route, error)

RoutesFromServices analyzes the given set of services and option and produces a routes by vhost.

type RoutesBuilder

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

RoutesBuilder simplifies creation of a routes.

func NewServiceRoutes

func NewServiceRoutes(client docker.APIClientCloser) *RoutesBuilder

NewServiceRoutes creates a routes.

func (*RoutesBuilder) AddRule

func (b *RoutesBuilder) AddRule(n string, m ServiceMatcher,
	toRoutes func([]swarm.Service) (map[ingress.Vhost][]loadbalancer.Route, error)) *RoutesBuilder

AddRule adds a rule to aggregate the routes for

func (*RoutesBuilder) Build

func (b *RoutesBuilder) Build() (*Routes, error)

Build creates the routes.

func (*RoutesBuilder) SetHardSyncWithLB

func (b *RoutesBuilder) SetHardSyncWithLB(t bool) *RoutesBuilder

SetHardSyncWithLB forces the routes to do a hard sync for every service. This is not very efficient when there are lots of services.

func (*RoutesBuilder) SetOptions

func (b *RoutesBuilder) SetOptions(options ingress.Options) *RoutesBuilder

SetOptions sets the ingress options

func (*RoutesBuilder) SetSpecLabels

func (b *RoutesBuilder) SetSpecLabels(lbSpec, certSpec string) *RoutesBuilder

SetSpecLabels sets the label to look for for loadbalancer spec and certifcate spec

type ServiceMatcher

type ServiceMatcher func(swarm.Service) bool

ServiceMatcher is a swarm.Service predicate.

func MatchSpecLabels

func MatchSpecLabels(kv map[string]string) ServiceMatcher

MatchSpecLabels returns a matcher that matches the labels as given map. This is an OR / ANY match

type Spec

type Spec struct {
	// Docker holds the connection params to the Docker engine for join tokens, etc.
	Docker `json:",inline" yaml:",inline"`
}

Spec is the struct that captures the configuration of the swarm-based ingress route finder

Jump to

Keyboard shortcuts

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