mirror of
https://github.com/CloudNebulaProject/reddwarf.git
synced 2026-04-10 13:20:40 +00:00
Service networking:
- ClusterIP IPAM allocation on service create/delete via reusable Ipam with_prefix()
- ServiceController watches Pod/Service events + periodic reconcile to track endpoints
- NatManager generates ipnat rdr rules for ClusterIP -> pod IP forwarding
- Embedded DNS server resolves {svc}.{ns}.svc.cluster.local to ClusterIP
- New CLI flags: --service-cidr (default 10.96.0.0/12), --cluster-dns (default 0.0.0.0:10053)
Quick wins:
- ipadm IP assignment: configure_zone_ip() runs ipadm/route inside zone via zlogin after boot
- Node heartbeat zone state reporting: reddwarf.io/zone-count and zone-summary annotations
- bhyve brand support: ZoneBrand::Bhyve, install args, zonecfg device generation, controller integration
189 tests passing, clippy clean.
https://claude.ai/code/session_016QLFjAyYGzMPbBjEGMe75j
40 lines
1.2 KiB
Rust
40 lines
1.2 KiB
Rust
pub mod ipam;
|
|
pub mod nat;
|
|
pub mod types;
|
|
|
|
pub use crate::types::{DirectNicConfig, EtherstubConfig, NetworkMode};
|
|
pub use ipam::{CidrConfig, IpAllocation, Ipam};
|
|
pub use nat::NatManager;
|
|
|
|
/// Generate a VNIC name from pod namespace and name
|
|
pub fn vnic_name_for_pod(namespace: &str, pod_name: &str) -> String {
|
|
// VNIC names have a max length on illumos, so we truncate and hash
|
|
let combined = format!("{}-{}", namespace, pod_name);
|
|
if combined.len() <= 28 {
|
|
format!("vnic_{}", combined.replace('-', "_"))
|
|
} else {
|
|
// Use a simple hash for long names
|
|
let hash = combined
|
|
.bytes()
|
|
.fold(0u32, |acc, b| acc.wrapping_mul(31).wrapping_add(b as u32));
|
|
format!("vnic_{:08x}", hash)
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_vnic_name_short() {
|
|
let name = vnic_name_for_pod("default", "nginx");
|
|
assert_eq!(name, "vnic_default_nginx");
|
|
}
|
|
|
|
#[test]
|
|
fn test_vnic_name_long() {
|
|
let name = vnic_name_for_pod("very-long-namespace-name", "very-long-pod-name-here");
|
|
assert!(name.starts_with("vnic_"));
|
|
assert!(name.len() <= 32);
|
|
}
|
|
}
|