Documentation ¶
Index ¶
- Constants
- Variables
- func ProviderIDToServerID(providerID string) (id int, err error)
- func WatchAction(ctx context.Context, ac HCloudActionClient, a *hcloud.Action) error
- type AllServersCache
- type HCloudActionClient
- type HCloudCertificateClient
- type HCloudLoadBalancerClient
- type HCloudNetworkClient
- type LoadBalancerDefaults
- type LoadBalancerOps
- func (l *LoadBalancerOps) Create(ctx context.Context, lbName string, svc *v1.Service) (*hcloud.LoadBalancer, error)
- func (l *LoadBalancerOps) Delete(ctx context.Context, lb *hcloud.LoadBalancer) error
- func (l *LoadBalancerOps) GetByID(ctx context.Context, id int) (*hcloud.LoadBalancer, error)
- func (l *LoadBalancerOps) GetByK8SServiceUID(ctx context.Context, svc *v1.Service) (*hcloud.LoadBalancer, error)
- func (l *LoadBalancerOps) GetByName(ctx context.Context, name string) (*hcloud.LoadBalancer, error)
- func (l *LoadBalancerOps) ReconcileHCLB(ctx context.Context, lb *hcloud.LoadBalancer, svc *v1.Service) (bool, error)
- func (l *LoadBalancerOps) ReconcileHCLBServices(ctx context.Context, lb *hcloud.LoadBalancer, svc *v1.Service) (bool, error)
- func (l *LoadBalancerOps) ReconcileHCLBTargets(ctx context.Context, lb *hcloud.LoadBalancer, svc *v1.Service, ...) (bool, error)
Constants ¶
const LabelServiceUID = "hcloud-ccm/service-uid"
LabelServiceUID is a label added to the Hetzner Cloud backend to uniquely identify a load balancer managed by Hetzner Cloud Cloud Controller Manager.
Variables ¶
var ( ProviderName = "hetzner" NameLabelType = "node.hetzner.com/type" NameCloudNode = "cloud" NameDedicatedNode = "dedicated" TypeLabels = map[string]map[string]string{ "cloud": map[string]string{ "node.hetzner.com/type": "cloud", "instance.hetzner.cloud/provided-by": "cloud", "instance.hetzner.cloud/is-root-server": "false", }, "dedicated": map[string]string{ "node.hetzner.com/type": "dedicated", "instance.hetzner.cloud/provided-by": "robot", "instance.hetzner.cloud/is-root-server": "true", }, } ExcludeServer = &hcloud.Server{ ID: 999999, ServerType: &hcloud.ServerType{Name: "exclude"}, Status: hcloud.ServerStatus("running"), Datacenter: &hcloud.Datacenter{ Location: &hcloud.Location{ Name: "exclude", }, Name: "exclude", }, } )
var ( // ErrNotFound signals that an item was not found by the Hetzner Cloud // backend. ErrNotFound = errors.New("not found") // ErrNonUniqueResult signals that more than one matching item was returned // by the Hetzner Cloud backend was returned where only one item was // expected. ErrNonUniqueResult = errors.New("non-unique result") )
Functions ¶
func ProviderIDToServerID ¶
func WatchAction ¶
Types ¶
type AllServersCache ¶
type AllServersCache struct { LoadFunc func(context.Context) ([]*hcloud.Server, error) LoadTimeout time.Duration MaxAge time.Duration // contains filtered or unexported fields }
AllServersCache caches the result of the LoadFunc and provides random access to servers using select hcloud.Server attributes.
To simplify things the allServersCache reloads all servers on every cache miss, or whenever a timeout expired.
func (*AllServersCache) ByName ¶
func (c *AllServersCache) ByName(name string) (*hcloud.Server, error)
ByName obtains a server from the cache using the servers name.
Note that a pointer to the object stored in the cache is returned. Modifying this object affects the cache and all other code parts holding a reference. Furthermore modifying the returned server is not concurrency safe.
func (*AllServersCache) ByPrivateIP ¶
ByPrivateIP obtains a server from the cache using the IP of one of its private networks.
Note that a pointer to the object stored in the cache is returned. Modifying this object affects the cache and all other code parts holding a reference. Furthermore modifying the returned server is not concurrency safe.
type HCloudActionClient ¶
type HCloudCertificateClient ¶
type HCloudCertificateClient interface {
Get(ctx context.Context, idOrName string) (*hcloud.Certificate, *hcloud.Response, error)
}
HCloudCertificateClient defines the hcloud-go function related to certificate management.
type HCloudLoadBalancerClient ¶
type HCloudLoadBalancerClient interface { GetByID(ctx context.Context, id int) (*hcloud.LoadBalancer, *hcloud.Response, error) GetByName(ctx context.Context, name string) (*hcloud.LoadBalancer, *hcloud.Response, error) Create(ctx context.Context, opts hcloud.LoadBalancerCreateOpts) (hcloud.LoadBalancerCreateResult, *hcloud.Response, error) Update( ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerUpdateOpts, ) (*hcloud.LoadBalancer, *hcloud.Response, error) Delete(ctx context.Context, lb *hcloud.LoadBalancer) (*hcloud.Response, error) AddService( ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddServiceOpts, ) (*hcloud.Action, *hcloud.Response, error) UpdateService( ctx context.Context, lb *hcloud.LoadBalancer, listenPort int, opts hcloud.LoadBalancerUpdateServiceOpts, ) (*hcloud.Action, *hcloud.Response, error) DeleteService( ctx context.Context, lb *hcloud.LoadBalancer, listenPort int, ) (*hcloud.Action, *hcloud.Response, error) ChangeAlgorithm(ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerChangeAlgorithmOpts) (*hcloud.Action, *hcloud.Response, error) ChangeType(ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerChangeTypeOpts) (*hcloud.Action, *hcloud.Response, error) AddServerTarget(ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddServerTargetOpts) (*hcloud.Action, *hcloud.Response, error) AddIPTarget(ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddIPTargetOpts) (*hcloud.Action, *hcloud.Response, error) RemoveServerTarget(ctx context.Context, lb *hcloud.LoadBalancer, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) RemoveIPTarget(ctx context.Context, lb *hcloud.LoadBalancer, ip net.IP) (*hcloud.Action, *hcloud.Response, error) AttachToNetwork(ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAttachToNetworkOpts) (*hcloud.Action, *hcloud.Response, error) DetachFromNetwork(ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerDetachFromNetworkOpts) (*hcloud.Action, *hcloud.Response, error) EnablePublicInterface( ctx context.Context, loadBalancer *hcloud.LoadBalancer, ) (*hcloud.Action, *hcloud.Response, error) DisablePublicInterface( ctx context.Context, loadBalancer *hcloud.LoadBalancer, ) (*hcloud.Action, *hcloud.Response, error) AllWithOpts(ctx context.Context, opts hcloud.LoadBalancerListOpts) ([]*hcloud.LoadBalancer, error) }
HCloudLoadBalancerClient defines the hcloud-go functions required by the Load Balancer operations type.
type HCloudNetworkClient ¶
type LoadBalancerDefaults ¶
LoadBalancerDefaults stores cluster-wide default values for load balancers.
type LoadBalancerOps ¶
type LoadBalancerOps struct { LBClient HCloudLoadBalancerClient ActionClient HCloudActionClient NetworkClient HCloudNetworkClient CertClient HCloudCertificateClient RetryDelay time.Duration NetworkID int Defaults LoadBalancerDefaults }
LoadBalancerOps implements all operations regarding Hetzner Cloud Load Balancers.
func (*LoadBalancerOps) Create ¶
func (l *LoadBalancerOps) Create( ctx context.Context, lbName string, svc *v1.Service, ) (*hcloud.LoadBalancer, error)
Create creates a new Load Balancer using the Hetzner Cloud API.
It adds annotations identifying the HC Load Balancer to svc.
func (*LoadBalancerOps) Delete ¶
func (l *LoadBalancerOps) Delete(ctx context.Context, lb *hcloud.LoadBalancer) error
Delete removes a Hetzner Cloud load balancer from the backend.
func (*LoadBalancerOps) GetByID ¶
func (l *LoadBalancerOps) GetByID(ctx context.Context, id int) (*hcloud.LoadBalancer, error)
GetByID retrieves a Hetzner Cloud Load Balancer by id.
If no Load Balancer with id could be found, a wrapped ErrNotFound is returned.
func (*LoadBalancerOps) GetByK8SServiceUID ¶
func (l *LoadBalancerOps) GetByK8SServiceUID(ctx context.Context, svc *v1.Service) (*hcloud.LoadBalancer, error)
GetByK8SServiceUID tries to find a Load Balancer by its Kubernetes service UID.
If no Load Balancer could be found ErrNotFound is returned. Likewise, ErrNonUniqueResult is returned if more than one matching Load Balancer is found.
func (*LoadBalancerOps) GetByName ¶
func (l *LoadBalancerOps) GetByName(ctx context.Context, name string) (*hcloud.LoadBalancer, error)
GetByName retrieves a Hetzner Cloud Load Balancer by name.
If no Load Balancer with name could be found, a wrapped ErrNotFound is returned.
func (*LoadBalancerOps) ReconcileHCLB ¶
func (l *LoadBalancerOps) ReconcileHCLB(ctx context.Context, lb *hcloud.LoadBalancer, svc *v1.Service) (bool, error)
ReconcileHCLB configures the Hetzner Cloud Load Balancer to match what is defined for the K8S Load Balancer svc.
func (*LoadBalancerOps) ReconcileHCLBServices ¶
func (l *LoadBalancerOps) ReconcileHCLBServices( ctx context.Context, lb *hcloud.LoadBalancer, svc *v1.Service, ) (bool, error)
ReconcileHCLBServices synchronizes services exposed by the Hetzner Cloud Load Balancer with the kubernetes cluster.
func (*LoadBalancerOps) ReconcileHCLBTargets ¶
func (l *LoadBalancerOps) ReconcileHCLBTargets( ctx context.Context, lb *hcloud.LoadBalancer, svc *v1.Service, nodes []*v1.Node, ) (bool, error)
ReconcileHCLBTargets adds or removes target nodes from the Hetzner Cloud Load Balancer when nodes are added or removed to the K8S cluster.