Skip to content

Commit 724d2fc

Browse files
authored
Merge pull request #104 from koooosh/more-k8s-settings
Add multiple k8s settings
2 parents 9306966 + 7433399 commit 724d2fc

File tree

8 files changed

+94
-13
lines changed

8 files changed

+94
-13
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bottlerocket-template-helper = { path = "./bottlerocket-template-helper", versio
5858

5959
# Settings Models
6060
bottlerocket-model-derive = { path = "./bottlerocket-settings-models/model-derive", version = "0.1" }
61-
bottlerocket-modeled-types = { path = "./bottlerocket-settings-models/modeled-types", version = "0.12" }
61+
bottlerocket-modeled-types = { path = "./bottlerocket-settings-models/modeled-types", version = "0.13" }
6262
bottlerocket-scalar = { path = "./bottlerocket-settings-models/scalar", version = "0.1" }
6363
bottlerocket-scalar-derive = { path = "./bottlerocket-settings-models/scalar-derive", version = "0.1" }
6464
bottlerocket-string-impls-for = { path = "./bottlerocket-settings-models/string-impls-for", version = "0.1" }
@@ -76,7 +76,7 @@ settings-extension-dns = { path = "./bottlerocket-settings-models/settings-exten
7676
settings-extension-ecs = { path = "./bottlerocket-settings-models/settings-extensions/ecs", version = "0.1" }
7777
settings-extension-host-containers = { path = "./bottlerocket-settings-models/settings-extensions/host-containers", version = "0.2" }
7878
settings-extension-kernel = { path = "./bottlerocket-settings-models/settings-extensions/kernel", version = "0.1" }
79-
settings-extension-kubernetes = { path = "./bottlerocket-settings-models/settings-extensions/kubernetes", version = "0.5" }
79+
settings-extension-kubernetes = { path = "./bottlerocket-settings-models/settings-extensions/kubernetes", version = "0.6" }
8080
settings-extension-kubelet-device-plugins = { path = "./bottlerocket-settings-models/settings-extensions/kubelet-device-plugins", version = "0.3" }
8181
settings-extension-metrics = { path = "./bottlerocket-settings-models/settings-extensions/metrics", version = "0.1" }
8282
settings-extension-motd = { path = "./bottlerocket-settings-models/settings-extensions/motd", version = "0.1" }

bottlerocket-settings-models/CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
- See [unreleased changes here]
1111

12-
[unreleased changes here]: https://github.com/bottlerocket-os/bottlerocket-settings-sdk/compare/bottlerocket-settings-models-v0.16.0...HEAD
12+
[unreleased changes here]: https://github.com/bottlerocket-os/bottlerocket-settings-sdk/compare/bottlerocket-settings-models-v0.17.0...HEAD
13+
14+
## [0.17.0] - 2025-11-05
15+
16+
## Model Changes
17+
18+
### Added
19+
20+
- Added `image-minimum-gc-age` and `image-maximum-gc-age` kubernetes settings ([#87]) - Thanks @parnniti!
21+
- Added `ids-per-pod` and `max-parallel-image-pulls` kubernetes settings ([#104])
22+
- Added beta options for `cpu-manager-policy-options` kubernetes settings ([#104])
23+
24+
[#87]:https://github.com/bottlerocket-os/bottlerocket-settings-sdk/pull/87
25+
[#104]:https://github.com/bottlerocket-os/bottlerocket-settings-sdk/pull/104
26+
27+
[0.17.0]: https://github.com/bottlerocket-os/bottlerocket-settings-sdk/compare/bottlerocket-settings-models-v0.16.0...bottlerocket-settings-models-v0.17.0
1328

1429
## [0.16.0] - 2025-09-19
1530

bottlerocket-settings-models/modeled-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bottlerocket-modeled-types"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
authors = []
55
license = "Apache-2.0 OR MIT"
66
edition = "2021"

bottlerocket-settings-models/modeled-types/src/kubernetes.rs

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,12 @@ pub struct CredentialProvider {
13371337
pub enum KubernetesCPUManagerPolicyOption {
13381338
#[serde(rename = "full-pcpus-only")]
13391339
FullPCPUsOnly,
1340+
#[serde(rename = "distribute-cpus-across-numa")]
1341+
DistributeCPUsAcrossNUMA,
1342+
#[serde(rename = "prefer-align-cpus-by-uncorecache")]
1343+
PreferAlignCPUsByUncorecache,
1344+
#[serde(rename = "strict-cpu-reservation")]
1345+
StrictCPUReservation,
13401346
}
13411347

13421348
#[cfg(test)]
@@ -1346,8 +1352,12 @@ mod test_kubernetes_cpu_manager_policy_option {
13461352

13471353
#[test]
13481354
fn good_cpu_manager_policy_option() {
1349-
{
1350-
let ok = &"full-pcpus-only";
1355+
for ok in &[
1356+
"full-pcpus-only",
1357+
"distribute-cpus-across-numa",
1358+
"prefer-align-cpus-by-uncorecache",
1359+
"strict-cpu-reservation",
1360+
] {
13511361
KubernetesCPUManagerPolicyOption::try_from(*ok).unwrap();
13521362
}
13531363
}
@@ -1492,6 +1502,55 @@ mod test_kubernetes_memory_swap_behavior {
14921502

14931503
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=
14941504

1505+
/// KubernetesIdsPerPodValue represents an integer that contains a valid Kubernetes idsPerPod value.
1506+
/// Must be a multiple of 65536 and less than 1<<32. Upstream validation:
1507+
/// https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/apis/config/validation/validation_linux.go
1508+
#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
1509+
#[serde(try_from = "i64", into = "i64")]
1510+
pub struct KubernetesIdsPerPodValue {
1511+
inner: i64,
1512+
}
1513+
1514+
impl TryFrom<i64> for KubernetesIdsPerPodValue {
1515+
type Error = error::Error;
1516+
1517+
fn try_from(input: i64) -> Result<Self, Self::Error> {
1518+
ensure!(
1519+
input % 65536 == 0 && input < (1i64 << 32),
1520+
error::InvalidKubernetesIdsPerPodValueSnafu { input }
1521+
);
1522+
Ok(KubernetesIdsPerPodValue { inner: input })
1523+
}
1524+
}
1525+
1526+
impl From<KubernetesIdsPerPodValue> for i64 {
1527+
fn from(val: KubernetesIdsPerPodValue) -> Self {
1528+
val.inner
1529+
}
1530+
}
1531+
1532+
#[cfg(test)]
1533+
mod test_kubernetes_ids_per_pod_value {
1534+
use super::KubernetesIdsPerPodValue;
1535+
use std::convert::TryFrom;
1536+
1537+
#[test]
1538+
fn good_values() {
1539+
for ok in &[0, 65536, 131072, 196608, 4294901760] {
1540+
KubernetesIdsPerPodValue::try_from(*ok).unwrap();
1541+
}
1542+
}
1543+
1544+
#[test]
1545+
fn bad_values() {
1546+
for err in &[1, 65535, 65537, 4294967296] {
1547+
KubernetesIdsPerPodValue::try_from(*err).unwrap_err();
1548+
}
1549+
}
1550+
}
1551+
1552+
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=
1553+
14951554
/// NvidiaDevicePluginSettings contains the device sharing and partitioning related settings for Nvidia gpu.
14961555
#[model(impl_default = true)]
14971556
pub struct NvidiaDevicePluginSettings {

bottlerocket-settings-models/modeled-types/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ pub mod error {
159159

160160
#[snafu(display("Invalid memory swap behavior value '{}'", input))]
161161
InvalidMemorySwapBehavior { input: String },
162+
163+
#[snafu(display("Invalid Kubernetes IDs per pod value '{}'", input))]
164+
InvalidKubernetesIdsPerPodValue { input: i64 },
162165
}
163166

164167
/// Creates a `ValidationError` with a consistent message for strings with regex validations

bottlerocket-settings-models/settings-extensions/kubernetes/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "settings-extension-kubernetes"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Sean P. Kelly <[email protected]>"]
55
license = "Apache-2.0 OR MIT"
66
edition = "2021"

bottlerocket-settings-models/settings-extensions/kubernetes/src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ use bottlerocket_modeled_types::{
55
KubernetesAuthenticationMode, KubernetesBootstrapToken, KubernetesCPUManagerPolicyOption,
66
KubernetesCloudProvider, KubernetesClusterDnsIp, KubernetesClusterName,
77
KubernetesDurationValue, KubernetesEvictionKey, KubernetesHostnameOverrideSource,
8-
KubernetesLabelKey, KubernetesLabelValue, KubernetesMemoryManagerPolicy,
9-
KubernetesMemoryReservation, KubernetesMemorySwapBehavior, KubernetesQuantityValue,
10-
KubernetesReservedResourceKey, KubernetesTaintValue, KubernetesThresholdValue,
11-
NonNegativeInteger, SingleLineString, TopologyManagerPolicy, TopologyManagerScope, Url,
12-
ValidBase64, ValidLinuxHostname,
8+
KubernetesIdsPerPodValue, KubernetesLabelKey, KubernetesLabelValue,
9+
KubernetesMemoryManagerPolicy, KubernetesMemoryReservation, KubernetesMemorySwapBehavior,
10+
KubernetesQuantityValue, KubernetesReservedResourceKey, KubernetesTaintValue,
11+
KubernetesThresholdValue, NonNegativeInteger, SingleLineString, TopologyManagerPolicy,
12+
TopologyManagerScope, Url, ValidBase64, ValidLinuxHostname,
1313
};
1414
use bottlerocket_settings_sdk::{GenerateResult, SettingsModel};
1515

@@ -98,6 +98,8 @@ pub struct KubernetesSettingsV1 {
9898
node_ip: IpAddr,
9999
pod_infra_container_image: SingleLineString,
100100
hostname_override: ValidLinuxHostname,
101+
ids_per_pod: KubernetesIdsPerPodValue,
102+
max_parallel_image_pulls: i32,
101103
}
102104

103105
type Result<T> = std::result::Result<T, Infallible>;
@@ -203,6 +205,8 @@ mod test {
203205
device_ownership_from_security_context: None,
204206
single_process_oom_kill: None,
205207
static_pods_enabled: None,
208+
ids_per_pod: None,
209+
max_parallel_image_pulls: None,
206210
})
207211
);
208212
}

bottlerocket-settings-models/settings-models/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bottlerocket-settings-models"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
authors = ["Tom Kirchner <[email protected]>"]
55
license = "Apache-2.0 OR MIT"
66
edition = "2021"

0 commit comments

Comments
 (0)