listener

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

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

View Source
const (
	HttpGetParamWatch           = "watch=true"
	HttpGetParamResourceVersion = "resourceVersion"
)
View Source
const (
	KubeEventAdded    = "ADDED"
	KubeEventDeleted  = "DELETED"
	KubeEventModified = "MODIFIED"
)
View Source
const TranslateGroupStartIndex = 0

Variables

View Source
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 ExposedIPSpec struct {
	RomanaIP      RomanaIP
	NodeIPAddress string
	Activated     bool
}

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:

  1. namespaceNotificationPath for namespace additions/deletions
  2. 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 RomanaIP added in v1.1.0

type RomanaIP struct {
	Auto bool   `json:"auto"`
	IP   string `json:"ip"`
}

type TenantCacheEntry

type TenantCacheEntry struct {
	Tenant   common.Tenant
	Segments []common.Segment
}

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
)

Directories

Path Synopsis
Main entry point for Kubernetes listener
Main entry point for Kubernetes listener

Jump to

Keyboard shortcuts

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