-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpdb.rs
More file actions
54 lines (47 loc) · 1.72 KB
/
Copy pathpdb.rs
File metadata and controls
54 lines (47 loc) · 1.72 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
//! Build the per-role `PodDisruptionBudget` for the HbaseCluster.
use stackable_operator::{
commons::pdb::PdbConfig, k8s_openapi::api::policy::v1::PodDisruptionBudget,
v2::builder::pdb::pod_disruption_budget_builder_with_role,
};
use crate::{
controller::{ValidatedCluster, controller_name, operator_name, product_name},
crd::HbaseRole,
};
/// Builds the [`PodDisruptionBudget`] for the given `role`, or `None` if PDBs are disabled.
pub fn build_pdb(
pdb: &PdbConfig,
cluster: &ValidatedCluster,
role: &HbaseRole,
) -> Option<PodDisruptionBudget> {
if !pdb.enabled {
return None;
}
let max_unavailable = pdb.max_unavailable.unwrap_or(match role {
HbaseRole::Master => max_unavailable_masters(),
HbaseRole::RegionServer => max_unavailable_region_servers(),
HbaseRole::RestServer => max_unavailable_rest_servers(),
});
let pdb = pod_disruption_budget_builder_with_role(
cluster,
&product_name(),
&role.into(),
&operator_name(),
&controller_name(),
)
.with_max_unavailable(max_unavailable)
.build();
Some(pdb)
}
fn max_unavailable_masters() -> u16 {
1
}
fn max_unavailable_region_servers() -> u16 {
1
}
fn max_unavailable_rest_servers() -> u16 {
// RestServers are stateless, we only need to make sure we have two available, so we don't have a single point of failure.
// However, users probably deploy multiple rest servers for both - availability and performance. As there is the use-case
// of having multiple RestServers for availability reasons, we need to be restrictive and stick to our `maxUnavailable: 1`
// for `Multiple replicas to increase availability` rolegroups guideline.
1
}