-
Notifications
You must be signed in to change notification settings - Fork 78
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
Kubernetes configuration for bitcoin and electrumx #3573
Changes from all commits
c912a49
9741c48
642cb25
ccf320e
3512957
bd53113
1c0e47d
5e26b53
07681cc
c6dc412
51dd2c3
b182549
40f183c
b78d4db
c0d5741
36188b7
6528539
71076fb
c5bad30
9029455
c72fe40
80aef7f
25c5fc5
75ecd1b
c4a0631
ea169c0
15ddca9
8d68236
5f4cf9b
1b9d513
6400eba
cce74bf
1d23f0b
2adb9dd
7f082d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export CLOUDSDK_ACTIVE_CONFIG_NAME=keep-prd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: bitcoin |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: bitcoind-data-bitcoind-1 | ||
namespace: bitcoin | ||
labels: | ||
app: bitcoind | ||
chain: bitcoin | ||
network: mainnet | ||
spec: | ||
storageClassName: bitcoind | ||
dataSource: | ||
name: bitcoind-snapshot | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 650Gi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: snapshot.storage.k8s.io/v1 | ||
kind: VolumeSnapshot | ||
metadata: | ||
name: bitcoind-snapshot | ||
spec: | ||
volumeSnapshotClassName: bitcoind | ||
source: | ||
persistentVolumeClaimName: bitcoind-data-bitcoind-0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it just for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We needed snapshot from |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
resources: | ||
- ../../../templates/bitcoin/bitcoind | ||
|
||
namespace: bitcoin | ||
|
||
commonLabels: | ||
network: mainnet | ||
|
||
configMapGenerator: | ||
- name: bitcoind | ||
behavior: merge | ||
literals: | ||
- chain=main | ||
|
||
secretGenerator: | ||
- name: bitcoind | ||
behavior: merge | ||
envs: | ||
- .env.secret | ||
|
||
patches: | ||
- target: | ||
kind: StatefulSet | ||
name: bitcoind | ||
patch: |- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: bitcoind | ||
spec: | ||
replicas: 2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: electrumx-compact-history | ||
namespace: bitcoin | ||
labels: | ||
chain: bitcoin | ||
app: electrumx | ||
network: mainnet | ||
spec: | ||
backoffLimit: 0 | ||
completions: 1 | ||
parallelism: 1 | ||
template: | ||
metadata: | ||
labels: | ||
chain: bitcoin | ||
app: electrumx | ||
network: mainnet | ||
job-name: electrumx-compact-history | ||
spec: | ||
securityContext: | ||
runAsUser: 1000 | ||
runAsGroup: 1000 | ||
fsGroup: 1000 | ||
# https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#configure-volume-permission-and-ownership-change-policy-for-pods | ||
fsGroupChangePolicy: "OnRootMismatch" | ||
containers: | ||
- name: electrumx | ||
image: lukechilds/electrumx:v1.16.0 # TODO: switch to our image | ||
imagePullPolicy: Always | ||
command: | ||
- /electrumx/electrumx_compact_history | ||
env: | ||
- name: COIN | ||
value: BitcoinSegwit | ||
- name: NET | ||
value: mainnet | ||
- name: DB_DIRECTORY | ||
value: /mnt/electrum/data | ||
- name: DAEMON_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: bitcoind | ||
key: rpc-password | ||
- name: DAEMON_HOST | ||
valueFrom: | ||
configMapKeyRef: | ||
name: electrumx | ||
key: daemon-host | ||
- name: DAEMON_URL | ||
value: http://$(DAEMON_USER):$(DAEMON_TOKEN)@$(DAEMON_HOST) | ||
- name: COST_SOFT_LIMIT | ||
value: "0" | ||
- name: COST_HARD_LIMIT | ||
value: "0" | ||
- name: LOG_LEVEL | ||
value: debug | ||
volumeMounts: | ||
- name: electrumx-data | ||
mountPath: /mnt/electrum/data | ||
restartPolicy: Never | ||
volumes: | ||
- name: electrumx-data | ||
persistentVolumeClaim: | ||
# Update to the desired replica's volume index. | ||
claimName: electrumx-data-electrumx-2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: electrumx-data-electrumx-1 | ||
namespace: bitcoin | ||
labels: | ||
app: electrumx | ||
chain: bitcoin | ||
network: mainnet | ||
spec: | ||
storageClassName: electrumx-v2 | ||
dataSource: | ||
name: electrumx-snapshot | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 450Gi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: electrumx-data-electrumx-2 | ||
namespace: bitcoin | ||
labels: | ||
app: electrumx | ||
chain: bitcoin | ||
network: mainnet | ||
spec: | ||
storageClassName: electrumx-v2 | ||
dataSource: | ||
name: electrumx-snapshot | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 450Gi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: snapshot.storage.k8s.io/v1 | ||
kind: VolumeSnapshot | ||
metadata: | ||
name: electrumx-snapshot | ||
spec: | ||
volumeSnapshotClassName: electrumx | ||
source: | ||
persistentVolumeClaimName: electrumx-data-electrumx-0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question about generating snapshots as for bitcoind. Don't we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Answered here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
resources: | ||
- ../../../templates/bitcoin/electrumx | ||
|
||
namespace: bitcoin | ||
|
||
commonLabels: | ||
network: mainnet | ||
|
||
secretGenerator: | ||
- name: tbtc-network-cloudflare-origin-cert | ||
type: kubernetes.io/tls | ||
files: | ||
- .secret/ca.crt | ||
- .secret/tls.crt | ||
- .secret/tls.key | ||
|
||
patches: | ||
- target: | ||
kind: Service | ||
name: electrumx | ||
patch: |- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: electrumx | ||
spec: | ||
type: LoadBalancer | ||
loadBalancerIP: 35.223.16.19 | ||
- target: | ||
kind: StatefulSet | ||
name: electrumx | ||
patch: |- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: electrumx | ||
spec: | ||
replicas: 3 | ||
|
||
generatorOptions: | ||
disableNameSuffixHash: true | ||
annotations: | ||
note: generated |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
resources: | ||
- bitcoin-namespace.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export CLOUDSDK_ACTIVE_CONFIG_NAME=keep-test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: bitcoin-testnet |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: bitcoind-data-bitcoind-1 | ||
namespace: bitcoin-testnet | ||
labels: | ||
app: bitcoind | ||
chain: bitcoin | ||
network: testnet | ||
spec: | ||
storageClassName: bitcoind | ||
dataSource: | ||
name: bitcoind-snapshot | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 50Gi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: snapshot.storage.k8s.io/v1 | ||
kind: VolumeSnapshot | ||
metadata: | ||
name: bitcoind-snapshot | ||
spec: | ||
volumeSnapshotClassName: bitcoind | ||
source: | ||
persistentVolumeClaimName: bitcoind-data-bitcoind-0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
resources: | ||
- ../../../../templates/bitcoin/bitcoind | ||
|
||
namespace: bitcoin-testnet | ||
|
||
commonLabels: | ||
network: testnet | ||
|
||
configMapGenerator: | ||
- name: bitcoind | ||
behavior: merge | ||
literals: | ||
- chain=test | ||
|
||
secretGenerator: | ||
- name: bitcoind | ||
behavior: merge | ||
envs: | ||
- .env.secret | ||
|
||
patches: | ||
# Patch bitcoind StatefulSet by setting a storage request specific for testnet. | ||
- target: | ||
kind: StatefulSet | ||
name: bitcoind | ||
patch: |- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: bitcoind | ||
spec: | ||
replicas: 2 | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: bitcoind-data | ||
labels: | ||
chain: bitcoin | ||
app: bitcoind | ||
network: testnet | ||
spec: | ||
storageClassName: bitcoind | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 50Gi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: electrumx-data-electrumx-1 | ||
namespace: bitcoin-testnet | ||
labels: | ||
app: electrumx | ||
chain: bitcoin | ||
network: testnet | ||
spec: | ||
storageClassName: electrumx-v2 | ||
dataSource: | ||
name: electrumx-snapshot | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 30Gi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: snapshot.storage.k8s.io/v1 | ||
kind: VolumeSnapshot | ||
metadata: | ||
name: electrumx-snapshot | ||
spec: | ||
volumeSnapshotClassName: electrumx | ||
source: | ||
persistentVolumeClaimName: electrumx-data-electrumx-0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am looking at the list of PVCs in GCP and I see
bitcoind-data-bitcoind-1
andbitcoind-data-bitcoind-0
. To confirm my understanding: we are running two replicas of bitcoind, each with its own PVC. Is this correct? If so, why don't we havebitcoind-data-bitcoind-0-pvc.yaml
file here as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bitcoind-data-bitcoind-0-pvc
got created automatically when we started the bitcoind statefulset withvolumeClaimTemplates
and just one replica.After the first replica synced we crated a snapshot of
bitcoind-data-bitcoind-0
PVC and used it as adataSource
to create thebitcoind-data-bitcoind-1
.