Documentation ¶
Overview ¶
Package listener listens to Kubernetes for policy updates.
Package listener's nodes.go contains a subset of listener functionality where it connects to kubernetes using kubernetes client-go and watches node creation/deletion events and then adds/deletes the nodes to/from romana cluster appropriately.
Package listener implements kubernetes API specific helper functions.
Index ¶
- Constants
- Variables
- func HandleDefaultPolicy(o *v1.Namespace, l *KubeListener)
- func ProduceNewPolicyEvents(out chan Event, done <-chan struct{}, KubeListener *KubeListener)
- type Event
- type ExposedIPSpec
- type ExposedIPSpecMap
- type ExternalIP
- type KubeListener
- func (l *KubeListener) CreateSchema(overwrite bool) error
- func (l *KubeListener) Initialize(client *common.RestClient) error
- func (l *KubeListener) Name() string
- func (l *KubeListener) ProcessNodeEvents(done <-chan struct{})
- func (l *KubeListener) Routes() common.Routes
- func (l *KubeListener) SetConfig(config common.ServiceConfig) error
- type NoMoreIngressEntities
- type PolicyTranslator
- type RomanaIP
- type TenantCacheEntry
- type TranslateGroup
- type Translator
- func (t Translator) GetClient() *common.RestClient
- func (t *Translator) Init(client *common.RestClient, segmentLabelName, tenantLabelName string)
- func (t Translator) Kube2Romana(kubePolicy v1beta1.NetworkPolicy) (common.Policy, error)
- func (t Translator) Kube2RomanaBulk(kubePolicies []v1beta1.NetworkPolicy) ([]common.Policy, []v1beta1.NetworkPolicy, error)
- type TranslatorError
- type TranslatorErrorType
Constants ¶
const ( HttpGetParamWatch = "watch=true" HttpGetParamResourceVersion = "resourceVersion" )
const ( KubeEventAdded = "ADDED" KubeEventDeleted = "DELETED" KubeEventModified = "MODIFIED" )
const TranslateGroupStartIndex = 0
Variables ¶
var (
RomanaExposedIPSpecMap = ExposedIPSpecMap{IPForService: make(map[string]ExposedIPSpec)}
)
Functions ¶
func HandleDefaultPolicy ¶
func HandleDefaultPolicy(o *v1.Namespace, l *KubeListener)
HandleDefaultPolicy handles isolation flag on a namespace by creating/deleting default network policy. See http://kubernetes.io/docs/user-guide/networkpolicies/
func ProduceNewPolicyEvents ¶
func ProduceNewPolicyEvents(out chan Event, done <-chan struct{}, KubeListener *KubeListener)
ProduceNewPolicyEvents produces kubernetes network policy events that arent applied in romana policy service yet.
Types ¶
type Event ¶
type Event struct { Type string `json:"Type"` Object interface{} }
Event is a representation of a structure that we receive from kubernetes API.
type ExposedIPSpec ¶ added in v1.1.0
type ExposedIPSpecMap ¶ added in v1.1.0
type ExposedIPSpecMap struct { sync.Mutex IPForService map[string]ExposedIPSpec }
type ExternalIP ¶ added in v1.1.0
type ExternalIP struct {
IP string `json:"ip" form:"ip"`
}
type KubeListener ¶
type KubeListener struct { Watchers map[string]cache.ListerWatcher // contains filtered or unexported fields }
KubeListener is a Service that listens to updates from Kubernetes by connecting to the endpoints specified and consuming chunked JSON documents. The endpoints are constructed from kubeURL and the following paths:
- namespaceNotificationPath for namespace additions/deletions
- policyNotificationPathPrefix + <namespace name> + policyNotificationPathPostfix for policy additions/deletions.
func (*KubeListener) CreateSchema ¶
func (l *KubeListener) CreateSchema(overwrite bool) error
func (*KubeListener) Initialize ¶
func (l *KubeListener) Initialize(client *common.RestClient) error
func (*KubeListener) Name ¶
func (l *KubeListener) Name() string
Name implements method of Service interface.
func (*KubeListener) ProcessNodeEvents ¶
func (l *KubeListener) ProcessNodeEvents(done <-chan struct{})
ProcessNodeEvents processes kubernetes node events, there by adding/deleting nodes to/from romana cluster automatically when they are added/removed to/from kubernetes cluster.
func (*KubeListener) Routes ¶
func (l *KubeListener) Routes() common.Routes
Routes returns various routes used in the service.
func (*KubeListener) SetConfig ¶
func (l *KubeListener) SetConfig(config common.ServiceConfig) error
SetConfig implements SetConfig function of the Service interface.
type NoMoreIngressEntities ¶
type NoMoreIngressEntities struct{}
NoMoreIngressEntities is an error that indicates that translateNextIngress went through all Ingress entries in TranslateGroup.kubePolicy.
func (NoMoreIngressEntities) Error ¶
func (e NoMoreIngressEntities) Error() string
type PolicyTranslator ¶
type PolicyTranslator interface { Init(*common.RestClient, string) // Translates kubernetes policy into romana format. Kube2Romana(v1beta1.NetworkPolicy) (common.Policy, error) // Translates number of kubernetes policies into romana format. // Returns a list of translated policies, list of original policies // that failed to translate and an error. Kube2RomanaBulk([]v1beta1.NetworkPolicy) ([]common.Policy, []v1beta1.NetworkPolicy, error) }
type TenantCacheEntry ¶
type TranslateGroup ¶
type TranslateGroup struct {
// contains filtered or unexported fields
}
TranslateGroup represent a state of translation of kubernetes policy into romana policy.
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
var PTranslator Translator
TODO there should be a better way to introduce translator then global variable like this one.
func (Translator) GetClient ¶
func (t Translator) GetClient() *common.RestClient
func (*Translator) Init ¶
func (t *Translator) Init(client *common.RestClient, segmentLabelName, tenantLabelName string)
func (Translator) Kube2Romana ¶
func (t Translator) Kube2Romana(kubePolicy v1beta1.NetworkPolicy) (common.Policy, error)
Kube2Romana reserved for future use.
func (Translator) Kube2RomanaBulk ¶
func (t Translator) Kube2RomanaBulk(kubePolicies []v1beta1.NetworkPolicy) ([]common.Policy, []v1beta1.NetworkPolicy, error)
Kube2RomanaBulk attempts to translate a list of kubernetes policies into romana representation, returns a list of translated policies and a list of policies that can't be translated in original format.
type TranslatorError ¶
type TranslatorError struct { Code TranslatorErrorType Details error }
func (TranslatorError) Error ¶
func (t TranslatorError) Error() string
type TranslatorErrorType ¶
type TranslatorErrorType int
const ( ErrorCacheUpdate TranslatorErrorType = iota ErrorTenantNotInCache ErrorTranslatingPolicyTarget ErrorTranslatingPolicyIngress )