Documentation ¶
Overview ¶
Convert Kubernetes resources like Pods and Nodes to MidoNet Translation.
Index ¶
- Constants
- func ClusterRouterID(config *Config) uuid.UUID
- func DefaultTunnelZoneID(config *Config) uuid.UUID
- func EnsureGlobalResources(mncli mncli.Interface, config *Config, recorder record.EventRecorder) error
- func IDForKey(kind string, key string) uuid.UUID
- func MACForKey(key string) net.HardwareAddr
- func MainChainID(config *Config) uuid.UUID
- func NewHandler(converter Converter, updater Updater, config *Config) controller.Handler
- func ServicesChainID(config *Config) uuid.UUID
- func SubID(id uuid.UUID, s string) uuid.UUID
- type BackendResource
- type Config
- type Converter
- type Key
- type SubResource
- type SubResourceMap
- type Updater
Constants ¶
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" )
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" )
const ( // MidoNetAPIDeleter is used to defer deletion of Translation // until it's processed by the pusher controller. MidoNetAPIDeleter = "midonet.org/deleter" )
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 ¶
ClusterRouterID is the ID of the cluster router for this deployment.
func DefaultTunnelZoneID ¶
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 ¶
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 ¶
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 ¶
ServicesChainID is the ID of MidoNet Chain which contains the Rules for each services.
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 ¶
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.
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.