podmanager

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: Apache-2.0 Imports: 11 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPlugin = *NewPlugin()

DefaultPlugin is a default instance of PodManager.

Functions

This section is empty.

Types

type API

type API interface {
	// GetLocalPods returns all currently locally deployed pods.
	// The method should be called only from within the main event loop
	// (not thread safe) and not before the startup resync.
	GetLocalPods() LocalPods

	// GetPods returns all currently deployed pods (local and non-local) in the cluster.
	// The method should be called only from within the main event loop
	// (not thread safe) and not before the startup resync.
	GetPods() Pods
}

API defines methods provided by PodManager for use by other plugins.

type AddPod

type AddPod struct {

	// input arguments (read by event handlers)
	Pod              podmodel.ID
	ContainerID      string
	NetworkNamespace string
	IPAMType         string
	IPAMData         string

	// output arguments (edited by event handlers)
	Interfaces []PodInterface
	Routes     []Route
	// contains filtered or unexported fields
}

AddPod event is triggered when a new pod is being deployed on this node.

func NewAddPodEvent

func NewAddPodEvent(request *cni.CNIRequest) *AddPod

NewAddPodEvent is constructor for AddPod event.

func (*AddPod) Direction

func (ev *AddPod) Direction() controller.UpdateDirectionType

Direction is forward.

func (*AddPod) Done

func (ev *AddPod) Done(err error)

Done propagates error to the event producer.

func (*AddPod) GetName

func (ev *AddPod) GetName() string

GetName returns name of the AddPod event.

func (*AddPod) IsBlocking

func (ev *AddPod) IsBlocking() bool

IsBlocking returns true.

func (*AddPod) Method

func (ev *AddPod) Method() controller.EventMethodType

Method is Update.

func (*AddPod) String

func (ev *AddPod) String() string

String describes AddPod event.

func (*AddPod) TransactionType

func (ev *AddPod) TransactionType() controller.UpdateTransactionType

TransactionType is RevertOnFailure.

func (*AddPod) Wait

func (ev *AddPod) Wait() error

Wait waits for the result of the AddPod event.

type DeletePod

type DeletePod struct {
	Pod podmodel.ID
	// contains filtered or unexported fields
}

DeletePod event is triggered when pod deployed on this node is being terminated.

func NewDeletePodEvent

func NewDeletePodEvent(request *cni.CNIRequest) *DeletePod

NewDeletePodEvent is constructor for DeletePod event.

func (*DeletePod) Direction

func (ev *DeletePod) Direction() controller.UpdateDirectionType

Direction is Reverse.

func (*DeletePod) Done

func (ev *DeletePod) Done(err error)

Done propagates error to the event producer.

func (*DeletePod) GetName

func (ev *DeletePod) GetName() string

GetName returns name of the DeletePod event.

func (*DeletePod) IsBlocking

func (ev *DeletePod) IsBlocking() bool

IsBlocking returns true.

func (*DeletePod) Method

func (ev *DeletePod) Method() controller.EventMethodType

Method is Update.

func (*DeletePod) String

func (ev *DeletePod) String() string

String describes DeletePod event.

func (*DeletePod) TransactionType

func (ev *DeletePod) TransactionType() controller.UpdateTransactionType

TransactionType is BestEffortIgnoreErrors.

func (*DeletePod) Wait

func (ev *DeletePod) Wait() error

Wait waits for the result of the DeletePod event.

type Deps

type Deps struct {
	infra.PluginDeps
	EventLoop controller.EventLoop
	GRPC      grpc.Server
}

Deps lists dependencies of PodManager.

type DockerClient

type DockerClient interface {
	// Ping pings the docker server.
	Ping() error
	// ListContainers returns a slice of containers matching the given criteria.
	ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error)
	// InspectContainer returns information about a container by its ID.
	InspectContainer(id string) (*docker.Container, error)
}

DockerClient defines API of a Docker client needed by PodManager. The interface allows to inject mock Docker client in the unit tests.

type IPVersion

type IPVersion int

IPVersion is either v4 or v6.

const (
	// IPv4 represents IP version 4.
	IPv4 IPVersion = iota
	// IPv6 represents IP version 6.
	IPv6
)

type IPWithGateway

type IPWithGateway struct {
	Version IPVersion
	Address *net.IPNet // IP with mask combined
	Gateway net.IP
}

IPWithGateway encapsulates IP address and gateway.

type LocalPod

type LocalPod struct {
	ID               podmodel.ID
	ContainerID      string
	NetworkNamespace string
}

LocalPod represents a locally deployed pod (locally = on this node).

func (*LocalPod) String

func (p *LocalPod) String() string

String returns human-readable string representation of local pod metadata.

type LocalPods

type LocalPods map[podmodel.ID]*LocalPod

LocalPods is a map of local pod-ID -> Pod info.

func (LocalPods) String

func (ps LocalPods) String() string

String returns a string representation of the local pods.

type Option

type Option func(*PodManager)

Option is a function that can be used in NewPlugin to customize Plugin.

func UseDeps

func UseDeps(f func(*Deps)) Option

UseDeps returns Option that can inject custom dependencies.

type Pod

type Pod struct {
	ID          podmodel.ID
	IPAddress   string
	Labels      map[string]string
	Annotations map[string]string
}

Pod represents a pod in the cluster (may or may not be local).

func (*Pod) String

func (p *Pod) String() string

String returns human-readable string representation of pod metadata.

type PodInterface

type PodInterface struct {
	HostName    string           // name of the interface in the host stack
	IPAddresses []*IPWithGateway // list of assigned IP addresses
}

PodInterface represents a single pod interface.

type PodManager

type PodManager struct {
	Deps
	// contains filtered or unexported fields
}

PodManager plugin manages pods deployed on this node. It serves Add/Delete CNI requests, converts them to AddPod and DeletePod events, and maintains a map of metadata for all locally deployed pods, with enough information for other plugins to be able to (re)construct connectivity between pods and the vswitch.

func NewPlugin

func NewPlugin(opts ...Option) *PodManager

NewPlugin creates a new Plugin with the provided Options.

func (*PodManager) Add

func (pm *PodManager) Add(ctx context.Context, request *cni.CNIRequest) (reply *cni.CNIReply, err error)

Add converts CNI Add request to AddPod event.

func (*PodManager) Delete

func (pm *PodManager) Delete(ctx context.Context, request *cni.CNIRequest) (reply *cni.CNIReply, err error)

Delete converts CNI Delete request to DeletePod event.

func (*PodManager) GetLocalPods

func (pm *PodManager) GetLocalPods() LocalPods

GetLocalPods returns all currently locally deployed pods. The method should be called only from within the main event loop (not thread safe) and not before the startup resync.

func (*PodManager) GetPods

func (pm *PodManager) GetPods() Pods

GetPods returns all currently deployed pods (local and non-local) in the cluster. The method should be called only from within the main event loop (not thread safe) and not before the startup resync.

func (*PodManager) HandlesEvent

func (pm *PodManager) HandlesEvent(event controller.Event) bool

HandlesEvent select AddPod, DeletePod, k8s pod changes, and any resync events.

func (*PodManager) Init

func (pm *PodManager) Init() (err error)

Init connects to Docker server and also registers the plugin to serve Add/Delete CNI requests.

func (*PodManager) Resync

func (pm *PodManager) Resync(event controller.Event, kubeStateData controller.KubeStateData,
	resyncCount int, _ controller.ResyncOperations) error

Resync re-synchronizes the map of local pods using information provided by Docker server.

func (*PodManager) Revert

func (pm *PodManager) Revert(event controller.Event) error

Revert is used to remove a pod entry from the map of local pods when AddPod event fails.

func (*PodManager) Update

func (pm *PodManager) Update(event controller.Event, _ controller.UpdateOperations) (changeDescription string, err error)

Update handles AddPod and DeletePod events.

type Pods

type Pods map[podmodel.ID]*Pod

Pods is a map of pod-ID -> Pod info.

func (Pods) String

func (ps Pods) String() string

String returns a string representation of the pods.

type Route

type Route struct {
	Network *net.IPNet
	Gateway net.IP
}

Route represents single IP route.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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