Documentation
¶
Index ¶
- Constants
- func BuildResourceReference(gvk schema.GroupVersionKind, obj metav1.Object) v1alpha1.ResourceReference
- func ForResourceMapDNSEntry(gkv schema.GroupVersionKind) func(context.Context, client.Object) []reconcile.Request
- func GetAnnotatedOwners(obj metav1.Object) []string
- func GetDNSNamesFromAnnotations(annotations map[string]string) (*utils.UniqueStrings, error)
- func GetMergedAnnotation(gvk schema.GroupVersionKind, state state.AnnotationState, obj metav1.Object) map[string]string
- func GetTargetsForIngress(ingress *networkingv1.Ingress) *utils.UniqueStrings
- func GetTargetsForService(svc *corev1.Service, annotations map[string]string) *utils.UniqueStrings
- func HasDNSNamesWildcard(names *utils.UniqueStrings) bool
- func MapDNSAnnotationToSourceRequest(gkv schema.GroupVersionKind) func(context.Context, client.Object) []reconcile.Request
- func MatchesWildcardSingleSubdomain(host, h string) bool
- func NewEventFeedbackWrapper(recorder RecorderWithDeduplication, handler handler.EventHandler, ...) handler.EventHandler
- func RelevantDNSEntryPredicate(entryOwnerData EntryOwnerData) predicate.Predicate
- func RelevantSourceObjectPredicate[SourceObject client.Object](r *SourceReconciler[SourceObject], ...) predicate.Predicate
- func RemoveDNSNamesWildcard(names *utils.UniqueStrings)
- type DNSSpecInput
- func AugmentFromCommonAnnotations(annotations map[string]string, input DNSSpecInput) (*DNSSpecInput, error)
- func GetDNSSpecInputForIngress(state state.AnnotationState, gvk schema.GroupVersionKind, ...) (*DNSSpecInput, error)
- func GetDNSSpecInputForService(state state.AnnotationState, gvk schema.GroupVersionKind, svc *corev1.Service) (*DNSSpecInput, error)
- type EntryOwnerData
- type FetchSourceFunc
- type OwnerData
- func (o OwnerData) AddOwner(obj metav1.Object, clusterID string) bool
- func (o OwnerData) AsAnnotationRef(targetClusterID string) string
- func (o OwnerData) HasOwner(obj metav1.Object, clusterID string) bool
- func (o OwnerData) RemoveOwner(obj metav1.Object, clusterID string) bool
- func (o OwnerData) String() string
- type RecorderWithDeduplication
- type SourceActuator
- type SourceReconciler
- func (r *SourceReconciler[SourceObject]) AddToManager(mgr manager.Manager, controlPlaneCluster cluster.Cluster, ...) error
- func (r *SourceReconciler[SourceObject]) CleanupOrphanOwnedDNSEntries(ctx context.Context) error
- func (r *SourceReconciler[SourceObject]) DoDelete(ctx context.Context, obj client.Object) (reconcile.Result, error)
- func (r *SourceReconciler[SourceObject]) DoReconcile(ctx context.Context, obj client.Object, dnsSpecInput *DNSSpecInput) (reconcile.Result, error)
- func (r *SourceReconciler[SourceObject]) IsOwnedByController(entry *dnsv1alpha1.DNSEntry, owner metav1.Object) bool
- func (r *SourceReconciler[SourceObject]) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)
Constants ¶
const ( // DNSNamesWildcard is the annotation value for 'dns.gardener.cloud/dnsnames' to add all hosts. DNSNamesWildcard = "*" // DNSNamesAll is an annotation value for 'dns.gardener.cloud/dnsnames' to add all hosts (alias of value "*"). DNSNamesAll = "all" )
Variables ¶
This section is empty.
Functions ¶
func BuildResourceReference ¶
func BuildResourceReference(gvk schema.GroupVersionKind, obj metav1.Object) v1alpha1.ResourceReference
BuildResourceReference builds a ResourceReference for the given object.
func ForResourceMapDNSEntry ¶ added in v0.34.0
func ForResourceMapDNSEntry(gkv schema.GroupVersionKind) func(context.Context, client.Object) []reconcile.Request
ForResourceMapDNSEntry returns a function that maps a DNSEntry to its owning resource(s).
func GetAnnotatedOwners ¶
GetAnnotatedOwners returns the list of owner references stored in the annotation `resources.gardener.cloud/owners`.
func GetDNSNamesFromAnnotations ¶ added in v0.36.0
func GetDNSNamesFromAnnotations(annotations map[string]string) (*utils.UniqueStrings, error)
GetDNSNamesFromAnnotations extracts DNS names from the corresponding annotation.
func GetMergedAnnotation ¶
func GetMergedAnnotation(gvk schema.GroupVersionKind, state state.AnnotationState, obj metav1.Object) map[string]string
GetMergedAnnotation gets the merged annotations for the given object.
func GetTargetsForIngress ¶ added in v0.40.0
func GetTargetsForIngress(ingress *networkingv1.Ingress) *utils.UniqueStrings
GetTargetsForIngress extracts the targets for an Ingress resource from its status. It returns the IPs if available, otherwise the hostnames.
func GetTargetsForService ¶ added in v0.40.0
GetTargetsForService extracts the targets for a Service resource from its status. It returns the IPs if available, otherwise the hostnames.
func HasDNSNamesWildcard ¶ added in v0.45.0
func HasDNSNamesWildcard(names *utils.UniqueStrings) bool
HasDNSNamesWildcard checks whether the given set of DNS names contains a wildcard entry (either "*" or "all").
func MapDNSAnnotationToSourceRequest ¶ added in v0.34.0
func MapDNSAnnotationToSourceRequest(gkv schema.GroupVersionKind) func(context.Context, client.Object) []reconcile.Request
MapDNSAnnotationToSourceRequest returns a function mapping a DNSAnnotation to its referenced source object.
func MatchesWildcardSingleSubdomain ¶ added in v0.40.0
MatchesWildcardSingleSubdomain checks whether 'h' is a wildcard pattern (*.X) that matches 'host' as a single-level subdomain. It returns true only if 'h' starts with "*.", and 'host' has exactly one additional label prepended to the base domain of 'h'. Examples:
- host: foo.gardener.cloud, h: *.gardener.cloud -> true
- host: gardener.cloud, h: *.gardener.cloud -> false (host is the base domain itself)
- host: a.b.gardener.cloud, h: *.gardener.cloud -> false (multi-level subdomain)
- host: foo.gardener.cloud, h: docs.gardener.cloud -> false (h is not a wildcard)
- host: example.com, h: *.gardener.cloud -> false (unrelated domain)
func NewEventFeedbackWrapper ¶ added in v0.34.0
func NewEventFeedbackWrapper( recorder RecorderWithDeduplication, handler handler.EventHandler, mapper handler.MapFunc, sourceFetcher FetchSourceFunc, ) handler.EventHandler
NewEventFeedbackWrapper creates a new event feedback wrapper that wraps an existing event handler.
func RelevantDNSEntryPredicate ¶ added in v0.34.0
func RelevantDNSEntryPredicate(entryOwnerData EntryOwnerData) predicate.Predicate
RelevantDNSEntryPredicate returns the predicate to be considered for reconciliation.
func RelevantSourceObjectPredicate ¶ added in v0.34.0
func RelevantSourceObjectPredicate[SourceObject client.Object]( r *SourceReconciler[SourceObject], isRelevant func(r *SourceReconciler[SourceObject], obj SourceObject) bool, ) predicate.Predicate
RelevantSourceObjectPredicate returns the predicate to be considered for reconciliation.
func RemoveDNSNamesWildcard ¶ added in v0.45.0
func RemoveDNSNamesWildcard(names *utils.UniqueStrings)
RemoveDNSNamesWildcard removes wildcard entries (both "*" and "all") from the given set of DNS names.
Types ¶
type DNSSpecInput ¶
type DNSSpecInput struct {
Names *utils.UniqueStrings
TTL *int64
CNameLookupInterval *int64
Targets *utils.UniqueStrings
Text *utils.UniqueStrings
RoutingPolicy *v1alpha1.RoutingPolicy
IPStack string
ResolveTargetsToAddresses *bool
Ignore string
}
DNSSpecInput specifies names, targets, and policies for DNS records.
func AugmentFromCommonAnnotations ¶ added in v0.36.0
func AugmentFromCommonAnnotations(annotations map[string]string, input DNSSpecInput) (*DNSSpecInput, error)
AugmentFromCommonAnnotations augments the given DNSSpecInput with common annotations.
func GetDNSSpecInputForIngress ¶ added in v0.34.0
func GetDNSSpecInputForIngress(state state.AnnotationState, gvk schema.GroupVersionKind, ingress *networkingv1.Ingress) (*DNSSpecInput, error)
GetDNSSpecInputForIngress gets the DNS spec input for an Ingress resource.
func GetDNSSpecInputForService ¶
func GetDNSSpecInputForService(state state.AnnotationState, gvk schema.GroupVersionKind, svc *corev1.Service) (*DNSSpecInput, error)
GetDNSSpecInputForService gets the DNS spec input for a service of type loadbalancer.
type EntryOwnerData ¶
type EntryOwnerData struct {
Config config.SourceControllerConfig
GVK schema.GroupVersionKind
}
EntryOwnerData contains the information about the owner type of DNSEntry.
func (EntryOwnerData) GetOwnerObjectKeys ¶
func (d EntryOwnerData) GetOwnerObjectKeys(obj metav1.Object) []client.ObjectKey
GetOwnerObjectKeys returns the list of owner object keys for the given
func (EntryOwnerData) IsRelevantEntry ¶
func (d EntryOwnerData) IsRelevantEntry(entry *dnsv1alpha1.DNSEntry) bool
IsRelevantEntry checks whether the given DNSEntry has an owner of the given GroupVersionKind. If sameNamespaceAndCluster is true, only the owner references are checked. Otherwise, the annotation `resources.gardener.cloud/owners` is checked.
type FetchSourceFunc ¶ added in v0.34.0
type FetchSourceFunc func(ctx context.Context, request reconcile.Request, entry *v1alpha1.DNSEntry) (client.Object, error)
FetchSourceFunc defines a function type that fetches a Kubernetes object (the source) for a given reconcile.Request. It returns the fetched object and an error if the fetch fails.
type OwnerData ¶
type OwnerData struct {
Object metav1.Object
ClusterID string
GVK schema.GroupVersionKind
}
OwnerData contains the information about an owner object.
func (OwnerData) AddOwner ¶
AddOwner adds an owner reference to the given object. If the owner is from the same cluster and namespace, a proper owner reference is added. Otherwise, the owner reference is stored in an annotation.
func (OwnerData) AsAnnotationRef ¶
AsAnnotationRef returns the owner reference in the format used in the annotation `resources.gardener.cloud/owners`.
func (OwnerData) HasOwner ¶
HasOwner checks whether the given owner is already present in the object's owner references or in the annotation `resources.gardener.cloud/owners`. It returns true if the owner reference or annotation is already present, false otherwise.
func (OwnerData) RemoveOwner ¶
RemoveOwner removes the given owner from the object's owner references or from the annotation `resources.gardener.cloud/owners`. It returns true if an owner reference or annotation was removed, false otherwise.
type RecorderWithDeduplication ¶ added in v0.34.0
type RecorderWithDeduplication interface {
events.EventRecorder
// DedupEventf records an event only if the same event message has not been recorded
// for the given object within the deduplication TTL.
DedupEventf(client client.Object, eventtype, reason, action, messageFmt string, args ...any)
}
RecorderWithDeduplication is an event recorder with deduplication capabilities.
func NewDedupRecorder ¶ added in v0.34.0
func NewDedupRecorder(recorder events.EventRecorder, ttl time.Duration) RecorderWithDeduplication
NewDedupRecorder creates a new RecorderWithDeduplication with the given TTL for deduplication.
type SourceActuator ¶ added in v0.34.0
type SourceActuator[SourceObject client.Object] interface { // NewSourceObject creates a new instance of the source object. NewSourceObject() SourceObject // ReconcileSourceObject reconciles the given source object. ReconcileSourceObject(context.Context, *SourceReconciler[SourceObject], SourceObject) (reconcile.Result, error) // IsRelevantSourceObject checks whether the given source object is relevant for DNS management. IsRelevantSourceObject(*SourceReconciler[SourceObject], SourceObject) bool // ControllerName returns the name of this controller. ControllerName() string // FinalizerLocalName returns the local name of the finalizer. FinalizerLocalName() string // GetGVK returns the GroupVersionKind of the source object. GetGVK() schema.GroupVersionKind // ShouldSetTargetEntryAnnotation indicates whether the target DNSEntry annotation should be set on the source object. ShouldSetTargetEntryAnnotation() bool // OnDelete is called when a source object is deleted. OnDelete(client.ObjectKey) }
SourceActuator is the actuator interface for source reconcilers.
type SourceReconciler ¶ added in v0.34.0
type SourceReconciler[SourceObject client.Object] struct { Client client.Client ControlPlaneClient client.Client Recorder RecorderWithDeduplication GVK schema.GroupVersionKind Config config.SourceControllerConfig FinalizerName string SourceClass string TargetClass string State state.AnnotationState // contains filtered or unexported fields }
SourceReconciler is base for source reconcilers.
func NewSourceReconciler ¶ added in v0.34.0
func NewSourceReconciler[SourceObject client.Object](actuator SourceActuator[SourceObject]) *SourceReconciler[SourceObject]
NewSourceReconciler creates a new SourceReconciler for given actuator.
func (*SourceReconciler[SourceObject]) AddToManager ¶ added in v0.34.0
func (r *SourceReconciler[SourceObject]) AddToManager( mgr manager.Manager, controlPlaneCluster cluster.Cluster, cfg *config.DNSManagerConfiguration, builderHook func(*builder.Builder) *builder.Builder, ) error
AddToManager adds Reconciler to the given cluster.
func (*SourceReconciler[SourceObject]) CleanupOrphanOwnedDNSEntries ¶ added in v0.53.0
func (r *SourceReconciler[SourceObject]) CleanupOrphanOwnedDNSEntries(ctx context.Context) error
CleanupOrphanOwnedDNSEntries performs a one-shot sweep to remove orphan target DNSEntries whose source object no longer exists (e.g. it was deleted while the controller was down, so the delete event was missed). It lists all relevant target DNSEntries once, groups them by their owning source object, and for every distinct source that no longer exists runs the delete path to clean up its orphan entries. Grouping by source means the cost is one List plus one Get per distinct source, rather than per entry.
func (*SourceReconciler[SourceObject]) DoDelete ¶ added in v0.34.0
func (r *SourceReconciler[SourceObject]) DoDelete(ctx context.Context, obj client.Object) (reconcile.Result, error)
DoDelete performs delete reconciliation for given object.
func (*SourceReconciler[SourceObject]) DoReconcile ¶ added in v0.34.0
func (r *SourceReconciler[SourceObject]) DoReconcile(ctx context.Context, obj client.Object, dnsSpecInput *DNSSpecInput) (reconcile.Result, error)
DoReconcile reconciles for given object and dnsSpecInput.
func (*SourceReconciler[SourceObject]) IsOwnedByController ¶ added in v0.34.0
func (r *SourceReconciler[SourceObject]) IsOwnedByController(entry *dnsv1alpha1.DNSEntry, owner metav1.Object) bool
IsOwnedByController checks whether the given DNSEntry is owned by the given owner.