edge

package
v0.0.0-...-82bd775 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package edge provides an implementation of Kubernetes cloud provider that is suitable for edge deployments.

Currently its only functionality is to manage the NAT port mappings on deployments where a IGD (Internet Gateway Device) with UPnP enabled.

Specifically, it will use UPnP-IGD to create a port mapping for each port of a load balancer service defined in the Kubernetes cluster that have been annotated with the annotation:

midokura.com/load-balancer-type: upnp-igd

For example, the following service:

apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: default
  labels:
    "midokura.com/load-balancer-type": "upnp-igd"
spec:
  selector:
    app: my-app
  ports:
    - protocol: TCP
      port: <external_port>     # External port (WAN port)
      nodePort: <internal_port> # Internal port (LAN port)
      targetPort: 80            # Pod port
      name: http
  type: LoadBalancer

will create the TCP port mapping:

<external_ip>:<external_port> -> <internal_ip>:<internal_port>

The internal port is the service node port and the internal IP is the IP of the first node available (usually non-master node).

Index

Constants

View Source
const (
	// LoadBalancerTypeAnnotation annotates load balancer type
	LoadBalancerTypeAnnotation string = "midokura.com/load-balancer-type"
)
View Source
const (
	// ProviderName is the name of the edge provider
	ProviderName = "edge"
)
View Source
const (
	// UniversalPlugAndPlayInternetGatewayDeviceLoadBalancerType UPnP IGD load balancer type
	UniversalPlugAndPlayInternetGatewayDeviceLoadBalancerType = "upnp-igd"
)

LoadBalancerTypeAnnotation values

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
}

Config is used to read and store information from the cloud configuration file

func ReadConfig

func ReadConfig(config io.Reader) (Config, error)

ReadConfig reads values from environment variables and the cloud.conf, prioritizing cloud-config

type Edge

type Edge struct {
	LoadBalancerInstance *LoadBalancer
}

Edge is an implementation of cloud provider Interface for edge deployments.

func NewEdge

func NewEdge(cfg Config) (*Edge, error)

NewEdge creates a new new instance of the Edge struct from a config struct

func (*Edge) Clusters

func (cloud *Edge) Clusters() (cloudprovider.Clusters, bool)

Clusters returns nil and false, since clusters interface is not supported.

func (*Edge) HasClusterID

func (cloud *Edge) HasClusterID() bool

HasClusterID returns true, as a ClusterID is required and set

func (*Edge) Initialize

func (cloud *Edge) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{})

Initialize provides the cloud with a kubernetes client builder and may spawn goroutines to perform housekeeping or run custom controllers specific to the cloud provider. Any tasks started here should be cleaned up when the stop channel closes.

func (*Edge) Instances

func (cloud *Edge) Instances() (cloudprovider.Instances, bool)

Instances returns nil and false, since instances interface is not supported.

func (*Edge) LoadBalancer

func (cloud *Edge) LoadBalancer() (cloudprovider.LoadBalancer, bool)

LoadBalancer returns a balancer interface, and true since the interface is supported.

func (*Edge) ProviderName

func (cloud *Edge) ProviderName() string

ProviderName returns the cloud provider ID.

func (*Edge) Routes

func (cloud *Edge) Routes() (cloudprovider.Routes, bool)

Routes returns nil and false, since routes interface is not supported.

func (*Edge) Zones

func (cloud *Edge) Zones() (cloudprovider.Zones, bool)

Zones returns nil and false, since zones interface is not supported.

type LoadBalancer

type LoadBalancer struct {
	// contains filtered or unexported fields
}

LoadBalancer store the data for Load Balancer API Edge cloud provider

func NewLoadBalancer

func NewLoadBalancer() (*LoadBalancer, error)

NewLoadBalancer setup internal fields of LoadBalancer

func (*LoadBalancer) EnsureLoadBalancer

func (lb *LoadBalancer) EnsureLoadBalancer(ctx context.Context, clusterName string, service *k8s.Service, nodes []*k8s.Node) (*k8s.LoadBalancerStatus, error)

EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer Implementations must treat the *v1.Service and *v1.Node parameters as read-only and not modify them. Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager

func (*LoadBalancer) EnsureLoadBalancerDeleted

func (lb *LoadBalancer) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *k8s.Service) error

EnsureLoadBalancerDeleted deletes the specified load balancer if it exists, returning nil if the load balancer specified either didn't exist or was successfully deleted. This construction is useful because many cloud providers' load balancers have multiple underlying components, meaning a Get could say that the LB doesn't exist even if some part of it is still laying around. Implementations must treat the *v1.Service parameter as read-only and not modify it. Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager

func (*LoadBalancer) GetLoadBalancer

func (lb *LoadBalancer) GetLoadBalancer(ctx context.Context, clusterName string, service *k8s.Service) (status *k8s.LoadBalancerStatus, exists bool, err error)

GetLoadBalancer returns whether the specified load balancer exists, and if so, what its status is. Implementations must treat the *v1.Service parameter as read-only and not modify it. Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager

func (*LoadBalancer) GetLoadBalancerName

func (lb *LoadBalancer) GetLoadBalancerName(ctx context.Context, clusterName string, service *k8s.Service) string

GetLoadBalancerName returns the name of the load balancer. Implementations must treat the *v1.Service parameter as read-only and not modify it.

func (*LoadBalancer) UpdateLoadBalancer

func (lb *LoadBalancer) UpdateLoadBalancer(ctx context.Context, clusterName string, service *k8s.Service, nodes []*k8s.Node) error

UpdateLoadBalancer updates hosts under the specified load balancer. Implementations must treat the *v1.Service and *v1.Node parameters as read-only and not modify them. Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager

Jump to

Keyboard shortcuts

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