annotation

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSet = errors.New("not set")

ErrNotSet signals that an annotation was not set.

Functions

func AssertServiceAnnotated

func AssertServiceAnnotated(t *testing.T, svc *corev1.Service, expected map[Name]interface{})

AssertServiceAnnotated asserts that svc has been annotated with all annotations in expected.

func LBToService

func LBToService(svc *corev1.Service, lb *hcloud.LoadBalancer) error

LBToService sets the relevant annotations on svc to their respective values from lb.

Types

type Name

type Name string

Name defines the name of a K8S annotation.

const (
	// LBID is the ID assigned to the Hetzner Cloud Load Balancer by the
	// backend. Read-only.
	LBID Name = "load-balancer.hetzner.cloud/id"

	// LBPublicIPv4 is the public IPv4 address assigned to the Load Balancer by
	// the backend. Read-only.
	LBPublicIPv4 Name = "load-balancer.hetzner.cloud/ipv4"

	// LBPublicIPv4RDNS is the reverse DNS record assigned to the IPv4 address of
	// the Load Balancer.
	LBPublicIPv4RDNS Name = "load-balancer.hetzner.cloud/ipv4-rdns"

	// LBPublicIPv6 is the public IPv6 address assigned to the Load Balancer by
	// the backend. Read-only.
	LBPublicIPv6 Name = "load-balancer.hetzner.cloud/ipv6"

	// LBPublicIPv6RDNS is the reverse DNS record assigned to the IPv6 address of
	// the Load Balancer.
	LBPublicIPv6RDNS Name = "load-balancer.hetzner.cloud/ipv6-rdns"

	// LBIPv6Disabled disables the use of IPv6 for the Load Balancer.
	//
	// Set this annotation if you use external-dns.
	//
	// Default: false.
	LBIPv6Disabled Name = "load-balancer.hetzner.cloud/ipv6-disabled"

	// LBName is the name of the Load Balancer. The name will be visible in
	// the Hetzner Cloud API console.
	LBName Name = "load-balancer.hetzner.cloud/name"

	// LBDisablePublicNetwork disables the public network of the Hetzner Cloud
	// Load Balancer. It will still have a public network assigned, but all
	// traffic is routed over the private network.
	LBDisablePublicNetwork Name = "load-balancer.hetzner.cloud/disable-public-network"

	// LBDisablePrivateIngress disables the use of the private network for
	// ingress.
	LBDisablePrivateIngress Name = "load-balancer.hetzner.cloud/disable-private-ingress"

	// LBUsePrivateIP configures the Load Balancer to use the private IP for
	// Load Balancer server targets.
	LBUsePrivateIP Name = "load-balancer.hetzner.cloud/use-private-ip"

	// LBPrivateIPv4 specifies the IPv4 address to assign to the load balancer in the
	// private network that it's attached to.
	LBPrivateIPv4 Name = "load-balancer.hetzner.cloud/private-ipv4"

	// LBHostname specifies the hostname of the Load Balancer. This will be
	// used as ingress address instead of the Load Balancer IP addresses if
	// specified.
	LBHostname Name = "load-balancer.hetzner.cloud/hostname"

	// LBSvcProtocol specifies the protocol of the service. Default: tcp, Possible
	// values: tcp, http, https
	LBSvcProtocol Name = "load-balancer.hetzner.cloud/protocol"

	// LBAlgorithmType specifies the algorithm type of the Load Balancer.
	//
	// Possible values: round_robin, least_connections
	//
	// Default: round_robin.
	LBAlgorithmType Name = "load-balancer.hetzner.cloud/algorithm-type"

	// LBType specifies the type of the Load Balancer.
	//
	// Default: lb11.
	LBType Name = "load-balancer.hetzner.cloud/type"

	// LBLocation specifies the location where the Load Balancer will be
	// created in.
	//
	// Changing the location to a different value after the load balancer was
	// created has no effect. In order to move a load balancer to a different
	// location it is necessary to delete and re-create it. Note, that this
	// will lead to the load balancer getting new public IPs assigned.
	//
	// Mutually exclusive with LBNetworkZone.
	LBLocation Name = "load-balancer.hetzner.cloud/location"

	// LBNetworkZone specifies the network zone where the Load Balancer will be
	// created in.
	//
	// Changing the network zone to a different value after the load balancer
	// was created has no effect.  In order to move a load balancer to a
	// different network zone it is necessary to delete and re-create it. Note,
	// that this will lead to the load balancer getting new public IPs
	// assigned.
	//
	// Mutually exclusive with LBLocation.
	LBNetworkZone Name = "load-balancer.hetzner.cloud/network-zone"

	// LBNodeSelector can be set to restrict which Nodes are added as targets to the
	// Load Balancer. It accepts a Kubernetes label selector string, using either the
	// set-based or equality-based formats.
	//
	// If the selector can not be parsed, the targets in the Load Balancer are not
	// updated and an Event is created with the error message.
	//
	// Format: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
	LBNodeSelector Name = "load-balancer.hetzner.cloud/node-selector"

	// LBSvcProxyProtocol specifies if the Load Balancer services should
	// use the proxy protocol.
	//
	// Default: false.
	LBSvcProxyProtocol Name = "load-balancer.hetzner.cloud/uses-proxyprotocol"

	// LBSvcHTTPCookieName specifies the cookie name when using  HTTP or HTTPS
	// as protocol.
	LBSvcHTTPCookieName Name = "load-balancer.hetzner.cloud/http-cookie-name"

	// LBSvcHTTPCookieLifetime specifies the lifetime of the HTTP cookie.
	LBSvcHTTPCookieLifetime Name = "load-balancer.hetzner.cloud/http-cookie-lifetime"

	// LBSvcHTTPCertificateType defines the type of certificate the Load
	// Balancer should use.
	//
	// Possible values are "uploaded" and "managed".
	//
	// If not set LBSvcHTTPCertificateType defaults to "uploaded".
	// LBSvcHTTPManagedCertificateDomains is ignored in this case.
	//
	// HTTPS only.
	LBSvcHTTPCertificateType Name = "load-balancer.hetzner.cloud/certificate-type"

	// LBSvcHTTPCertificates a comma separated list of IDs or Names of
	// Certificates assigned to the service.
	//
	// HTTPS only.
	LBSvcHTTPCertificates Name = "load-balancer.hetzner.cloud/http-certificates"

	// LBSvcHTTPManagedCertificateName contains the names of the managed
	// certificate to create by the Cloud Controller manager. Ignored if
	// LBSvcHTTPCertificateType is missing or set to "uploaded". Optional.
	LBSvcHTTPManagedCertificateName Name = "load-balancer.hetzner.cloud/http-managed-certificate-name"

	// LBSvcHTTPManagedCertificateUseACMEStaging tells the cloud controller manager to create
	// the certificate using Let's Encrypt staging.
	//
	// This annotation is exclusively for Hetzner internal testing purposes.
	// Users should not use this annotation. There is no guarantee that it
	// remains or continues to function as it currently functions.
	LBSvcHTTPManagedCertificateUseACMEStaging Name = "load-balancer.hetzner.cloud/http-managed-certificate-acme-staging"

	// LBSvcHTTPManagedCertificateDomains contains a coma separated list of the
	// domain names of the managed certificate.
	//
	// All domains are used to create a single managed certificate.
	LBSvcHTTPManagedCertificateDomains Name = "load-balancer.hetzner.cloud/http-managed-certificate-domains"

	// LBSvcRedirectHTTP create a redirect from HTTP to HTTPS. HTTPS only.
	LBSvcRedirectHTTP Name = "load-balancer.hetzner.cloud/http-redirect-http"

	// LBSvcHTTPStickySessions enables the sticky sessions feature of Hetzner
	// Cloud HTTP Load Balancers.
	//
	// Default: false.
	LBSvcHTTPStickySessions Name = "load-balancer.hetzner.cloud/http-sticky-sessions"

	// LBSvcHealthCheckProtocol sets the protocol the health check should be
	// performed over.
	//
	// Possible values: tcp, http, https
	//
	// Default: tcp.
	LBSvcHealthCheckProtocol Name = "load-balancer.hetzner.cloud/health-check-protocol"

	// LBSvcHealthCheckPort specifies the port the health check is be performed
	// on.
	LBSvcHealthCheckPort Name = "load-balancer.hetzner.cloud/health-check-port"

	// LBSvcHealthCheckInterval specifies the interval in which time we perform
	// a health check in seconds.
	LBSvcHealthCheckInterval Name = "load-balancer.hetzner.cloud/health-check-interval"

	// LBSvcHealthCheckTimeout specifies the timeout of a single health check.
	LBSvcHealthCheckTimeout Name = "load-balancer.hetzner.cloud/health-check-timeout"

	// LBSvcHealthCheckRetries specifies the number of time a health check is
	// retried until a target is marked as unhealthy.
	LBSvcHealthCheckRetries Name = "load-balancer.hetzner.cloud/health-check-retries"

	// LBSvcHealthCheckHTTPDomain specifies the domain we try to access when
	// performing the health check.
	LBSvcHealthCheckHTTPDomain Name = "load-balancer.hetzner.cloud/health-check-http-domain"

	// LBSvcHealthCheckHTTPPath specifies the path we try to access when
	// performing the health check.
	LBSvcHealthCheckHTTPPath Name = "load-balancer.hetzner.cloud/health-check-http-path"

	// LBSvcHealthCheckHTTPValidateCertificate specifies whether the health
	// check should validate the SSL certificate that comes from the target
	// nodes.
	LBSvcHealthCheckHTTPValidateCertificate Name = "load-balancer.hetzner.cloud/health-check-http-validate-certificate"

	// LBSvcHealthCheckHTTPStatusCodes is a comma separated list of HTTP status
	// codes which we expect.
	LBSvcHealthCheckHTTPStatusCodes Name = "load-balancer.hetzner.cloud/http-status-codes"
)

func (Name) AnnotateService

func (s Name) AnnotateService(svc *corev1.Service, v interface{}) error

AnnotateService adds the value v as an annotation with s.Name to svc.

AnnotateService returns an error if converting v to a string fails.

func (Name) BoolFromService

func (s Name) BoolFromService(svc *corev1.Service) (bool, error)

BoolFromService retrieves the boolean value belonging to the annotation from svc.

BoolFromService returns an error if the value could not be converted to a boolean, or the annotation was not set. In the case of a missing value, the error wraps ErrNotSet.

func (Name) CertificateTypeFromService added in v1.9.0

func (s Name) CertificateTypeFromService(svc *corev1.Service) (hcloud.CertificateType, error)

CertificateTypeFromService retrieves the hcloud.CertificateType value belonging to the annotation from svc.

CertificateTypeFromService returns an error if the value could not be converted to a hcloud.CertificateType. In the case of a missing value, the error wraps ErrNotSet.

func (Name) CertificatesFromService

func (s Name) CertificatesFromService(svc *corev1.Service) ([]*hcloud.Certificate, error)

CertificatesFromService retrieves the []*hcloud.Certificate value belonging to the annotation from svc.

CertificatesFromService returns an error if the value could not be converted to a []*hcloud.Certificate, or the annotation was not set. In the case of a missing value, the error wraps ErrNotSet.

func (Name) DurationFromService

func (s Name) DurationFromService(svc *corev1.Service) (time.Duration, error)

DurationFromService retrieves the time.Duration value belonging to the annotation from svc.

DurationFromService returns an error if the value could not be converted to a time.Duration, or the annotation was not set. In the case of a missing value, the error wraps ErrNotSet.

func (Name) IPFromService

func (s Name) IPFromService(svc *corev1.Service) (net.IP, error)

IPFromService retrieves the net.IP value belonging to the annotation from svc.

IPFromService returns an error if the value could not be converted to a net.IP, or the annotation was not set. In the case of a missing value, the error wraps ErrNotSet.

func (Name) IntFromService

func (s Name) IntFromService(svc *corev1.Service) (int, error)

IntFromService retrieves the int value belonging to the annotation from svc.

IntFromService returns an error if the value could not be converted to an int, or the annotation was not set. In the case of a missing value, the error wraps ErrNotSet.

func (Name) IntsFromService

func (s Name) IntsFromService(svc *corev1.Service) ([]int, error)

IntsFromService retrieves the []int value belonging to the annotation from svc.

IntsFromService returns an error if the value could not be converted to a []int, or the annotation was not set. In the case of a missing value, the error wraps ErrNotSet.

func (Name) LBAlgorithmTypeFromService

func (s Name) LBAlgorithmTypeFromService(svc *corev1.Service) (hcloud.LoadBalancerAlgorithmType, error)

LBAlgorithmTypeFromService retrieves the hcloud.LoadBalancerAlgorithmType value belonging to the annotation from svc.

LBAlgorithmTypeFromService returns an error if the value could not be converted to a hcloud.LoadBalancerAlgorithmType, or the annotation was not set. In the case of a missing value, the error wraps ErrNotSet.

func (Name) LBSvcProtocolFromService

func (s Name) LBSvcProtocolFromService(svc *corev1.Service) (hcloud.LoadBalancerServiceProtocol, error)

LBSvcProtocolFromService retrieves the hcloud.LoadBalancerServiceProtocol value belonging to the annotation from svc.

LBSvcProtocolFromService returns an error if the value could not be converted to a hcloud.LoadBalancerServiceProtocol, or the annotation was not set. In the case of a missing value, the error wraps ErrNotSet.

func (Name) NetworkZoneFromService

func (s Name) NetworkZoneFromService(svc *corev1.Service) (hcloud.NetworkZone, error)

NetworkZoneFromService retrieves the hcloud.NetworkZone value belonging to the annotation from svc.

NetworkZoneFromService returns ErrNotSet if the annotation was not set.

func (Name) StringFromService

func (s Name) StringFromService(svc *corev1.Service) (string, bool)

StringFromService retrieves the value belonging to the annotation from svc.

If svc has no value for the annotation the second return value is false.

func (Name) StringsFromService

func (s Name) StringsFromService(svc *corev1.Service) ([]string, error)

StringsFromService retrieves the []string value belonging to the annotation from svc.

StringsFromService returns ErrNotSet annotation was not set.

Jump to

Keyboard shortcuts

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