Documentation ¶
Overview ¶
Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
The code in this file is also heavily based on: https://github.com/kubernetes/sample-controller which is Copyright 2017 The Kubernetes Authors under the Apache 2.0 License
Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- Constants
- Variables
- type AgentController
- type CleanupJob
- type ClusterIPLoadBalancerModelGenerator
- type Collector
- type Controller
- type HTTPAgentController
- type L3PortManager
- type LoadBalancerModelGenerator
- type NodePortLoadBalancerModelGenerator
- type PodLoadBalancerModelGenerator
- type PortMapper
- type PortMapperImpl
- func (c *PortMapperImpl) GetModel() map[string]string
- func (c *PortMapperImpl) GetServiceL3Port(id model.ServiceIdentifier) (string, error)
- func (c *PortMapperImpl) GetUsedL3Ports() ([]string, error)
- func (c *PortMapperImpl) MapService(svc *corev1.Service) error
- func (c *PortMapperImpl) SetAvailableL3Ports(portIDs []string) ([]model.ServiceIdentifier, error)
- func (c *PortMapperImpl) UnmapService(id model.ServiceIdentifier) error
- type RemoveCleanupBarrierJob
- type RemoveServiceJob
- type RequeueMode
- type SimplifiedHTTPClient
- type SyncServiceJob
- type UpdateConfigJob
- type Worker
- type WorkerJob
Constants ¶
const ( // SuccessSynced is used as part of the Event 'reason' when a Foo is synced SuccessSynced = "Synced" SuccessTakenOver = "TakenOver" SuccessReleased = "Released" MessageResourceTakenOver = "Service taken over by cah-loadbalancer-controller" MessageResourceReleased = "Service released by cah-loadbalancer-controller" )
const ( AnnotationManaged = "cah-loadbalancer.k8s.cloudandheat.com/managed" AnnotationInboundPort = "cah-loadbalancer.k8s.cloudandheat.com/inbound-port" )
const ( Drop = RequeueMode(0) RequeueHead = RequeueMode(1) RequeueTail = RequeueMode(2) )
const ( EventServiceTakenOver = "TakenOver" EventServiceReleased = "Released" EventServiceMapped = "Mapped" EventServiceRemapped = "Remapped" EventServiceAssigned = "Assigned" EventServiceUnassignedForRemapping = "UnassignedForRemapping" EventServiceUnassignedStale = "UnassignedStale" EventServiceUnmapped = "Unmapped" MessageEventServiceTakenOver = "Service taken over by cah-loadbalancer-controller" MessageEventServiceReleased = "Service released by cah-loadbalancer-controller" MessageEventServiceMapped = "Service mapped to L3 port %q" MessageEventServiceAssigned = "Service was assigned to the external IP address %q" MessageEventServiceUnassignedForRemapping = "Service was unassigned due to upcoming port remapping" MessageEventServiceUnassignedStale = "Cleared stale IP address information" MessageEventServiceUnassignedDrop = "Cleared IP address information because we release control over the Service" MessageEventServiceRemapped = "Service mapping changed from port %q to %q (due to conflict)" MessageEventServiceUnmapped = "Service unmapped" )
Variables ¶
var ( ErrServiceNotMapped = errors.New("Service not mapped") ErrNoSuitablePort = errors.New("No suitable port available") )
var (
ErrCleanupBarrierActive = goerrors.New("Cleanup barrier is in place")
)
var (
ErrInvalidIpAddress = errors.New("the string is not a valid textual representation of an IP address")
)
Functions ¶
This section is empty.
Types ¶
type AgentController ¶
type AgentController interface {
PushConfig(m *model.LoadBalancer) error
}
type CleanupJob ¶
type CleanupJob struct{}
func (*CleanupJob) Run ¶
func (j *CleanupJob) Run(w *Worker) (RequeueMode, error)
func (*CleanupJob) ToString ¶
func (j *CleanupJob) ToString() string
type ClusterIPLoadBalancerModelGenerator ¶
type ClusterIPLoadBalancerModelGenerator struct {
// contains filtered or unexported fields
}
func NewClusterIPLoadBalancerModelGenerator ¶
func NewClusterIPLoadBalancerModelGenerator( l3portmanager L3PortManager, services corelisters.ServiceLister) *ClusterIPLoadBalancerModelGenerator
func (*ClusterIPLoadBalancerModelGenerator) GenerateModel ¶
func (g *ClusterIPLoadBalancerModelGenerator) GenerateModel(portAssignment map[string]string) (*model.LoadBalancer, error)
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
func NewCollector ¶
func NewCollector(portmapper PortMapper) *Collector
func (*Collector) Collect ¶
func (c *Collector) Collect(out chan<- prometheus.Metric)
func (*Collector) Describe ¶
func (c *Collector) Describe(out chan<- *prometheus.Desc)
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is the controller implementation for Foo resources
func NewController ¶
func NewController( kubeclientset kubernetes.Interface, serviceInformer coreinformers.ServiceInformer, nodeInformer coreinformers.NodeInformer, endpointsInformer coreinformers.EndpointsInformer, networkPoliciesInformer networkinginformers.NetworkPolicyInformer, l3portmanager L3PortManager, agentController AgentController, generator LoadBalancerModelGenerator, ) (*Controller, error)
NewController returns a new sample controller
func (*Controller) Run ¶
func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error
Run will set up the event handlers for types we are interested in, as well as syncing informer caches and starting workers. It will block until stopCh is closed, at which point it will shutdown the workqueue and wait for workers to finish processing their current work items.
type HTTPAgentController ¶
type HTTPAgentController struct { AgentURLs []string Client SimplifiedHTTPClient TimeTolerance int }
func NewHTTPAgentController ¶
func NewHTTPAgentController(cfg config.Agents) (*HTTPAgentController, error)
func (*HTTPAgentController) GenerateToken ¶
func (c *HTTPAgentController) GenerateToken(m *model.LoadBalancer) (string, error)
func (*HTTPAgentController) PushConfig ¶
func (c *HTTPAgentController) PushConfig(m *model.LoadBalancer) error
type L3PortManager ¶ added in v0.6.0
type L3PortManager interface { // ProvisionPort creates a new L3 port and returns its id ProvisionPort() (string, error) // CleanUnusedPorts deletes all L3 ports that are currently not used CleanUnusedPorts(usedPorts []string) error // GetAvailablePorts returns all L3 ports that are available GetAvailablePorts() ([]string, error) // GetExternalAddress returns the external address (floating IP) and hostname for a given portID GetExternalAddress(portID string) (string, string, error) // GetInternalAddress returns the internal address (target of the floating IP) for a given portID, GetInternalAddress(portID string) (string, error) // CheckPortExists checks if there exists a port for the given portID CheckPortExists(portID string) (bool, error) }
type LoadBalancerModelGenerator ¶
type LoadBalancerModelGenerator interface {
GenerateModel(portAssignment map[string]string) (*model.LoadBalancer, error)
}
func NewLoadBalancerModelGenerator ¶
func NewLoadBalancerModelGenerator( backendLayer config.BackendLayer, l3portmanager L3PortManager, services corelisters.ServiceLister, nodes corelisters.NodeLister, endpoints corelisters.EndpointsLister, networkpolicies networkinglisters.NetworkPolicyLister, pods corelisters.PodLister) (LoadBalancerModelGenerator, error)
type NodePortLoadBalancerModelGenerator ¶
type NodePortLoadBalancerModelGenerator struct {
// contains filtered or unexported fields
}
func NewNodePortLoadBalancerModelGenerator ¶
func NewNodePortLoadBalancerModelGenerator( l3portmanager L3PortManager, services corelisters.ServiceLister, nodes corelisters.NodeLister) *NodePortLoadBalancerModelGenerator
func (*NodePortLoadBalancerModelGenerator) GenerateModel ¶
func (g *NodePortLoadBalancerModelGenerator) GenerateModel(portAssignment map[string]string) (*model.LoadBalancer, error)
type PodLoadBalancerModelGenerator ¶
type PodLoadBalancerModelGenerator struct {
// contains filtered or unexported fields
}
func NewPodLoadBalancerModelGenerator ¶
func NewPodLoadBalancerModelGenerator( l3portmanager L3PortManager, services corelisters.ServiceLister, endpoints corelisters.EndpointsLister, networkpolicies networkinglisters.NetworkPolicyLister, pods corelisters.PodLister) *PodLoadBalancerModelGenerator
func (*PodLoadBalancerModelGenerator) GenerateModel ¶
func (g *PodLoadBalancerModelGenerator) GenerateModel(portAssignment map[string]string) (*model.LoadBalancer, error)
type PortMapper ¶
type PortMapper interface { // Map the given service to a port // // If required, this will allocate a new port through the backend used for // the port mapper. // // Any errors occuring during port provisioning will be reported back by // this method. If this method reports an error, the service is not mapped. MapService(svc *corev1.Service) error // Remove all allocations of the service from the bookkeeping and release // L3 ports which are not used anymore // // Note that the release of ports can only be observed by polling // GetUsedL3Ports. UnmapService(id model.ServiceIdentifier) error // Return the ID of the port to which the service is mapped // // Returns ErrServiceNotMapped if the service is currently not mapped. GetServiceL3Port(id model.ServiceIdentifier) (string, error) GetModel() map[string]string // Return the list of IDs of the L3 ports which currently have at least one // mapped service. GetUsedL3Ports() ([]string, error) // Set the list with available L3 port IDs. // // Any service which is currently mapped to a port which is not in the list // of IDs passed to this method will be unmapped. The identifiers of the // affected services will be returned in the return value. SetAvailableL3Ports(portIDs []string) ([]model.ServiceIdentifier, error) }
func NewPortMapper ¶
func NewPortMapper(l3manager L3PortManager) (PortMapper, error)
type PortMapperImpl ¶
type PortMapperImpl struct {
// contains filtered or unexported fields
}
func (*PortMapperImpl) GetModel ¶
func (c *PortMapperImpl) GetModel() map[string]string
func (*PortMapperImpl) GetServiceL3Port ¶
func (c *PortMapperImpl) GetServiceL3Port(id model.ServiceIdentifier) (string, error)
func (*PortMapperImpl) GetUsedL3Ports ¶
func (c *PortMapperImpl) GetUsedL3Ports() ([]string, error)
func (*PortMapperImpl) MapService ¶
func (c *PortMapperImpl) MapService(svc *corev1.Service) error
func (*PortMapperImpl) SetAvailableL3Ports ¶
func (c *PortMapperImpl) SetAvailableL3Ports(portIDs []string) ([]model.ServiceIdentifier, error)
SetAvailableL3Ports marks a list of l3 ports as available. All other l3 ports are removed from the l3ports list. All services that belong to other ports are removed from the services list and will be returned.
func (*PortMapperImpl) UnmapService ¶
func (c *PortMapperImpl) UnmapService(id model.ServiceIdentifier) error
type RemoveCleanupBarrierJob ¶
type RemoveCleanupBarrierJob struct{}
func (*RemoveCleanupBarrierJob) Run ¶
func (j *RemoveCleanupBarrierJob) Run(state *Worker) (RequeueMode, error)
func (*RemoveCleanupBarrierJob) ToString ¶
func (j *RemoveCleanupBarrierJob) ToString() string
type RemoveServiceJob ¶
type RemoveServiceJob struct { Service model.ServiceIdentifier Annotations map[string]string }
func (*RemoveServiceJob) Run ¶
func (j *RemoveServiceJob) Run(w *Worker) (RequeueMode, error)
func (*RemoveServiceJob) ToString ¶
func (j *RemoveServiceJob) ToString() string
type RequeueMode ¶
type RequeueMode int
type SimplifiedHTTPClient ¶
type SyncServiceJob ¶
type SyncServiceJob struct {
Service model.ServiceIdentifier
}
func (*SyncServiceJob) Run ¶
func (j *SyncServiceJob) Run(w *Worker) (RequeueMode, error)
func (*SyncServiceJob) ToString ¶
func (j *SyncServiceJob) ToString() string
type UpdateConfigJob ¶
type UpdateConfigJob struct{}
func (*UpdateConfigJob) Run ¶
func (j *UpdateConfigJob) Run(w *Worker) (RequeueMode, error)
func (*UpdateConfigJob) ToString ¶
func (j *UpdateConfigJob) ToString() string
type Worker ¶
type Worker struct { AllowCleanups bool // contains filtered or unexported fields }
func NewWorker ¶
func NewWorker( l3portmanager L3PortManager, portmapper PortMapper, kubeclientset kubernetes.Interface, services corelisters.ServiceLister, generator LoadBalancerModelGenerator, agentController AgentController) *Worker
func (*Worker) EnqueueJob ¶
func (*Worker) RequeueJob ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
Copyright 2020 CLOUD&HEAT Technologies GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |