package hostport

import "k8s.io/kubernetes/contrib/mesos/pkg/scheduler/podtask/hostport"

Index

Constants

const (
	// maps a Container.HostPort to the same exact offered host port, ignores .HostPort = 0
	StrategyFixed = Strategy("fixed")
	// same as MappingFixed, except that .HostPort of 0 are mapped to any port offered
	StrategyWildcard = Strategy("wildcard")
)

Types

type DuplicateError

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

func (*DuplicateError) Error

func (err *DuplicateError) Error() string

type Mapper

type Mapper interface {
	// Map maps the given pod and the given mesos offer and returns a
	// slice of port mappings or an error if the mapping failed
	Map(pod *api.Pod, roles []string, offer *mesos.Offer) ([]Mapping, error)
}

Objects implementing the Mapper interface generate port mappings from k8s container ports to ports offered by mesos

type MapperFunc

type MapperFunc func(*api.Pod, []string, *mesos.Offer) ([]Mapping, error)

MapperFunc is a function adapter to the Mapper interface

func (MapperFunc) Map

func (f MapperFunc) Map(pod *api.Pod, roles []string, offer *mesos.Offer) ([]Mapping, error)

Map calls f(t, offer)

type Mapping

type Mapping struct {
	ContainerIdx int    // index of the container in the pod spec
	PortIdx      int    // index of the port in a container's port spec
	OfferPort    uint64 // the port offered by mesos
	Role         string // the role asssociated with the offered port
}

A Mapping represents the mapping between k8s container ports ports offered by mesos. It references the k8s' container and port and specifies the offered mesos port and the offered port's role

func FixedMapper

func FixedMapper(pod *api.Pod, roles []string, offer *mesos.Offer) ([]Mapping, error)

FixedMapper maps k8s host ports to offered ports ignoring hostPorts == 0 (remaining pod-private)

func WildcardMapper

func WildcardMapper(pod *api.Pod, roles []string, offer *mesos.Offer) ([]Mapping, error)

WildcardMapper maps k8s wildcard ports (hostPort == 0) to any available offer port

type PortAllocationError

type PortAllocationError struct {
	PodID string
	Ports []uint64
}

func (*PortAllocationError) Error

func (err *PortAllocationError) Error() string

type Strategy

type Strategy string

func (Strategy) NewMapper

func (defaultStrategy Strategy) NewMapper(pod *api.Pod) Mapper

NewMapper returns a new mapper based on the port mapping key value

Source Files

mapper.go

Version
v1.4.8
Published
Jan 12, 2017
Platform
linux/amd64
Imports
6 packages
Last checked
9 minutes ago

Tools for package owners.