Documentation
¶
Index ¶
- Constants
- Variables
- func HandleRateLimitExceededError(err error, obj runtime.Object)
- func IsRateLimitExceeded(obj runtime.Object) bool
- func SetRateLimit()
- func TimeOfNextPossibleAPICall() time.Time
- func WatchAction(ctx context.Context, ac HCloudActionClient, a *hcloud.Action) error
- type AllServersCache
- type CertificateOps
- func (co *CertificateOps) CreateManagedCertificate(ctx context.Context, name string, domains []string, labels map[string]string) error
- func (co *CertificateOps) GetCertificateByLabel(ctx context.Context, label string) (*hcloud.Certificate, error)
- func (co *CertificateOps) GetCertificateByNameOrID(ctx context.Context, idOrName string) (*hcloud.Certificate, error)
- type HCloudActionClient
- type HCloudCertificateClient
- type HCloudLoadBalancerClient
- type HCloudNetworkClient
- type LoadBalancerDefaults
- type LoadBalancerOps
- func (l *LoadBalancerOps) Create(ctx context.Context, lbName string, svc *corev1.Service) (*hcloud.LoadBalancer, error)
- func (l *LoadBalancerOps) Delete(ctx context.Context, lb *hcloud.LoadBalancer) error
- func (l *LoadBalancerOps) GetByID(ctx context.Context, id int64) (*hcloud.LoadBalancer, error)
- func (l *LoadBalancerOps) GetByK8SServiceUID(ctx context.Context, svc *corev1.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 *corev1.Service) (bool, error)
- func (l *LoadBalancerOps) ReconcileHCLBServices(ctx context.Context, lb *hcloud.LoadBalancer, svc *corev1.Service) (bool, error)
- func (l *LoadBalancerOps) ReconcileHCLBTargets(ctx context.Context, lb *hcloud.LoadBalancer, svc *corev1.Service, ...) (bool, error)
- type LoadBalancerOpsFixture
- func (fx *LoadBalancerOpsFixture) AssertExpectations()
- func (fx *LoadBalancerOpsFixture) MockAddIPTarget(lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddIPTargetOpts, err error) *hcloud.Action
- func (fx *LoadBalancerOpsFixture) MockAddServerTarget(lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddServerTargetOpts, ...) *hcloud.Action
- func (fx *LoadBalancerOpsFixture) MockAddService(opts hcloud.LoadBalancerAddServiceOpts, lb *hcloud.LoadBalancer, err error) *hcloud.Action
- func (fx *LoadBalancerOpsFixture) MockCreate(opts hcloud.LoadBalancerCreateOpts, lb *hcloud.LoadBalancer, err error) *hcloud.Action
- func (fx *LoadBalancerOpsFixture) MockDeleteService(lb *hcloud.LoadBalancer, port int, err error) *hcloud.Action
- func (fx *LoadBalancerOpsFixture) MockGetByID(lb *hcloud.LoadBalancer, err error)
- func (fx *LoadBalancerOpsFixture) MockListRobotServers(serverList []models.Server, err error)
- func (fx *LoadBalancerOpsFixture) MockRemoveIPTarget(lb *hcloud.LoadBalancer, ip net.IP, err error) *hcloud.Action
- func (fx *LoadBalancerOpsFixture) MockRemoveServerTarget(lb *hcloud.LoadBalancer, s *hcloud.Server, err error) *hcloud.Action
- func (fx *LoadBalancerOpsFixture) MockUpdateService(opts hcloud.LoadBalancerUpdateServiceOpts, lb *hcloud.LoadBalancer, ...) *hcloud.Action
- func (fx *LoadBalancerOpsFixture) MockWatchProgress(a *hcloud.Action, err error)
- type MockLoadBalancerOps
- func (m *MockLoadBalancerOps) Create(ctx context.Context, lbName string, service *corev1.Service) (*hcloud.LoadBalancer, error)
- func (m *MockLoadBalancerOps) Delete(ctx context.Context, lb *hcloud.LoadBalancer) error
- func (m *MockLoadBalancerOps) GetByID(ctx context.Context, id int64) (*hcloud.LoadBalancer, error)
- func (m *MockLoadBalancerOps) GetByK8SServiceUID(ctx context.Context, svc *corev1.Service) (*hcloud.LoadBalancer, error)
- func (m *MockLoadBalancerOps) GetByName(ctx context.Context, name string) (*hcloud.LoadBalancer, error)
- func (m *MockLoadBalancerOps) ReconcileHCLB(ctx context.Context, lb *hcloud.LoadBalancer, svc *corev1.Service) (bool, error)
- func (m *MockLoadBalancerOps) ReconcileHCLBServices(ctx context.Context, lb *hcloud.LoadBalancer, svc *corev1.Service) (bool, error)
- func (m *MockLoadBalancerOps) ReconcileHCLBTargets(ctx context.Context, lb *hcloud.LoadBalancer, svc *corev1.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 ( // 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") // ErrAlreadyExists signals that the resource creation failed, because the // resource already exists. ErrAlreadyExists = errors.New("already exists") )
Functions ¶
func IsRateLimitExceeded ¶
func SetRateLimit ¶
func SetRateLimit()
func WatchAction ¶
Types ¶
type AllServersCache ¶
type AllServersCache struct { LoadFunc func(context.Context) ([]*hcloud.Server, error) LoadTimeout time.Duration MaxAge time.Duration // If set, only IPs in this network will be considered for [ByPrivateIP] Network *hcloud.Network // 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.
func (*AllServersCache) InvalidateCache ¶
func (c *AllServersCache) InvalidateCache()
InvalidateCache invalidates the cache so that on the next cache call the cache gets refreshed.
type CertificateOps ¶
type CertificateOps struct {
CertClient HCloudCertificateClient
}
CertificateOps implements all operations regarding Hetzner Cloud Certificates.
func (*CertificateOps) CreateManagedCertificate ¶
func (co *CertificateOps) CreateManagedCertificate( ctx context.Context, name string, domains []string, labels map[string]string, ) error
CreateManagedCertificate creates a managed certificate for domains labeled with label.
CreateManagedCertificate returns a wrapped ErrAlreadyExists if the certificate already exists.
func (*CertificateOps) GetCertificateByLabel ¶
func (co *CertificateOps) GetCertificateByLabel(ctx context.Context, label string) (*hcloud.Certificate, error)
GetCertificateByLabel obtains a single certificate by the passed label.
If the label matches more than one certificate a wrapped ErrNonUniqueResult is returned. If no certificate could be found a wrapped ErrNotFound is returned.
func (*CertificateOps) GetCertificateByNameOrID ¶
func (co *CertificateOps) GetCertificateByNameOrID(ctx context.Context, idOrName string) (*hcloud.Certificate, error)
GetCertificateByNameOrID obtains a certificate from the Hetzner Cloud backend using its ID or Name.
If a certificate could not be found the returned error wraps ErrNotFound.
type HCloudActionClient ¶
type HCloudCertificateClient ¶
type HCloudCertificateClient interface { AllWithOpts(context.Context, hcloud.CertificateListOpts) ([]*hcloud.Certificate, error) Get(ctx context.Context, idOrName string) (*hcloud.Certificate, *hcloud.Response, error) CreateCertificate( ctx context.Context, opts hcloud.CertificateCreateOpts, ) (hcloud.CertificateCreateResult, *hcloud.Response, error) }
HCloudCertificateClient defines the hcloud-go function related to certificate management.
type HCloudLoadBalancerClient ¶
type HCloudLoadBalancerClient interface { GetByID(ctx context.Context, id int64) (*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) ChangeDNSPtr(ctx context.Context, lb *hcloud.LoadBalancer, ip string, ptr *string) (*hcloud.Action, *hcloud.Response, error) AddServerTarget(ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddServerTargetOpts) (*hcloud.Action, *hcloud.Response, error) RemoveServerTarget(ctx context.Context, lb *hcloud.LoadBalancer, server *hcloud.Server) (*hcloud.Action, *hcloud.Response, error) AddIPTarget(ctx context.Context, lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddIPTargetOpts) (*hcloud.Action, *hcloud.Response, error) RemoveIPTarget(ctx context.Context, lb *hcloud.LoadBalancer, server 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 ¶
type LoadBalancerDefaults struct { Location string NetworkZone string UsePrivateIP bool DisableIPv6 bool }
LoadBalancerDefaults stores cluster-wide default values for load balancers.
type LoadBalancerOps ¶
type LoadBalancerOps struct { LBClient HCloudLoadBalancerClient ActionClient HCloudActionClient NetworkClient HCloudNetworkClient RobotClient client.Client CertOps *CertificateOps RetryDelay time.Duration NetworkID int64 Recorder record.EventRecorder Defaults LoadBalancerDefaults }
LoadBalancerOps implements all operations regarding Hetzner Cloud Load Balancers.
func (*LoadBalancerOps) Create ¶
func (l *LoadBalancerOps) Create( ctx context.Context, lbName string, svc *corev1.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 int64) (*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 *corev1.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 *corev1.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 *corev1.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 *corev1.Service, nodes []*corev1.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.
type LoadBalancerOpsFixture ¶
type LoadBalancerOpsFixture struct { Name string Ctx context.Context LBClient *mocks.LoadBalancerClient CertClient *mocks.CertificateClient ActionClient *mocks.ActionClient NetworkClient *mocks.NetworkClient RobotClient *mocks.RobotClient LBOps *LoadBalancerOps T *testing.T }
func NewLoadBalancerOpsFixture ¶
func NewLoadBalancerOpsFixture(t *testing.T) *LoadBalancerOpsFixture
func (*LoadBalancerOpsFixture) AssertExpectations ¶
func (fx *LoadBalancerOpsFixture) AssertExpectations()
func (*LoadBalancerOpsFixture) MockAddIPTarget ¶
func (fx *LoadBalancerOpsFixture) MockAddIPTarget( lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddIPTargetOpts, err error, ) *hcloud.Action
func (*LoadBalancerOpsFixture) MockAddServerTarget ¶
func (fx *LoadBalancerOpsFixture) MockAddServerTarget( lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddServerTargetOpts, err error, ) *hcloud.Action
func (*LoadBalancerOpsFixture) MockAddService ¶
func (fx *LoadBalancerOpsFixture) MockAddService( opts hcloud.LoadBalancerAddServiceOpts, lb *hcloud.LoadBalancer, err error, ) *hcloud.Action
func (*LoadBalancerOpsFixture) MockCreate ¶
func (fx *LoadBalancerOpsFixture) MockCreate( opts hcloud.LoadBalancerCreateOpts, lb *hcloud.LoadBalancer, err error, ) *hcloud.Action
func (*LoadBalancerOpsFixture) MockDeleteService ¶
func (fx *LoadBalancerOpsFixture) MockDeleteService(lb *hcloud.LoadBalancer, port int, err error) *hcloud.Action
func (*LoadBalancerOpsFixture) MockGetByID ¶
func (fx *LoadBalancerOpsFixture) MockGetByID(lb *hcloud.LoadBalancer, err error)
func (*LoadBalancerOpsFixture) MockListRobotServers ¶
func (fx *LoadBalancerOpsFixture) MockListRobotServers( serverList []models.Server, err error, )
func (*LoadBalancerOpsFixture) MockRemoveIPTarget ¶
func (fx *LoadBalancerOpsFixture) MockRemoveIPTarget( lb *hcloud.LoadBalancer, ip net.IP, err error, ) *hcloud.Action
func (*LoadBalancerOpsFixture) MockRemoveServerTarget ¶
func (fx *LoadBalancerOpsFixture) MockRemoveServerTarget( lb *hcloud.LoadBalancer, s *hcloud.Server, err error, ) *hcloud.Action
func (*LoadBalancerOpsFixture) MockUpdateService ¶
func (fx *LoadBalancerOpsFixture) MockUpdateService( opts hcloud.LoadBalancerUpdateServiceOpts, lb *hcloud.LoadBalancer, listenPort int, err error, ) *hcloud.Action
func (*LoadBalancerOpsFixture) MockWatchProgress ¶
func (fx *LoadBalancerOpsFixture) MockWatchProgress(a *hcloud.Action, err error)
type MockLoadBalancerOps ¶
func (*MockLoadBalancerOps) Create ¶
func (m *MockLoadBalancerOps) Create( ctx context.Context, lbName string, service *corev1.Service, ) (*hcloud.LoadBalancer, error)
func (*MockLoadBalancerOps) Delete ¶
func (m *MockLoadBalancerOps) Delete(ctx context.Context, lb *hcloud.LoadBalancer) error
func (*MockLoadBalancerOps) GetByID ¶
func (m *MockLoadBalancerOps) GetByID(ctx context.Context, id int64) (*hcloud.LoadBalancer, error)
func (*MockLoadBalancerOps) GetByK8SServiceUID ¶
func (m *MockLoadBalancerOps) GetByK8SServiceUID(ctx context.Context, svc *corev1.Service) (*hcloud.LoadBalancer, error)
func (*MockLoadBalancerOps) GetByName ¶
func (m *MockLoadBalancerOps) GetByName(ctx context.Context, name string) (*hcloud.LoadBalancer, error)
func (*MockLoadBalancerOps) ReconcileHCLB ¶
func (m *MockLoadBalancerOps) ReconcileHCLB( ctx context.Context, lb *hcloud.LoadBalancer, svc *corev1.Service, ) (bool, error)
func (*MockLoadBalancerOps) ReconcileHCLBServices ¶
func (m *MockLoadBalancerOps) ReconcileHCLBServices( ctx context.Context, lb *hcloud.LoadBalancer, svc *corev1.Service, ) (bool, error)