feat: add priorityClass to node_health daemonset #249

Merged
stremblay merged 2 commits from feat/health_endpoint_priority_class into master 2026-03-14 18:53:32 +00:00
4 changed files with 37 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
use async_trait::async_trait; use async_trait::async_trait;
use harmony_types::id::Id; use harmony_types::id::Id;
use k8s_openapi::api::scheduling::v1::PriorityClass;
use k8s_openapi::api::{ use k8s_openapi::api::{
apps::v1::{DaemonSet, DaemonSetSpec}, apps::v1::{DaemonSet, DaemonSetSpec},
core::v1::{ core::v1::{
@@ -144,6 +145,19 @@ impl<T: Topology + K8sclient> Interpret<T> 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 // DaemonSet
let mut daemonset_labels = BTreeMap::new(); let mut daemonset_labels = BTreeMap::new();
daemonset_labels.insert("app".to_string(), "node-healthcheck".to_string()); daemonset_labels.insert("app".to_string(), "node-healthcheck".to_string());
@@ -168,6 +182,7 @@ impl<T: Topology + K8sclient> Interpret<T> for NodeHealthInterpret {
spec: Some(PodSpec { spec: Some(PodSpec {
service_account_name: Some(service_account_name.clone()), service_account_name: Some(service_account_name.clone()),
host_network: Some(true), host_network: Some(true),
priority_class_name: Some(priority_class_name),
tolerations: Some(vec![Toleration { tolerations: Some(vec![Toleration {
operator: Some("Exists".to_string()), operator: Some("Exists".to_string()),
..Toleration::default() ..Toleration::default()
@@ -182,6 +197,7 @@ impl<T: Topology + K8sclient> Interpret<T> for NodeHealthInterpret {
name: "NODE_NAME".to_string(), name: "NODE_NAME".to_string(),
value_from: Some(EnvVarSource { value_from: Some(EnvVarSource {
field_ref: Some(ObjectFieldSelector { field_ref: Some(ObjectFieldSelector {
api_version: Some("v1".to_string()),
field_path: "spec.nodeName".to_string(), field_path: "spec.nodeName".to_string(),
..ObjectFieldSelector::default() ..ObjectFieldSelector::default()
}), }),
@@ -233,6 +249,9 @@ impl<T: Topology + K8sclient> Interpret<T> for NodeHealthInterpret {
K8sResourceScore::single(cluster_role_binding, None) K8sResourceScore::single(cluster_role_binding, None)
.interpret(inventory, topology) .interpret(inventory, topology)
.await?; .await?;
K8sResourceScore::single(priority_class, None)
.interpret(inventory, topology)
.await?;
K8sResourceScore::single(daemon_set, Some(namespace_name.clone())) K8sResourceScore::single(daemon_set, Some(namespace_name.clone()))
.interpret(inventory, topology) .interpret(inventory, topology)
.await?; .await?;

View File

@@ -344,7 +344,7 @@ pub struct StaticMap {
pub mac: String, pub mac: String,
pub ipaddr: String, pub ipaddr: String,
pub cid: Option<MaybeString>, pub cid: Option<MaybeString>,
pub hostname: String, pub hostname: Option<String>,
pub descr: Option<MaybeString>, pub descr: Option<MaybeString>,
pub winsserver: MaybeString, pub winsserver: MaybeString,
pub dnsserver: MaybeString, pub dnsserver: MaybeString,
@@ -383,24 +383,24 @@ pub struct Outbound {
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
pub struct NatRule { pub struct NatRule {
pub protocol: String, pub protocol: Option<String>,
pub interface: String, pub interface: Option<String>,
pub category: MaybeString, pub category: Option<MaybeString>,
pub ipprotocol: String, pub ipprotocol: Option<String>,
pub descr: MaybeString, pub descr: Option<MaybeString>,
pub tag: MaybeString, pub tag: Option<MaybeString>,
pub tagged: Option<MaybeString>, pub tagged: Option<MaybeString>,
pub poolopts: PoolOpts, pub poolopts: Option<PoolOpts>,
#[yaserde(rename = "associated-rule-id")] #[yaserde(rename = "associated-rule-id")]
pub associated_rule_id: Option<MaybeString>, pub associated_rule_id: Option<MaybeString>,
pub disabled: Option<u8>, pub disabled: Option<u8>,
pub target: String, pub target: Option<String>,
#[yaserde(rename = "local-port")] #[yaserde(rename = "local-port")]
pub local_port: i32, pub local_port: Option<i32>,
pub source: Source, pub source: Option<Source>,
pub destination: Destination, pub destination: Option<Destination>,
pub updated: Updated, pub updated: Option<Updated>,
pub created: Created, pub created: Option<Created>,
} }
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
@@ -1545,7 +1545,7 @@ pub struct Vlans {
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
pub struct Bridges { pub struct Bridges {
pub bridged: Option<MaybeString>, pub bridged: Option<RawXml>,
} }
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]

View File

@@ -48,7 +48,7 @@ impl<'a> DhcpConfigLegacyISC<'a> {
hostname: &str, hostname: &str,
) -> Result<(), DhcpError> { ) -> Result<(), DhcpError> {
let mac = mac.to_string(); let mac = mac.to_string();
let hostname = hostname.to_string(); let hostname = Some(hostname.to_string());
let lan_dhcpd = self.get_lan_dhcpd(); let lan_dhcpd = self.get_lan_dhcpd();
let existing_mappings: &mut Vec<StaticMap> = &mut lan_dhcpd.staticmaps; let existing_mappings: &mut Vec<StaticMap> = &mut lan_dhcpd.staticmaps;
@@ -121,7 +121,7 @@ impl<'a> DhcpConfigLegacyISC<'a> {
.map(|entry| StaticMap { .map(|entry| StaticMap {
mac: entry["mac"].as_str().unwrap_or_default().to_string(), mac: entry["mac"].as_str().unwrap_or_default().to_string(),
ipaddr: entry["ipaddr"].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), descr: entry["descr"].as_str().map(MaybeString::from),
..Default::default() ..Default::default()
}) })

View File

@@ -213,7 +213,7 @@ impl<'a> DhcpConfigDnsMasq<'a> {
.map(|entry| StaticMap { .map(|entry| StaticMap {
mac: entry["mac"].as_str().unwrap_or_default().to_string(), mac: entry["mac"].as_str().unwrap_or_default().to_string(),
ipaddr: entry["ipaddr"].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), descr: entry["descr"].as_str().map(MaybeString::from),
..Default::default() ..Default::default()
}) })