pub fn build_service(
name: &str,
namespace: &str,
instance: &Bind9Instance,
custom_config: Option<&ServiceConfig>,
) -> ServiceExpand description
Builds a Kubernetes Service for exposing BIND9 DNS ports.
Creates a Service exposing:
- TCP port 53 (for zone transfers and large queries)
- UDP port 53 (for standard DNS queries)
- HTTP port 80 (mapped to bindcar API port)
Custom service configuration includes both spec fields and metadata annotations. These are merged with defaults, allowing partial customization while maintaining safe defaults for unspecified fields.
§Arguments
name- Name for the Servicenamespace- Kubernetes namespaceinstance- TheBind9Instancethat owns this Servicecustom_config- Optional customServiceConfigwith spec and annotations to merge with defaults
§Returns
A Kubernetes Service resource ready for creation/update
§Example
use bindy::bind9_resources::build_service;
use bindy::crd::{Bind9Instance, ServiceConfig};
use std::collections::BTreeMap;
let mut annotations = BTreeMap::new();
annotations.insert("metallb.universe.tf/address-pool".to_string(), "my-pool".to_string());
let config = ServiceConfig {
annotations: Some(annotations),
spec: None,
};
let service = build_service("dns-primary", "dns-system", &instance, Some(&config));