Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pvc for stacks/bitcoin nodes #56

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ impl StacksDevnetApiK8sManager {

let bitcoind_conf = format!(
r#"
datadir=/etc/bitcoin
server=1
regtest=1
rpcallowip=0.0.0.0/0
Expand Down Expand Up @@ -876,6 +877,9 @@ impl StacksDevnetApiK8sManager {
)
.await?;

self.deploy_pvc(StacksDevnetPvc::BitcoindNode, &namespace)
.await?;

self.deploy_pod(StacksDevnetPod::BitcoindNode, &namespace)
.await?;

Expand Down Expand Up @@ -1052,6 +1056,9 @@ impl StacksDevnetApiK8sManager {
)
.await?;

self.deploy_pvc(StacksDevnetPvc::StacksNode, &namespace)
.await?;

self.deploy_pod(StacksDevnetPod::StacksNode, &namespace)
.await?;

Expand Down
4 changes: 4 additions & 0 deletions src/resources/pvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
}
}
2 changes: 2 additions & 0 deletions src/resources/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
6 changes: 6 additions & 0 deletions src/template_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
10 changes: 8 additions & 2 deletions templates/bitcoind-chain-coordinator-pod.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -74,3 +77,6 @@ spec:
- configMap:
name: project-dir-conf
name: project-dir-conf-volume
- persistentVolumeClaim:
claimName: bitcoind-node-pvc
name: bitcoind-data-volume
15 changes: 15 additions & 0 deletions templates/bitcoind-node-pvc.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: bitcoind-node-pvc
namespace: "{namespace}"
spec:
accessModes:
- ReadWriteOnce
resources:
limits:
storage: 750Mi
requests:
storage: 500Mi
storageClassName: devnet-storage-class
volumeMode: Filesystem
10 changes: 8 additions & 2 deletions templates/stacks-node-pod.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- name: stacks-node-data-volume
persistentVolumeClaim:
claimName: stacks-node-pvc
15 changes: 15 additions & 0 deletions templates/stacks-node-pvc.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: stacks-node-pvc
namespace: "{namespace}"
spec:
accessModes:
- ReadWriteOnce
resources:
limits:
storage: 750Mi
requests:
storage: 500Mi
storageClassName: devnet-storage-class
volumeMode: Filesystem
Loading