feat: add priorityClass to node_health daemonset #249
@@ -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<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
|
||||
let mut daemonset_labels = BTreeMap::new();
|
||||
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 {
|
||||
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<T: Topology + K8sclient> Interpret<T> 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<T: Topology + K8sclient> Interpret<T> 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?;
|
||||
|
||||
@@ -344,7 +344,7 @@ pub struct StaticMap {
|
||||
pub mac: String,
|
||||
pub ipaddr: String,
|
||||
pub cid: Option<MaybeString>,
|
||||
pub hostname: String,
|
||||
pub hostname: Option<String>,
|
||||
pub descr: Option<MaybeString>,
|
||||
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<String>,
|
||||
pub interface: Option<String>,
|
||||
pub category: Option<MaybeString>,
|
||||
pub ipprotocol: Option<String>,
|
||||
pub descr: Option<MaybeString>,
|
||||
pub tag: Option<MaybeString>,
|
||||
pub tagged: Option<MaybeString>,
|
||||
pub poolopts: PoolOpts,
|
||||
pub poolopts: Option<PoolOpts>,
|
||||
#[yaserde(rename = "associated-rule-id")]
|
||||
pub associated_rule_id: Option<MaybeString>,
|
||||
pub disabled: Option<u8>,
|
||||
pub target: String,
|
||||
pub target: Option<String>,
|
||||
#[yaserde(rename = "local-port")]
|
||||
pub local_port: i32,
|
||||
pub source: Source,
|
||||
pub destination: Destination,
|
||||
pub updated: Updated,
|
||||
pub created: Created,
|
||||
pub local_port: Option<i32>,
|
||||
pub source: Option<Source>,
|
||||
pub destination: Option<Destination>,
|
||||
pub updated: Option<Updated>,
|
||||
pub created: Option<Created>,
|
||||
}
|
||||
|
||||
#[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<MaybeString>,
|
||||
pub bridged: Option<RawXml>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
|
||||
@@ -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<StaticMap> = &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()
|
||||
})
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user