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
- type Config
- type Edge
- func (cloud *Edge) Clusters() (cloudprovider.Clusters, bool)
- func (cloud *Edge) HasClusterID() bool
- func (cloud *Edge) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{})
- func (cloud *Edge) Instances() (cloudprovider.Instances, bool)
- func (cloud *Edge) LoadBalancer() (cloudprovider.LoadBalancer, bool)
- func (cloud *Edge) ProviderName() string
- func (cloud *Edge) Routes() (cloudprovider.Routes, bool)
- func (cloud *Edge) Zones() (cloudprovider.Zones, bool)
- type LoadBalancer
- func (lb *LoadBalancer) EnsureLoadBalancer(ctx context.Context, clusterName string, service *k8s.Service, ...) (*k8s.LoadBalancerStatus, error)
- func (lb *LoadBalancer) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *k8s.Service) error
- func (lb *LoadBalancer) GetLoadBalancer(ctx context.Context, clusterName string, service *k8s.Service) (status *k8s.LoadBalancerStatus, exists bool, err error)
- func (lb *LoadBalancer) GetLoadBalancerName(ctx context.Context, clusterName string, service *k8s.Service) string
- func (lb *LoadBalancer) UpdateLoadBalancer(ctx context.Context, clusterName string, service *k8s.Service, ...) error
Constants ¶
const ( // LoadBalancerTypeAnnotation annotates load balancer type LoadBalancerTypeAnnotation string = "midokura.com/load-balancer-type" )
const (
// ProviderName is the name of the edge provider
ProviderName = "edge"
)
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
type Edge ¶
type Edge struct {
LoadBalancerInstance *LoadBalancer
}
Edge is an implementation of cloud provider Interface for edge deployments.
func (*Edge) Clusters ¶
func (cloud *Edge) Clusters() (cloudprovider.Clusters, bool)
Clusters returns nil and false, since clusters interface is not supported.
func (*Edge) HasClusterID ¶
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 ¶
ProviderName returns the cloud provider ID.
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