From 7876e4389c2511e7e37478636217e4cbee179894 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Wed, 24 Dec 2025 19:06:40 -0300 Subject: [PATCH] crypto: fetch p2pool binary at runtime --- services/crypto/xmr-miner/deployment.yaml | 37 +++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/services/crypto/xmr-miner/deployment.yaml b/services/crypto/xmr-miner/deployment.yaml index dc24828..cf64fa4 100644 --- a/services/crypto/xmr-miner/deployment.yaml +++ b/services/crypto/xmr-miner/deployment.yaml @@ -30,11 +30,37 @@ spec: - key: hardware operator: In values: ["rpi4"] + initContainers: + - name: fetch-p2pool + image: alpine:3.20 + command: ["/bin/sh","-c"] + args: + - | + set -euo pipefail + apk add --no-cache curl tar openssl >/dev/null + test -n "${P2POOL_URL}" + echo "Downloading ${P2POOL_URL}" + curl -fsSL "${P2POOL_URL}" -o /tmp/p2pool.tgz + if [ -n "${P2POOL_SHA256}" ]; then + echo "${P2POOL_SHA256} /tmp/p2pool.tgz" | sha256sum -c - + fi + mkdir -p /opt/p2pool + tar -xzf /tmp/p2pool.tgz -C /opt/p2pool + BIN="$(find /opt/p2pool -maxdepth 1 -type f -name 'p2pool*' | head -n1)" + test -n "${BIN}" + install -m0755 "${BIN}" /opt/p2pool/p2pool + env: + - name: P2POOL_URL + valueFrom: { configMapKeyRef: { name: xmr-miner-sources, key: P2POOL_URL } } + - name: P2POOL_SHA256 + valueFrom: { configMapKeyRef: { name: xmr-miner-sources, key: P2POOL_SHA256, optional: true } } + volumeMounts: + - { name: p2pool-bin, mountPath: /opt/p2pool } containers: - name: monero-p2pool - image: registry.bstein.dev/crypto/monero-p2pool:4.9 - imagePullPolicy: Always - command: ["p2pool"] + image: debian:bookworm-slim + imagePullPolicy: IfNotPresent + command: ["/opt/p2pool/p2pool"] args: - "--host" - "monerod.crypto.svc.cluster.local" @@ -61,3 +87,8 @@ spec: tcpSocket: { port: 3333 } initialDelaySeconds: 10 periodSeconds: 10 + volumeMounts: + - { name: p2pool-bin, mountPath: /opt/p2pool } + volumes: + - name: p2pool-bin + emptyDir: {}