Documentation ¶
Index ¶
- Variables
- type API
- type AddPod
- func (ev *AddPod) Direction() controller.UpdateDirectionType
- func (ev *AddPod) Done(err error)
- func (ev *AddPod) GetName() string
- func (ev *AddPod) IsBlocking() bool
- func (ev *AddPod) Method() controller.EventMethodType
- func (ev *AddPod) String() string
- func (ev *AddPod) TransactionType() controller.UpdateTransactionType
- func (ev *AddPod) Wait() error
- type DeletePod
- func (ev *DeletePod) Direction() controller.UpdateDirectionType
- func (ev *DeletePod) Done(err error)
- func (ev *DeletePod) GetName() string
- func (ev *DeletePod) IsBlocking() bool
- func (ev *DeletePod) Method() controller.EventMethodType
- func (ev *DeletePod) String() string
- func (ev *DeletePod) TransactionType() controller.UpdateTransactionType
- func (ev *DeletePod) Wait() error
- type Deps
- type DockerClient
- type IPVersion
- type IPWithGateway
- type LocalPod
- type LocalPods
- type Option
- type Pod
- type PodInterface
- type PodManager
- func (pm *PodManager) Add(ctx context.Context, request *cni.CNIRequest) (reply *cni.CNIReply, err error)
- func (pm *PodManager) Delete(ctx context.Context, request *cni.CNIRequest) (reply *cni.CNIReply, err error)
- func (pm *PodManager) GetLocalPods() LocalPods
- func (pm *PodManager) GetPods() Pods
- func (pm *PodManager) HandlesEvent(event controller.Event) bool
- func (pm *PodManager) Init() (err error)
- func (pm *PodManager) Resync(event controller.Event, kubeStateData controller.KubeStateData, ...) error
- func (pm *PodManager) Revert(event controller.Event) error
- func (pm *PodManager) Update(event controller.Event, _ controller.UpdateOperations) (changeDescription string, err error)
- type Pods
- type Route
Constants ¶
This section is empty.
Variables ¶
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) TransactionType ¶
func (ev *AddPod) TransactionType() controller.UpdateTransactionType
TransactionType is RevertOnFailure.
type DeletePod ¶
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) Method ¶
func (ev *DeletePod) Method() controller.EventMethodType
Method is Update.
func (*DeletePod) TransactionType ¶
func (ev *DeletePod) TransactionType() controller.UpdateTransactionType
TransactionType is BestEffortIgnoreErrors.
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 IPWithGateway ¶
type IPWithGateway struct { Version IPVersion Address *net.IPNet // IP with mask combined Gateway net.IP }
IPWithGateway encapsulates IP address and gateway.
type Option ¶
type Option func(*PodManager)
Option is a function that can be used in NewPlugin to customize Plugin.
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).
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.