get it working monero miner

This commit is contained in:
Brad Stein 2025-08-13 01:32:55 -05:00
parent 071be575c6
commit 0287a3291e
5 changed files with 20 additions and 114 deletions

View File

@ -67,7 +67,7 @@ spec:
ports:
- { name: rpc, containerPort: 18081 }
- { name: p2p, containerPort: 18080 }
- { name: p2pool, containerPort: 18083 }
- { name: zmq, containerPort: 18083 }
# securityContext:
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true

View File

@ -11,3 +11,4 @@ spec:
ports:
- { name: rpc, port: 18081, targetPort: 18081 }
- { name: p2p, port: 18080, targetPort: 18080 }
- { name: zmq, port: 18080, targetPort: 18080 }

View File

@ -1,76 +1,32 @@
# services/crypto/xmr-miner/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: p2pool
namespace: crypto
labels: { app: p2pool }
spec:
replicas: 1
selector:
matchLabels: { app: p2pool }
selector: { matchLabels: { app: p2pool } }
template:
metadata:
labels: { app: p2pool }
spec:
priorityClassName: scavenger
nodeSelector:
kubernetes.io/arch: arm64
priorityClassName: scavenger
volumes:
- name: tools
emptyDir: {}
- name: payout
secret:
secretName: xmr-payout
- name: sources
configMap:
name: xmr-miner-sources
initContainers:
- name: fetch-tools
image: debian:bookworm-slim
command: ["/bin/sh","-lc"]
args:
- |
set -eux
apt-get update
apt-get install -y --no-install-recommends ca-certificates curl xz-utils tar coreutils
update-ca-certificates
P2POOL_URL="$(cat /cfg/P2POOL_URL)"; : "${P2POOL_URL:?P2POOL_URL required}"
XMRIG_URL="$(cat /cfg/XMRIG_URL)"; : "${XMRIG_URL:?XMRIG_URL required}"
P2POOL_SHA="$(cat /cfg/P2POOL_SHA256)"; true
XMRIG_SHA="$(cat /cfg/XMRIG_SHA256)"; true
mkdir -p /opt/bin
# --- p2pool ---
curl -fL "$P2POOL_URL" -o /tmp/p2pool.tgz
if [ -n "${P2POOL_SHA:-}" ]; then echo "${P2POOL_SHA} /tmp/p2pool.tgz" | sha256sum -c -; fi
tar -x -C /tmp -f /tmp/p2pool.tgz || true
# pick the p2pool binary from whatever layout the tarball uses
P2=$(find /tmp -maxdepth 3 -type f -name 'p2pool*' -perm -u+x | head -n1)
test -n "$P2" && cp "$P2" /opt/bin/p2pool && chmod 0755 /opt/bin/p2pool
# --- xmrig (for quick local self-checks; DaemonSet also downloads its own) ---
curl -fL "$XMRIG_URL" -o /tmp/xmrig.tgz
if [ -n "${XMRIG_SHA:-}" ]; then echo "${XMRIG_SHA} /tmp/xmrig.tgz" | sha256sum -c -; fi
tar -x -C /tmp -f /tmp/xmrig.tgz || true
XR=$(find /tmp -maxdepth 3 -type f -name 'xmrig*' -perm -u+x | head -n1)
test -n "$XR" && cp "$XR" /opt/bin/xmrig && chmod 0755 /opt/bin/xmrig
ls -l /opt/bin
volumeMounts:
- { name: tools, mountPath: /opt/bin }
- { name: sources, mountPath: /cfg, readOnly: true }
containers:
- name: p2pool
image: debian:bookworm-slim
command: ["/bin/sh","-lc"]
image: ghcr.io/schernykh/p2pool:latest
imagePullPolicy: IfNotPresent
command: ["/bin/sh","-c"]
args:
- |
set -eu
ADDR="$(cat /run/xmr/address)"
# be nice to the node; p2pool will connect to your in-cluster monerod
exec nice -n 19 ionice -c3 /opt/bin/p2pool \
exec nice -n 19 ionice -c3 p2pool \
--wallet "$ADDR" \
--host monerod.crypto.svc.cluster.local \
--rpc-port 18081 \
@ -79,6 +35,4 @@ spec:
ports:
- { containerPort: 3333, name: stratum, protocol: TCP }
volumeMounts:
- { name: tools, mountPath: /opt/bin }
- { name: payout, mountPath: /run/xmr, readOnly: true }
# BestEffort QoS: no requests/limits → yields CPU when others need it

View File

@ -12,12 +12,3 @@ spec:
- name: stratum
port: 3333
targetPort: 3333
- name: rpc
port: 18081
targetPort: 18081
- name: p2p
port: 18080
targetPort: 18080
- name: zmq
port: 18083
targetPort: 18083

View File

@ -1,4 +1,3 @@
# services/crypto/xmr-miner/xmrig-daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
@ -8,79 +7,40 @@ metadata:
spec:
selector:
matchLabels: { app: xmr-xmrig }
updateStrategy:
type: RollingUpdate
updateStrategy: { type: RollingUpdate }
template:
metadata:
labels: { app: xmr-xmrig }
spec:
priorityClassName: scavenger
nodeSelector:
kubernetes.io/arch: arm64
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: DoesNotExist
- key: node-role.kubernetes.io/master
operator: DoesNotExist
volumes:
- name: tools
emptyDir: {}
- name: payout
secret:
secretName: xmr-payout
- name: sources
configMap:
name: xmr-miner-sources
initContainers:
- name: fetch-xmrig
image: debian:bookworm-slim
command: ["/bin/sh","-lc"]
args:
- |
set -eux
apt-get update
apt-get install -y --no-install-recommends ca-certificates curl xz-utils tar coreutils
update-ca-certificates
XMRIG_URL="$(cat /cfg/XMRIG_URL)"; : "${XMRIG_URL:?XMRIG_URL required}"
XMRIG_SHA="$(cat /cfg/XMRIG_SHA256)"; true
mkdir -p /opt/bin
curl -fL "$XMRIG_URL" -o /tmp/xmrig.tgz
if [ -n "${XMRIG_SHA:-}" ]; then echo "${XMRIG_SHA} /tmp/xmrig.tgz" | sha256sum -c -; fi
tar -x -C /tmp -f /tmp/xmrig.tgz || true
XR=$(find /tmp -maxdepth 3 -type f -name 'xmrig*' -perm -u+x | head -n1)
test -n "$XR" && cp "$XR" /opt/bin/xmrig && chmod 0755 /opt/bin/xmrig
ls -l /opt/bin
volumeMounts:
- { name: tools, mountPath: /opt/bin }
- { name: sources, mountPath: /cfg, readOnly: true }
containers:
- name: xmrig
image: debian:bookworm-slim
image: xmrig/xmrig:latest
imagePullPolicy: IfNotPresent
env:
- { name: XMRIG_THREADS, valueFrom: { configMapKeyRef: { name: xmr-miner-sources, key: XMRIG_THREADS } } }
- { name: XMRIG_EXTRA_ARGS,valueFrom: { configMapKeyRef: { name: xmr-miner-sources, key: XMRIG_EXTRA_ARGS } } }
- name: XMRIG_THREADS
valueFrom: { configMapKeyRef: { name: xmr-miner-sources, key: XMRIG_THREADS, optional: true } }
- name: XMRIG_EXTRA_ARGS
valueFrom: { configMapKeyRef: { name: xmr-miner-sources, key: XMRIG_EXTRA_ARGS, optional: true } }
command: ["/bin/sh","-lc"]
args:
- |
set -eu
ADDR="$(cat /run/xmr/address)"
THR="${XMRIG_THREADS:-1}"
EXTRA="${XMRIG_EXTRA_ARGS:-}"
# Lowest CPU/IO priority; connect to cluster p2pool
exec nice -n 19 ionice -c3 /opt/bin/xmrig \
# p2pool ignores wallet user; use 'x' or fixed difficulty with x+<diff>
exec nice -n 19 ionice -c3 xmrig \
-o p2pool.crypto.svc.cluster.local:3333 \
-u x+10000 \
-a rx \
-u x \
-k \
--donate-level 0 \
--cpu-priority 1 \
--threads "${THR}" ${EXTRA}
volumeMounts:
- { name: tools, mountPath: /opt/bin }
- { name: payout, mountPath: /run/xmr, readOnly: true }
# BestEffort QoS: no requests/limits → yields CPU when others need it