diff --git a/harmony/src/modules/node_health/mod.rs b/harmony/src/modules/node_health/mod.rs index 5a6bcce..6d660cd 100644 --- a/harmony/src/modules/node_health/mod.rs +++ b/harmony/src/modules/node_health/mod.rs @@ -1,5 +1,6 @@ use async_trait::async_trait; use harmony_types::id::Id; +use k8s_openapi::api::scheduling::v1::PriorityClass; use k8s_openapi::api::{ apps::v1::{DaemonSet, DaemonSetSpec}, core::v1::{ @@ -144,6 +145,19 @@ impl Interpret for NodeHealthInterpret { }, }; + // PriorityClass + let priority_class_name = "node-healthcheck-critical".to_string(); + let priority_class = PriorityClass { + metadata: ObjectMeta { + name: Some(priority_class_name.clone()), + ..ObjectMeta::default() + }, + value: 1000000000, + global_default: Some(false), + preemption_policy: Some("PreemptLowerPriority".to_string()), + description: Some("Highest priority for node health check daemonset - can preempt lower priority pods".to_string()), + }; + // DaemonSet let mut daemonset_labels = BTreeMap::new(); daemonset_labels.insert("app".to_string(), "node-healthcheck".to_string()); @@ -168,6 +182,7 @@ impl Interpret for NodeHealthInterpret { spec: Some(PodSpec { service_account_name: Some(service_account_name.clone()), host_network: Some(true), + priority_class_name: Some(priority_class_name), tolerations: Some(vec![Toleration { operator: Some("Exists".to_string()), ..Toleration::default() @@ -182,6 +197,7 @@ impl Interpret for NodeHealthInterpret { name: "NODE_NAME".to_string(), value_from: Some(EnvVarSource { field_ref: Some(ObjectFieldSelector { + api_version: Some("v1".to_string()), field_path: "spec.nodeName".to_string(), ..ObjectFieldSelector::default() }), @@ -233,6 +249,9 @@ impl Interpret for NodeHealthInterpret { K8sResourceScore::single(cluster_role_binding, None) .interpret(inventory, topology) .await?; + K8sResourceScore::single(priority_class, None) + .interpret(inventory, topology) + .await?; K8sResourceScore::single(daemon_set, Some(namespace_name.clone())) .interpret(inventory, topology) .await?; diff --git a/opnsense-config-xml/src/data/opnsense.rs b/opnsense-config-xml/src/data/opnsense.rs index 0cd0bee..172be92 100644 --- a/opnsense-config-xml/src/data/opnsense.rs +++ b/opnsense-config-xml/src/data/opnsense.rs @@ -344,7 +344,7 @@ pub struct StaticMap { pub mac: String, pub ipaddr: String, pub cid: Option, - pub hostname: String, + pub hostname: Option, pub descr: Option, pub winsserver: MaybeString, pub dnsserver: MaybeString, @@ -383,24 +383,24 @@ pub struct Outbound { #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] pub struct NatRule { - pub protocol: String, - pub interface: String, - pub category: MaybeString, - pub ipprotocol: String, - pub descr: MaybeString, - pub tag: MaybeString, + pub protocol: Option, + pub interface: Option, + pub category: Option, + pub ipprotocol: Option, + pub descr: Option, + pub tag: Option, pub tagged: Option, - pub poolopts: PoolOpts, + pub poolopts: Option, #[yaserde(rename = "associated-rule-id")] pub associated_rule_id: Option, pub disabled: Option, - pub target: String, + pub target: Option, #[yaserde(rename = "local-port")] - pub local_port: i32, - pub source: Source, - pub destination: Destination, - pub updated: Updated, - pub created: Created, + pub local_port: Option, + pub source: Option, + pub destination: Option, + pub updated: Option, + pub created: Option, } #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] @@ -1545,7 +1545,7 @@ pub struct Vlans { #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] pub struct Bridges { - pub bridged: Option, + pub bridged: Option, } #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] diff --git a/opnsense-config/src/modules/dhcp_legacy.rs b/opnsense-config/src/modules/dhcp_legacy.rs index b644073..b705fc1 100644 --- a/opnsense-config/src/modules/dhcp_legacy.rs +++ b/opnsense-config/src/modules/dhcp_legacy.rs @@ -48,7 +48,7 @@ impl<'a> DhcpConfigLegacyISC<'a> { hostname: &str, ) -> Result<(), DhcpError> { let mac = mac.to_string(); - let hostname = hostname.to_string(); + let hostname = Some(hostname.to_string()); let lan_dhcpd = self.get_lan_dhcpd(); let existing_mappings: &mut Vec = &mut lan_dhcpd.staticmaps; @@ -121,7 +121,7 @@ impl<'a> DhcpConfigLegacyISC<'a> { .map(|entry| StaticMap { mac: entry["mac"].as_str().unwrap_or_default().to_string(), ipaddr: entry["ipaddr"].as_str().unwrap_or_default().to_string(), - hostname: entry["hostname"].as_str().unwrap_or_default().to_string(), + hostname: Some(entry["hostname"].as_str().unwrap_or_default().to_string()), descr: entry["descr"].as_str().map(MaybeString::from), ..Default::default() }) diff --git a/opnsense-config/src/modules/dnsmasq.rs b/opnsense-config/src/modules/dnsmasq.rs index dff4de1..7343519 100644 --- a/opnsense-config/src/modules/dnsmasq.rs +++ b/opnsense-config/src/modules/dnsmasq.rs @@ -213,7 +213,7 @@ impl<'a> DhcpConfigDnsMasq<'a> { .map(|entry| StaticMap { mac: entry["mac"].as_str().unwrap_or_default().to_string(), ipaddr: entry["ipaddr"].as_str().unwrap_or_default().to_string(), - hostname: entry["hostname"].as_str().unwrap_or_default().to_string(), + hostname: Some(entry["hostname"].as_str().unwrap_or_default().to_string()), descr: entry["descr"].as_str().map(MaybeString::from), ..Default::default() })