Skip to content

Commit

Permalink
fix: storage_class_name can be specified from env
Browse files Browse the repository at this point in the history
  • Loading branch information
wangeguo committed Feb 24, 2024
1 parent 8bc1fd2 commit fe89b2c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ AMP_NATS_URL=nats://amp-nats.amp-system.svc:4222

# The workspace path.
AMP_WORKSPACE=/workspace

# The storage class name. The default is `local-path` on k3s.
AMP_STORAGE_CLASS_NAME=local-path
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.8.17"
version = "0.8.18"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/amphitheatre-app/amphitheatre"
Expand Down
4 changes: 4 additions & 0 deletions controllers/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ pub struct Config {
/// The NATS URL.
#[clap(long, env = "AMP_NATS_URL")]
pub nats_url: String,

/// The storage class name.
#[clap(long, env = "AMP_STORAGE_CLASS_NAME")]
pub storage_class_name: String,
}
5 changes: 3 additions & 2 deletions resources/src/volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

use std::collections::BTreeMap;
use std::env;

use amp_common::resource::Actor;
use k8s_openapi::api::core::v1::{PersistentVolumeClaim, PersistentVolumeClaimSpec, ResourceRequirements};
Expand Down Expand Up @@ -62,13 +63,13 @@ fn new(actor: &Actor) -> Result<PersistentVolumeClaim> {
..Default::default()
},
spec: Some(PersistentVolumeClaimSpec {
access_modes: Some(vec!["ReadWriteOnce".into()]),
access_modes: Some(vec!["ReadWriteMany".into()]),
resources: Some(ResourceRequirements {
requests: Some(BTreeMap::from([("storage".into(), Quantity("1Gi".into()))])),
..Default::default()
}),
// @TODO: Make storage class name configurable
// storage_class_name: Some("local-path".into()),
storage_class_name: env::var("AMP_STORAGE_CLASS_NAME").ok(),
volume_mode: Some("Filesystem".into()),
..Default::default()
}),
Expand Down

0 comments on commit fe89b2c

Please sign in to comment.