hcops

package
v1.37.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const LBTypesResponse = `` /* 250-byte string literal not displayed */

LBTypesResponse is served by the fixtures Load Balancer type API. Tests that expect a Load Balancer type to be looked up have to use one of these types.

View Source
const (
	// LabelServiceUID is a label added to the Hetzner Cloud backend to uniquely
	// identify a load balancer managed by Hetzner Cloud Cloud Controller Manager.
	LabelServiceUID = "hcloud-ccm/service-uid"
)

Variables

View Source
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

This section is empty.

Types

type CertificateOps added in v1.9.0

type CertificateOps struct {
	ActionClient hcloud.IActionClient
	CertClient   hcloud.ICertificateClient
}

CertificateOps implements all operations regarding Hetzner Cloud Certificates.

func (*CertificateOps) CreateManagedCertificate added in v1.9.0

func (co *CertificateOps) CreateManagedCertificate(
	ctx context.Context, opts hcloud.CertificateCreateOpts,
) error

CreateManagedCertificate creates the managed certificate described by opts.

CreateManagedCertificate returns a wrapped ErrAlreadyExists if the certificate already exists.

func (*CertificateOps) GetCertificateByLabel added in v1.9.0

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 added in v1.9.0

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 LoadBalancerOps

type LoadBalancerOps struct {
	LBClient      hcloud.ILoadBalancerClient
	ActionClient  hcloud.IActionClient
	NetworkClient hcloud.INetworkClient
	RobotClient   hrobot.RobotClient
	LBTypeCache   *cache.Cache[hcloud.LoadBalancerType]
	CertOps       *CertificateOps
	RetryDelay    time.Duration
	NetworkID     int64
	Cfg           config.HCCMConfiguration
	Recorder      record.EventRecorder
}

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 added in v1.9.0

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 added in v1.9.0

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 added in v1.19.0

func (*LoadBalancerOpsFixture) MockAddServerTarget

func (*LoadBalancerOpsFixture) MockAddService

func (*LoadBalancerOpsFixture) MockCreate

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 added in v1.19.0

func (fx *LoadBalancerOpsFixture) MockListRobotServers(
	serverList []hrobotmodels.Server, err error,
)

func (*LoadBalancerOpsFixture) MockRemoveIPTarget added in v1.19.0

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

type MockLoadBalancerOps

type MockLoadBalancerOps struct {
	mock.Mock
}

func (*MockLoadBalancerOps) Create

func (m *MockLoadBalancerOps) Create(
	ctx context.Context, lbName string, service *corev1.Service,
) (*hcloud.LoadBalancer, error)

func (*MockLoadBalancerOps) Delete added in v1.9.0

func (*MockLoadBalancerOps) GetByID

func (*MockLoadBalancerOps) GetByK8SServiceUID added in v1.9.0

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)

func (*MockLoadBalancerOps) ReconcileHCLBTargets

func (m *MockLoadBalancerOps) ReconcileHCLBTargets(
	ctx context.Context, lb *hcloud.LoadBalancer, svc *corev1.Service, nodes []*corev1.Node,
) (bool, error)

Jump to

Keyboard shortcuts

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