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 the instance index within a cluster (used for scale-down ordering)
85pub const BINDY_INSTANCE_INDEX_ANNOTATION: &str = "bindy.firestoned.io/instance-index";
86
87/// Annotation used to trigger reconciliation (value is timestamp)
88pub const BINDY_RECONCILE_TRIGGER_ANNOTATION: &str = "bindy.firestoned.io/reconcile-trigger";
89
90// ============================================================================
91// Finalizers
92// ============================================================================
93
94/// Finalizer for `Bind9Cluster` resources
95pub const FINALIZER_BIND9_CLUSTER: &str = "bindy.firestoned.io/bind9cluster-finalizer";
96
97/// Finalizer for `Bind9Instance` resources
98pub const FINALIZER_BIND9_INSTANCE: &str = "bindy.firestoned.io/bind9instance-finalizer";
99
100/// Finalizer for `DNSZone` resources
101pub const FINALIZER_DNS_ZONE: &str = "bindy.firestoned.io/dnszone-finalizer";
102
103// ============================================================================
104// Role Values
105// ============================================================================
106
107/// Role value for primary DNS instances
108pub const ROLE_PRIMARY: &str = "primary";
109
110/// Role value for secondary DNS instances
111pub const ROLE_SECONDARY: &str = "secondary";