-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support storage configuration for rabbitmq (#261)
Signed-off-by: Wenjie Ma <[email protected]>
- Loading branch information
1 parent
154df75
commit be492a9
Showing
9 changed files
with
212 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ spec: | |
rabbitmqConfig: | ||
additionalConfig: | | ||
log.console.level = debug | ||
persistence: | ||
storage: 10Gi | ||
storageClassName: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1010,57 +1010,68 @@ fn make_stateful_set(rabbitmq: &RabbitmqCluster, config_map_rv: &String) -> (sta | |
}); | ||
// Set the templates used for creating the persistent volume claims attached to each pod | ||
stateful_set_spec.set_volume_claim_templates({ // TODO: Add PodManagementPolicy | ||
let mut volume_claim_templates = Vec::new(); | ||
volume_claim_templates.push({ | ||
let mut pvc = PersistentVolumeClaim::default(); | ||
pvc.set_metadata({ | ||
let mut metadata = ObjectMeta::default(); | ||
metadata.set_name(new_strlit("persistence").to_string()); | ||
metadata.set_namespace(rabbitmq.namespace().unwrap()); | ||
metadata.set_labels({ | ||
let mut labels = StringMap::empty(); | ||
labels.insert(new_strlit("app").to_string(), rabbitmq.name().unwrap()); | ||
labels | ||
if rabbitmq.spec().persistence().storage().eq(&new_strlit("0Gi").to_string()) { | ||
let empty_pvc = Vec::<PersistentVolumeClaim>::new(); | ||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|pvc: PersistentVolumeClaim| pvc@), | ||
rabbitmq_spec::make_stateful_set(rabbitmq@, config_map_rv@).spec.get_Some_0().volume_claim_templates.get_Some_0() | ||
); | ||
} | ||
empty_pvc | ||
} else { | ||
let mut volume_claim_templates = Vec::new(); | ||
volume_claim_templates.push({ | ||
let mut pvc = PersistentVolumeClaim::default(); | ||
pvc.set_metadata({ | ||
let mut metadata = ObjectMeta::default(); | ||
metadata.set_name(new_strlit("persistence").to_string()); | ||
metadata.set_namespace(rabbitmq.namespace().unwrap()); | ||
metadata.set_labels({ | ||
let mut labels = StringMap::empty(); | ||
labels.insert(new_strlit("app").to_string(), rabbitmq.name().unwrap()); | ||
labels | ||
}); | ||
metadata | ||
}); | ||
metadata | ||
}); | ||
pvc.set_spec({ | ||
let mut pvc_spec = PersistentVolumeClaimSpec::default(); | ||
pvc_spec.set_access_modes({ | ||
let mut access_modes = Vec::new(); | ||
access_modes.push(new_strlit("ReadWriteOnce").to_string()); | ||
|
||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|mode: String| mode@), | ||
rabbitmq_spec::make_stateful_set(rabbitmq@, config_map_rv@) | ||
.spec.get_Some_0().volume_claim_templates.get_Some_0()[0] | ||
.spec.get_Some_0().access_modes.get_Some_0() | ||
); | ||
} | ||
pvc.set_spec({ | ||
let mut pvc_spec = PersistentVolumeClaimSpec::default(); | ||
pvc_spec.set_access_modes({ | ||
let mut access_modes = Vec::new(); | ||
access_modes.push(new_strlit("ReadWriteOnce").to_string()); | ||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|mode: String| mode@), | ||
rabbitmq_spec::make_stateful_set(rabbitmq@, config_map_rv@) | ||
.spec.get_Some_0().volume_claim_templates.get_Some_0()[0] | ||
.spec.get_Some_0().access_modes.get_Some_0() | ||
); | ||
} | ||
|
||
access_modes | ||
}); | ||
pvc_spec.set_resources({ | ||
let mut resources = ResourceRequirements::default(); | ||
resources.set_requests({ | ||
let mut requests = StringMap::empty(); | ||
requests.insert(new_strlit("storage").to_string(), new_strlit("10Gi").to_string()); | ||
requests | ||
access_modes | ||
}); | ||
resources | ||
pvc_spec.set_resources({ | ||
let mut resources = ResourceRequirements::default(); | ||
resources.set_requests({ | ||
let mut requests = StringMap::empty(); | ||
requests.insert(new_strlit("storage").to_string(), rabbitmq.spec().persistence().storage()); | ||
requests | ||
}); | ||
resources | ||
}); | ||
pvc_spec.overwrite_storage_class_name(rabbitmq.spec().persistence().storage_class_name()); | ||
pvc_spec | ||
}); | ||
pvc_spec | ||
pvc | ||
}); | ||
pvc | ||
}); | ||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|pvc: PersistentVolumeClaim| pvc@), | ||
rabbitmq_spec::make_stateful_set(rabbitmq@, config_map_rv@).spec.get_Some_0().volume_claim_templates.get_Some_0() | ||
); | ||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|pvc: PersistentVolumeClaim| pvc@), | ||
rabbitmq_spec::make_stateful_set(rabbitmq@, config_map_rv@).spec.get_Some_0().volume_claim_templates.get_Some_0() | ||
); | ||
} | ||
volume_claim_templates | ||
} | ||
volume_claim_templates | ||
}); | ||
// Set management policy | ||
stateful_set_spec.set_pod_management_policy(new_strlit("Parallel").to_string()); | ||
|
@@ -1232,6 +1243,14 @@ fn make_rabbitmq_pod_spec(rabbitmq: &RabbitmqCluster) -> (pod_spec: PodSpec) | |
}); | ||
volume | ||
}); | ||
if rabbitmq.spec().persistence().storage().eq(&new_strlit("0Gi").to_string()) { | ||
volumes.push({ | ||
let mut volume = Volume::default(); | ||
volume.set_name(new_strlit("persistence").to_string()); | ||
volume.set_empty_dir(); | ||
volume | ||
}); | ||
} | ||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|vol: Volume| vol@), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.