converter

package
v0.0.0-...-d67a62d Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Convert Kubernetes resources like Pods and Nodes to MidoNet Translation.

Index

Constants

View Source
const (
	// HostIDAnnotation annotates MidoNet Host ID for the Node.
	HostIDAnnotation = "midonet.org/host-id"

	// TunnelZoneIDAnnotation annotates MidoNet Tunnel Zone ID for the Node.
	// An empty string means the auto-created default tunnel zone.
	TunnelZoneIDAnnotation = "midonet.org/tunnel-zone-id"

	// TunnelEndpointIPAnnotation annotates MidoNet Tunnel Endpoint IP for
	// the Node.
	TunnelEndpointIPAnnotation = "midonet.org/tunnel-endpoint-ip"

	// MACAnnotation annotates MAC address for the Pod/Node.
	MACAnnotation = "midonet.org/mac-address"
)
View Source
const (
	// OwnerUIDLabel is a label to record the Kubernetes resource for which
	// this Translation is created for.
	// It's somehow redundant with OwnerReference but you can't use
	// arbitrary fields for field selectors.
	OwnerUIDLabel = "midonet.org/owner-uid"

	// GlobalLabel annotates that the Translations is global resources.
	// That is, Translations which doesn't belong to a particular
	// Kubernetes resource.  (See global.go)
	GlobalLabel = "midonet.org/global"
)
View Source
const (
	// MidoNetAPIDeleter is used to defer deletion of Translation
	// until it's processed by the pusher controller.
	MidoNetAPIDeleter = "midonet.org/deleter"
)
View Source
const (
	// TranslationVersion is a seed for Translation names and
	// backend resource IDs.
	// Changing TranslationVersion changes every Translation names
	// and backend resource IDs this controller would produce.  That is,
	// it effectively deletes every Translations and their backend resources
	// and create them with different IDs.  While it would cause severe
	// user traffic interruptions for a while, it can be useful when
	// upgrading the controller with incompatible Translations.
	TranslationVersion = "3"
)

Variables

This section is empty.

Functions

func ClusterRouterID

func ClusterRouterID(config *Config) uuid.UUID

ClusterRouterID is the ID of the cluster router for this deployment.

func DefaultTunnelZoneID

func DefaultTunnelZoneID(config *Config) uuid.UUID

DefaultTunnelZoneID is the ID of the default MidoNet Tunnel Zone for this deployment.

func EnsureGlobalResources

func EnsureGlobalResources(mncli mncli.Interface, config *Config, recorder record.EventRecorder) error

EnsureGlobalResources ensures to create Translations for global resources.

func IDForKey

func IDForKey(kind string, key string) uuid.UUID

IDForKey deterministically generates a MidoNet UUID for a given Kubernetes resource key, that is "Namespace/Name" string. Note: This function is also (ab)used for our pseudo resources; ServicePort, ServicePortSub, and Endpoint.

func MACForKey

func MACForKey(key string) net.HardwareAddr

MACForKey deterministically generates an MAC address from a given string, which is typically a Kubernetes resource key. Note: Don't assume this conflict-free as the output space is rather small. (only 24 bits)

func MainChainID

func MainChainID(config *Config) uuid.UUID

MainChainID is the ID of MidoNet Chain which contains the Rules to dispatch to other global Chains including ServicesChainID.

func NewHandler

func NewHandler(converter Converter, updater Updater, config *Config) controller.Handler

NewHandler creates a converterHandler.

func ServicesChainID

func ServicesChainID(config *Config) uuid.UUID

ServicesChainID is the ID of MidoNet Chain which contains the Rules for each services.

func SubID

func SubID(id uuid.UUID, s string) uuid.UUID

SubID deterministically generates another MidoNet UUID for the resource identified by the given UUID. It's used e.g. when more than two MidoNet resources (thus UUIDs) are necessary for a Kubernetes resource.

Types

type BackendResource

type BackendResource interface {
	ToAPI(interface{}) (*v1.BackendResource, error)
}

BackendResource represents backend resources converted from k8s resources

type Config

type Config struct {
	Tenant string
}

Config contains configuration for converter and its sub packages.

func NewConfigFromEnvConfig

func NewConfigFromEnvConfig(config *config.Config) *Config

NewConfigFromEnvConfig creates Config from envconfig instance.

type Converter

type Converter interface {
	Convert(key Key, obj interface{}, config *Config) ([]BackendResource, SubResourceMap, error)
}

Converter converts a Kubernetes resource to zero or more backend resources.

type Key

type Key struct {
	Kind      string
	Namespace string
	Name      string

	// Unversioned=true makes this Key and its associated Translation
	// unversioned.  That is, keys and IDs are not changed when
	// TranslationVersion is bumped.  It's necessary for resources
	// which doesn't have IDs in the first place.
	// REVISIT: Probably Key is not the appropriate place to put this info.
	Unversioned bool
}

Key is an identifier of a Translation.

func (*Key) Key

func (k *Key) Key() string

Key returns MetaNamespaceKeyFunc style key for the Key

type SubResource

type SubResource interface {
	Convert(key Key, config *Config) ([]BackendResource, error)
}

SubResource is a pseudo resource to represent a part of a k8s resource. For example, we represent a k8s service as a set of "ServicePort" sub resources.

type SubResourceMap

type SubResourceMap map[Key]SubResource

SubResourceMap represents zero or more SubResources. It's returned by a Conveter.Convert().

type Updater

type Updater interface {
	// NOTE: Pass GVK explicitly as List'ed objects don't have valid
	// TypeMeta.  https://github.com/kubernetes/kubernetes/issues/3030
	Update(parentKind schema.GroupVersionKind, parentObj interface{}, resources map[Key][]BackendResource) error
}

Updater stores the converted resources.

func NewTranslationUpdater

func NewTranslationUpdater(client mncli.Interface, recorder record.EventRecorder) Updater

NewTranslationUpdater returns an updater to store Translation resources.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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