-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcontroller.rs
More file actions
129 lines (116 loc) · 3.53 KB
/
Copy pathcontroller.rs
File metadata and controls
129 lines (116 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
use stackable_operator::{
commons::resources::{
CpuLimitsFragment, MemoryLimitsFragment, NoRuntimeLimits, NoRuntimeLimitsFragment,
PvcConfigFragment, Resources, ResourcesFragment,
},
config::{fragment::Fragment, merge::Merge},
k8s_openapi::apimachinery::pkg::api::resource::Quantity,
product_config_utils::Configuration,
product_logging::{self, spec::Logging},
schemars::{self, JsonSchema},
};
use strum::{Display, EnumIter};
use crate::crd::{
role::commons::{CommonConfig, Storage, StorageFragment},
v1alpha1,
};
pub const CONTROLLER_PROPERTIES_FILE: &str = "controller.properties";
#[derive(
Clone,
Debug,
Deserialize,
Display,
Eq,
EnumIter,
JsonSchema,
Ord,
PartialEq,
PartialOrd,
Serialize,
)]
#[serde(rename_all = "kebab-case")]
#[strum(serialize_all = "kebab-case")]
pub enum ControllerContainer {
Vector,
Kafka,
}
#[derive(Debug, Default, PartialEq, Fragment, JsonSchema)]
#[fragment_attrs(
derive(
Clone,
Debug,
Default,
Deserialize,
JsonSchema,
Merge,
PartialEq,
Serialize
),
serde(rename_all = "camelCase")
)]
pub struct ControllerConfig {
#[fragment_attrs(serde(flatten))]
pub common_config: CommonConfig,
#[fragment_attrs(serde(default))]
pub logging: Logging<ControllerContainer>,
#[fragment_attrs(serde(default))]
pub resources: Resources<Storage, NoRuntimeLimits>,
/// The ListenerClass used for bootstrapping new clients.
pub bootstrap_listener_class: String,
}
impl ControllerConfig {
pub fn default_config(cluster_name: &str, role: &str) -> ControllerConfigFragment {
ControllerConfigFragment {
common_config: CommonConfig::default_config(cluster_name, role),
logging: product_logging::spec::default_logging(),
resources: ResourcesFragment {
cpu: CpuLimitsFragment {
min: Some(Quantity("250m".to_owned())),
max: Some(Quantity("1000m".to_owned())),
},
memory: MemoryLimitsFragment {
limit: Some(Quantity("1Gi".to_owned())),
runtime_limits: NoRuntimeLimitsFragment {},
},
storage: StorageFragment {
log_dirs: PvcConfigFragment {
capacity: Some(Quantity("2Gi".to_owned())),
storage_class: None,
selectors: None,
},
},
},
bootstrap_listener_class: Some("cluster-internal".to_string()),
}
}
}
impl Configuration for ControllerConfigFragment {
type Configurable = v1alpha1::KafkaCluster;
fn compute_env(
&self,
_resource: &Self::Configurable,
_role_name: &str,
) -> Result<BTreeMap<String, Option<String>>, stackable_operator::product_config_utils::Error>
{
Ok(BTreeMap::new())
}
fn compute_cli(
&self,
_resource: &Self::Configurable,
_role_name: &str,
) -> Result<BTreeMap<String, Option<String>>, stackable_operator::product_config_utils::Error>
{
Ok(BTreeMap::new())
}
fn compute_files(
&self,
_resource: &Self::Configurable,
_role_name: &str,
_file: &str,
) -> Result<BTreeMap<String, Option<String>>, stackable_operator::product_config_utils::Error>
{
Ok(BTreeMap::new())
}
}