From bb415fc9d83f426bf36eb0d51f703878e0a4ad17 Mon Sep 17 00:00:00 2001 From: MicaiahReid Date: Tue, 19 Sep 2023 12:40:42 -0400 Subject: [PATCH] use new pvcs --- src/lib.rs | 7 +++++++ src/resources/pvc.rs | 4 ++++ src/resources/tests.rs | 2 ++ src/template_parser.rs | 6 ++++++ templates/bitcoind-chain-coordinator-pod.template.yaml | 10 ++++++++-- templates/stacks-node-pod.template.yaml | 10 ++++++++-- 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2384a62..bf4ec3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -796,6 +796,7 @@ impl StacksDevnetApiK8sManager { let bitcoind_conf = format!( r#" + datadir=/etc/bitcoin server=1 regtest=1 rpcallowip=0.0.0.0/0 @@ -876,6 +877,9 @@ impl StacksDevnetApiK8sManager { ) .await?; + self.deploy_pvc(StacksDevnetPvc::BitcoindNode, &namespace) + .await?; + self.deploy_pod(StacksDevnetPod::BitcoindNode, &namespace) .await?; @@ -1052,6 +1056,9 @@ impl StacksDevnetApiK8sManager { ) .await?; + self.deploy_pvc(StacksDevnetPvc::StacksNode, &namespace) + .await?; + self.deploy_pod(StacksDevnetPod::StacksNode, &namespace) .await?; diff --git a/src/resources/pvc.rs b/src/resources/pvc.rs index 21ad26c..4116b67 100644 --- a/src/resources/pvc.rs +++ b/src/resources/pvc.rs @@ -4,12 +4,16 @@ use strum_macros::EnumIter; #[derive(EnumIter, Debug)] pub enum StacksDevnetPvc { StacksApi, + StacksNode, + BitcoindNode, } impl fmt::Display for StacksDevnetPvc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { StacksDevnetPvc::StacksApi => write!(f, "stacks-api-pvc"), + StacksDevnetPvc::StacksNode => write!(f, "stacks-node-pvc"), + StacksDevnetPvc::BitcoindNode => write!(f, "bitcoind-node-pvc"), } } } diff --git a/src/resources/tests.rs b/src/resources/tests.rs index 9e3a959..eb2e125 100644 --- a/src/resources/tests.rs +++ b/src/resources/tests.rs @@ -26,6 +26,8 @@ fn it_prints_correct_name_for_pod(pod: StacksDevnetPod) -> String { } #[test_case(StacksDevnetPvc::StacksApi => is equal_to "stacks-api-pvc".to_string(); "for StacksApi")] +#[test_case(StacksDevnetPvc::StacksNode => is equal_to "stacks-node-pvc".to_string(); "for StacksNode")] +#[test_case(StacksDevnetPvc::BitcoindNode => is equal_to "bitcoind-node-pvc".to_string(); "for BitcoindNode")] fn it_prints_correct_name_for_pvc(pvc: StacksDevnetPvc) -> String { pvc.to_string() } diff --git a/src/template_parser.rs b/src/template_parser.rs index 9e63384..c50eb1a 100644 --- a/src/template_parser.rs +++ b/src/template_parser.rs @@ -41,6 +41,12 @@ pub fn get_yaml_from_resource(resource: StacksDevnetResource) -> &'static str { StacksDevnetResource::Pvc(StacksDevnetPvc::StacksApi) => { include_str!("../templates/stacks-api-pvc.template.yaml") } + StacksDevnetResource::Pvc(StacksDevnetPvc::StacksNode) => { + include_str!("../templates/stacks-node-pvc.template.yaml") + } + StacksDevnetResource::Pvc(StacksDevnetPvc::BitcoindNode) => { + include_str!("../templates/bitcoind-node-pvc.template.yaml") + } StacksDevnetResource::Service(StacksDevnetService::StacksApi) => { include_str!("../templates/stacks-api-service.template.yaml") } diff --git a/templates/bitcoind-chain-coordinator-pod.template.yaml b/templates/bitcoind-chain-coordinator-pod.template.yaml index 0d5d020..aa80768 100644 --- a/templates/bitcoind-chain-coordinator-pod.template.yaml +++ b/templates/bitcoind-chain-coordinator-pod.template.yaml @@ -9,7 +9,7 @@ spec: containers: - command: - /usr/local/bin/bitcoind - - -conf=/etc/bitcoin/bitcoin.conf + - -conf=/tmp/conf/bitcoin.conf - -nodebuglogfile - -pid=/run/bitcoind.pid image: quay.io/hirosystems/bitcoind:devnet-v3 @@ -23,9 +23,12 @@ spec: name: rpc protocol: TCP volumeMounts: - - mountPath: /etc/bitcoin + - mountPath: /tmp/conf name: bitcoind-conf-volume readOnly: true + - mountPath: /etc/bitcoin + name: bitcoind-data-volume + readOnly: false - command: - ./stacks-network - --namespace=$(NAMESPACE) @@ -74,3 +77,6 @@ spec: - configMap: name: project-dir-conf name: project-dir-conf-volume + - persistentVolumeClaim: + claimName: bitcoind-node-pvc + name: bitcoind-data-volume diff --git a/templates/stacks-node-pod.template.yaml b/templates/stacks-node-pod.template.yaml index e49706f..3ff19ab 100644 --- a/templates/stacks-node-pod.template.yaml +++ b/templates/stacks-node-pod.template.yaml @@ -32,7 +32,13 @@ spec: - mountPath: /src/stacks-node name: stacks-node-conf-volume readOnly: true + - mountPath: /devnet + name: stacks-node-data-volume + readOnly: false volumes: - - configMap: + - name: stacks-node-conf-volume + configMap: name: stacks-node-conf - name: stacks-node-conf-volume \ No newline at end of file + - name: stacks-node-data-volume + persistentVolumeClaim: + claimName: stacks-node-pvc \ No newline at end of file