Skip to content

Commit

Permalink
Add runtime_class_name to fluent controller (#371)
Browse files Browse the repository at this point in the history
Signed-off-by: Wenjie Ma <[email protected]>
  • Loading branch information
euclidgame authored Oct 23, 2023
1 parent 802d91e commit 693ca4a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions deploy/fluent/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ spec:
description: "Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"
type: object
type: object
runtimeClassName:
type: string
tolerations:
items:
description: "The pod this Toleration is attached to tolerates any taint that matches the triple <key,value,effect> using the matching operator <operator>."
Expand All @@ -556,6 +558,8 @@ spec:
type: array
required:
- fluentBitConfigName
- image
- runtimeClassName
type: object
required:
- spec
Expand Down Expand Up @@ -603,3 +607,4 @@ spec:
served: true
storage: true
subresources: {}

1 change: 1 addition & 0 deletions e2e/src/fluent_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub fn fluent_bit() -> String {
spec:
fluentBitConfigName: fluent-bit-config
image: kubesphere/fluent-bit:v2.1.7
runtimeClassName: ''
tolerations:
- operator: Exists
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ fn make_fluentbit_pod_spec(fb: &FluentBit) -> (pod_spec: PodSpec)
pod_spec.overwrite_tolerations(fb.spec().tolerations());
pod_spec.overwrite_affinity(fb.spec().affinity());
pod_spec.set_node_selector(fb.spec().node_selector());
if !fb.spec().runtime_class_name().eq(&new_strlit("").to_string()) {
pod_spec.set_runtime_class_name(fb.spec().runtime_class_name());
}
pod_spec
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ impl FluentBitSpec {
{
StringMap::from_rust_map(self.inner.node_selector.clone())
}

#[verifier(external_body)]
pub fn runtime_class_name(&self) -> (runtime_class_name: String)
ensures
runtime_class_name@ == self@.runtime_class_name,
{
String::from_rust_string(self.inner.runtime_class_name.clone())
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ pub open spec fn make_fluentbit_pod_spec(fb: FluentBitView) -> PodSpecView
tolerations: fb.spec.tolerations,
affinity: fb.spec.affinity,
node_selector: Some(fb.spec.node_selector),
runtime_class_name: if fb.spec.runtime_class_name != new_strlit("")@ {
Some(fb.spec.runtime_class_name)
} else {
PodSpecView::default().runtime_class_name
},
..PodSpecView::default()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ pub struct FluentBitSpecView {
pub annotations: Map<StringView, StringView>,
pub affinity: Option<AffinityView>,
pub node_selector: Map<StringView, StringView>,
pub runtime_class_name: StringView,
}

impl FluentBitSpecView {}
Expand Down
2 changes: 2 additions & 0 deletions src/deps_hack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ pub struct FluentBitSpec {
pub affinity: Option<k8s_openapi::api::core::v1::Affinity>,
#[serde(default)]
pub node_selector: std::collections::BTreeMap<String, String>,
#[serde(rename = "runtimeClassName")]
pub runtime_class_name: String,
}

#[derive(
Expand Down

0 comments on commit 693ca4a

Please sign in to comment.