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 ¶
- func Start(cs kubernetes.Interface, conf *rest.Config)
- func Stop()
- type EventDispatcher
- type EventDispatchersContainer
- type K8sNetworkPolicyController
- type NamespaceController
- type PNPController
- type PcnK8sNetworkPolicyController
- func (npc *PcnK8sNetworkPolicyController) List(pQuery, nsQuery *pcn_types.ObjectQuery) ([]networking_v1.NetworkPolicy, error)
- func (npc *PcnK8sNetworkPolicyController) Run()
- func (npc *PcnK8sNetworkPolicyController) Stop()
- func (npc *PcnK8sNetworkPolicyController) Subscribe(event pcn_types.EventType, ...) (func(), error)
- type PcnNamespaceController
- type PcnNetworkPolicyController
- type PcnPodController
- func (p *PcnPodController) List(queryPod, queryNs, queryNode *pcn_types.ObjectQuery) ([]core_v1.Pod, error)
- func (p *PcnPodController) Run()
- func (p *PcnPodController) Stop()
- func (p *PcnPodController) Subscribe(event pcn_types.EventType, podspec, namespace, node *pcn_types.ObjectQuery, ...) (func(), error)
- type PcnServiceController
- func (s *PcnServiceController) List(queryServ, queryNs *pcn_types.ObjectQuery) ([]core_v1.Service, error)
- func (s *PcnServiceController) Run()
- func (s *PcnServiceController) Stop()
- func (s *PcnServiceController) Subscribe(event pcn_types.EventType, consumer func(*core_v1.Service, *core_v1.Service)) (func(), error)
- type PodController
- type ServiceController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
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) 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 ¶
func (npc *PcnK8sNetworkPolicyController) List(pQuery, nsQuery *pcn_types.ObjectQuery) ([]networking_v1.NetworkPolicy, error)
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 ¶
func (npc *PcnK8sNetworkPolicyController) Subscribe(event pcn_types.EventType, consumer func(*networking_v1.NetworkPolicy, *networking_v1.NetworkPolicy)) (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 PcnNamespaceController ¶
type PcnNamespaceController struct {
// contains filtered or unexported fields
}
PcnNamespaceController is the implementation of the Namespace Controller
func (*PcnNamespaceController) List ¶
func (n *PcnNamespaceController) List(query *pcn_types.ObjectQuery) ([]core_v1.Namespace, error)
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) 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
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