bindy/labels.rs
1// Copyright (c) 2025 Erick Bourgeois, firestoned
2// SPDX-License-Identifier: MIT
3
4//! Common label and annotation constants used across all reconcilers.
5//!
6//! This module defines standard Kubernetes labels and Bindy-specific labels/annotations
7//! to ensure consistency across all resources created by the controller.
8
9// ============================================================================
10// Kubernetes Standard Labels
11// https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/
12// ============================================================================
13
14/// Standard label for the component name within the architecture (e.g., "dns-server", "dns-cluster")
15pub const K8S_COMPONENT: &str = "app.kubernetes.io/component";
16
17/// Standard label for the tool being used to manage the operation of an application
18pub const K8S_MANAGED_BY: &str = "app.kubernetes.io/managed-by";
19
20/// Standard label for the name of the application (e.g., "bind9")
21pub const K8S_NAME: &str = "app.kubernetes.io/name";
22
23/// Standard label for a unique name identifying the instance of an application
24pub const K8S_INSTANCE: &str = "app.kubernetes.io/instance";
25
26/// Standard label for the name of a higher-level application this one is part of
27pub const K8S_PART_OF: &str = "app.kubernetes.io/part-of";
28
29// ============================================================================
30// Kubernetes Standard Label Values
31// ============================================================================
32
33/// Value for `app.kubernetes.io/part-of` indicating this resource is part of Bindy
34pub const PART_OF_BINDY: &str = "bindy";
35
36/// Component value for DNS server instances
37pub const COMPONENT_DNS_SERVER: &str = "dns-server";
38
39/// Component value for DNS clusters
40pub const COMPONENT_DNS_CLUSTER: &str = "dns-cluster";
41
42/// Application name for BIND9 instances
43pub const APP_NAME_BIND9: &str = "bind9";
44
45// ============================================================================
46// Kubernetes Standard Label Values - Managed By
47// ============================================================================
48
49/// Value for `app.kubernetes.io/managed-by` when resource is managed by `Bind9Instance` controller
50pub const MANAGED_BY_BIND9_INSTANCE: &str = "Bind9Instance";
51
52/// Value for `app.kubernetes.io/managed-by` when resource is managed by `Bind9Cluster` controller
53pub const MANAGED_BY_BIND9_CLUSTER: &str = "Bind9Cluster";
54
55/// Value for `app.kubernetes.io/managed-by` when resource is managed by `ClusterBind9Provider` controller
56pub const MANAGED_BY_CLUSTER_BIND9_PROVIDER: &str = "ClusterBind9Provider";
57
58// ============================================================================
59// Bindy-Specific Labels
60// ============================================================================
61
62/// Label indicating which controller manages this resource (`Bind9Instance` or `Bind9Cluster`)
63pub const BINDY_MANAGED_BY_LABEL: &str = "bindy.firestoned.io/managed-by";
64
65/// Label indicating which `Bind9Cluster` this resource belongs to
66pub const BINDY_CLUSTER_LABEL: &str = "bindy.firestoned.io/cluster";
67
68/// Label indicating the role of this instance (primary or secondary)
69pub const BINDY_ROLE_LABEL: &str = "bindy.firestoned.io/role";
70
71// ============================================================================
72// Bindy-Specific Annotations
73// ============================================================================
74
75/// Annotation indicating which `Bind9Cluster` a DNS record belongs to
76pub const BINDY_CLUSTER_ANNOTATION: &str = "bindy.firestoned.io/cluster";
77
78/// Annotation indicating which `Bind9Instance` a DNS record is deployed to
79pub const BINDY_INSTANCE_ANNOTATION: &str = "bindy.firestoned.io/instance";
80
81/// Annotation indicating which `DNSZone` a DNS record belongs to
82pub const BINDY_ZONE_ANNOTATION: &str = "bindy.firestoned.io/zone";
83
84/// Annotation indicating which `Bind9Instance` selected this `DNSZone` via label selector
85pub const BINDY_SELECTED_BY_INSTANCE_ANNOTATION: &str = "bindy.firestoned.io/selected-by-instance";
86
87/// Annotation indicating the instance index within a cluster (used for scale-down ordering)
88pub const BINDY_INSTANCE_INDEX_ANNOTATION: &str = "bindy.firestoned.io/instance-index";
89
90/// Annotation used to trigger reconciliation (value is timestamp)
91pub const BINDY_RECONCILE_TRIGGER_ANNOTATION: &str = "bindy.firestoned.io/reconcile-trigger";
92
93// ============================================================================
94// Finalizers
95// ============================================================================
96
97/// Finalizer for `Bind9Cluster` resources
98pub const FINALIZER_BIND9_CLUSTER: &str = "bindy.firestoned.io/bind9cluster-finalizer";
99
100/// Finalizer for `Bind9Instance` resources
101pub const FINALIZER_BIND9_INSTANCE: &str = "bindy.firestoned.io/bind9instance-finalizer";
102
103/// Finalizer for `DNSZone` resources
104pub const FINALIZER_DNS_ZONE: &str = "bindy.firestoned.io/dnszone-finalizer";
105
106/// Finalizer for `ARecord` resources
107pub const FINALIZER_A_RECORD: &str = "bindy.firestoned.io/arecord-finalizer";
108
109/// Finalizer for `AAAARecord` resources
110pub const FINALIZER_AAAA_RECORD: &str = "bindy.firestoned.io/aaaarecord-finalizer";
111
112/// Finalizer for `CNAMERecord` resources
113pub const FINALIZER_CNAME_RECORD: &str = "bindy.firestoned.io/cnamerecord-finalizer";
114
115/// Finalizer for `MXRecord` resources
116pub const FINALIZER_MX_RECORD: &str = "bindy.firestoned.io/mxrecord-finalizer";
117
118/// Finalizer for `NSRecord` resources
119pub const FINALIZER_NS_RECORD: &str = "bindy.firestoned.io/nsrecord-finalizer";
120
121/// Finalizer for `TXTRecord` resources
122pub const FINALIZER_TXT_RECORD: &str = "bindy.firestoned.io/txtrecord-finalizer";
123
124/// Finalizer for `SRVRecord` resources
125pub const FINALIZER_SRV_RECORD: &str = "bindy.firestoned.io/srvrecord-finalizer";
126
127/// Finalizer for `CAARecord` resources
128pub const FINALIZER_CAA_RECORD: &str = "bindy.firestoned.io/caarecord-finalizer";
129
130// ============================================================================
131// Role Values
132// ============================================================================
133
134/// Role value for primary DNS instances
135pub const ROLE_PRIMARY: &str = "primary";
136
137/// Role value for secondary DNS instances
138pub const ROLE_SECONDARY: &str = "secondary";