controllers

package
v0.0.0-...-a143e3c Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package controllers contains the controllers used by Polycube. They are used to watch for resource events or to get information about them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(cs kubernetes.Interface, conf *rest.Config)

Start starts all the controllers included

func Stop

func Stop()

Stop stops all the controllers that have been started at once.

Types

type EventDispatcher

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

EventDispatcher dispatches the event to all subscribers

func NewEventDispatcher

func NewEventDispatcher() *EventDispatcher

NewEventDispatcher starts a new event dispatcher

func (*EventDispatcher) Add

func (d *EventDispatcher) Add(s subscriber) string

Add will add a new subscriber

func (*EventDispatcher) CleanUp

func (d *EventDispatcher) CleanUp()

CleanUp will remove all subscribers at once

func (*EventDispatcher) Dispatch

func (d *EventDispatcher) Dispatch(current, prev interface{})

Dispatch will dispatch the event to the list of subscribers

func (*EventDispatcher) Remove

func (d *EventDispatcher) Remove(i string)

Remove will remove a subscriber

type EventDispatchersContainer

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

EventDispatchersContainer contains the three basic EventDispatcher-s: New, Update, Delete

type K8sNetworkPolicyController

type K8sNetworkPolicyController interface {
	// Run starts the controller
	Run()
	// Stop will stop the controller
	Stop()
	// Subscribe executes the function consumer when the event event is triggered.
	// It returns an error if the event type does not exist.
	// It returns a function to call when you want to stop tracking that event.
	Subscribe(event pcn_types.EventType, consumer func(*networking_v1.NetworkPolicy, *networking_v1.NetworkPolicy)) (func(), error)
	// List gets policies according to a specific query
	List(pQuery, nsQuery *pcn_types.ObjectQuery) ([]networking_v1.NetworkPolicy, error)
}

K8sNetworkPolicyController is the interface of the Kubernetes Network Policies Controller

func K8sPolicies

func K8sPolicies() K8sNetworkPolicyController

K8sPolicies returns the Kubernetes Network Policy Controller

type NamespaceController

type NamespaceController interface {
	// Run starts the namespace controller
	Run()
	// Stop will stop the namespace controller
	Stop()
	// Subscribe executes the function consumer when the event event is triggered.
	// It returns an error if the event type does not exist.
	// It returns a function to call when you want to stop tracking that event.
	Subscribe(event pcn_types.EventType, consumer func(*core_v1.Namespace, *core_v1.Namespace)) (func(), error)
	// List gets namespaces according to a specific namespace query
	List(query *pcn_types.ObjectQuery) ([]core_v1.Namespace, error)
}

NamespaceController is the interface of the Namespace Controller

func Namespaces

func Namespaces() NamespaceController

Namespaces returns the Namespace controller

type PNPController

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

PNPController struct defines all the data needed by the controller

func (*PNPController) List

func (p *PNPController) List(pQuery, nsQuery *pcn_types.ObjectQuery) ([]v1beta.PolycubeNetworkPolicy, error)

List returns a list of polycube network policies that match the specified criteria. Returns an empty list if no network policies have been found or an error occurred. The error is returned in this case.

func (*PNPController) Run

func (p *PNPController) Run()

Run starts the pod controller

func (*PNPController) Stop

func (p *PNPController) Stop()

Stop will stop the controller

func (*PNPController) Subscribe

func (p *PNPController) Subscribe(event pcn_types.EventType, consumer func(*v1beta.PolycubeNetworkPolicy, *v1beta.PolycubeNetworkPolicy)) (func(), error)

Subscribe executes the function consumer when the event event is triggered. It returns an error if the event type does not exist. It returns a function to call when you want to stop tracking that event.

type PcnK8sNetworkPolicyController

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

PcnK8sNetworkPolicyController is the implementation of the k8s network policy controller

func (*PcnK8sNetworkPolicyController) List

List returns a list of network policies that match the specified criteria. Returns an empty list if no network policies have been found or an error occurred. The error is returned in this case.

func (*PcnK8sNetworkPolicyController) Run

func (npc *PcnK8sNetworkPolicyController) Run()

Run starts the network policy controller

func (*PcnK8sNetworkPolicyController) Stop

func (npc *PcnK8sNetworkPolicyController) Stop()

Stop stops the controller

func (*PcnK8sNetworkPolicyController) Subscribe

Subscribe executes the function consumer when the event event is triggered. It returns an error if the event type does not exist. It returns a function to call when you want to stop tracking that event.

type PcnNamespaceController

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

PcnNamespaceController is the implementation of the Namespace Controller

func (*PcnNamespaceController) List

List gets namespaces according to a specific namespace query

func (*PcnNamespaceController) Run

func (n *PcnNamespaceController) Run()

Run starts the namespace controller

func (*PcnNamespaceController) Stop

func (n *PcnNamespaceController) Stop()

Stop will stop the namespace controller

func (*PcnNamespaceController) Subscribe

func (n *PcnNamespaceController) Subscribe(event pcn_types.EventType, consumer func(*core_v1.Namespace, *core_v1.Namespace)) (func(), error)

Subscribe executes the function consumer when the event event is triggered. It returns an error if the event type does not exist. It returns a function to call when you want to stop tracking that event.

type PcnNetworkPolicyController

type PcnNetworkPolicyController interface {
	// Run starts the controller
	Run()
	// Stop will stop the controller
	Stop()
	// Subscribe executes the function consumer when the event event is triggered.
	// It returns an error if the event type does not exist.
	// It returns a function to call when you want to stop tracking that event.
	Subscribe(event pcn_types.EventType, consumer func(*v1beta.PolycubeNetworkPolicy, *v1beta.PolycubeNetworkPolicy)) (func(), error)
	// List gets policies according to a policy query and a namespace query
	List(pQuery, nsQuery *pcn_types.ObjectQuery) ([]v1beta.PolycubeNetworkPolicy, error)
}

PcnNetworkPolicyController is the interface of the polycube netpol controller

func PcnPolicies

func PcnPolicies() PcnNetworkPolicyController

PcnPolicies returns the Polycube Network Policy Controller

type PcnPodController

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

PcnPodController is the implementation of the pod controller

func (*PcnPodController) List

func (p *PcnPodController) List(queryPod, queryNs, queryNode *pcn_types.ObjectQuery) ([]core_v1.Pod, error)

List gets pod according to a specific pod query and a namespace query

func (*PcnPodController) Run

func (p *PcnPodController) Run()

Run starts the pod controller

func (*PcnPodController) Stop

func (p *PcnPodController) Stop()

Stop will stop the pod controller

func (*PcnPodController) Subscribe

func (p *PcnPodController) Subscribe(event pcn_types.EventType, podspec, namespace, node *pcn_types.ObjectQuery, phase core_v1.PodPhase, consumer func(*core_v1.Pod, *core_v1.Pod)) (func(), error)

Subscribe executes the function consumer when the event event is triggered. It returns an error if the event type does not exist. It returns a function to call when you want to stop tracking that event.

type PcnServiceController

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

PcnServiceController is the implementation of the service controller

func (*PcnServiceController) List

func (s *PcnServiceController) List(queryServ, queryNs *pcn_types.ObjectQuery) ([]core_v1.Service, error)

List gets service according to a specific service query and a namespace query. NOTE: labels, in this case, are those in the spec.Selector, not those of the service itself

func (*PcnServiceController) Run

func (s *PcnServiceController) Run()

Run starts the service controller

func (*PcnServiceController) Stop

func (s *PcnServiceController) Stop()

Stop will stop the service controller

func (*PcnServiceController) Subscribe

func (s *PcnServiceController) Subscribe(event pcn_types.EventType, consumer func(*core_v1.Service, *core_v1.Service)) (func(), error)

Subscribe executes the function consumer when the event event is triggered. It returns an error if the event type does not exist. It returns a function to call when you want to stop tracking that event.

type PodController

type PodController interface {
	// Run starts the pod controller
	Run()
	// Stop will stop the pod controller
	Stop()
	// Subscribe executes the function consumer when the event event is triggered.
	// It returns an error if the event type does not exist.
	// It returns a function to call when you want to stop tracking that event.
	Subscribe(event pcn_types.EventType, podspec, namespace, node *pcn_types.ObjectQuery, phase core_v1.PodPhase, consumer func(*core_v1.Pod, *core_v1.Pod)) (func(), error)
	// List gets pod according to a specific pod query and a namespace query
	List(queryPod, queryNs, queryNode *pcn_types.ObjectQuery) ([]core_v1.Pod, error)
}

PodController is the interface of the pod controller

func Pods

func Pods() PodController

Pods returns the pod controller

type ServiceController

type ServiceController interface {
	// Run starts the service controller
	Run()
	// Stop will stop the service controller
	Stop()
	// Subscribe executes the function consumer when the event event is triggered.
	// It returns an error if the event type does not exist.
	// It returns a function to call when you want to stop tracking that event.
	Subscribe(event pcn_types.EventType, consumer func(*core_v1.Service, *core_v1.Service)) (func(), error)
	// List gets services according to a specific service query and a namespace query
	List(queryServ, queryNs *pcn_types.ObjectQuery) ([]core_v1.Service, error)
}

ServiceController is the interface of the service controller

func Services

func Services() ServiceController

Services returns the Service Controller

Jump to

Keyboard shortcuts

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