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: ports:
- { name: rpc, containerPort: 18081 } - { name: rpc, containerPort: 18081 }
- { name: p2p, containerPort: 18080 } - { name: p2p, containerPort: 18080 }
- { name: p2pool, containerPort: 18083 } - { name: zmq, containerPort: 18083 }
# securityContext: # securityContext:
# allowPrivilegeEscalation: false # allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true # readOnlyRootFilesystem: true

View File

@ -11,3 +11,4 @@ spec:
ports: ports:
- { name: rpc, port: 18081, targetPort: 18081 } - { name: rpc, port: 18081, targetPort: 18081 }
- { name: p2p, port: 18080, targetPort: 18080 } - { 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 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: p2pool name: p2pool
namespace: crypto namespace: crypto
labels: { app: p2pool }
spec: spec:
replicas: 1 replicas: 1
selector: selector: { matchLabels: { app: p2pool } }
matchLabels: { app: p2pool }
template: template:
metadata: metadata:
labels: { app: p2pool } labels: { app: p2pool }
spec: spec:
priorityClassName: scavenger
nodeSelector: nodeSelector:
kubernetes.io/arch: arm64 kubernetes.io/arch: arm64
priorityClassName: scavenger
volumes: volumes:
- name: tools
emptyDir: {}
- name: payout - name: payout
secret: secret:
secretName: xmr-payout 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: containers:
- name: p2pool - name: p2pool
image: debian:bookworm-slim image: ghcr.io/schernykh/p2pool:latest
command: ["/bin/sh","-lc"] imagePullPolicy: IfNotPresent
command: ["/bin/sh","-c"]
args: args:
- | - |
set -eu set -eu
ADDR="$(cat /run/xmr/address)" ADDR="$(cat /run/xmr/address)"
# be nice to the node; p2pool will connect to your in-cluster monerod exec nice -n 19 ionice -c3 p2pool \
exec nice -n 19 ionice -c3 /opt/bin/p2pool \
--wallet "$ADDR" \ --wallet "$ADDR" \
--host monerod.crypto.svc.cluster.local \ --host monerod.crypto.svc.cluster.local \
--rpc-port 18081 \ --rpc-port 18081 \
@ -79,6 +35,4 @@ spec:
ports: ports:
- { containerPort: 3333, name: stratum, protocol: TCP } - { containerPort: 3333, name: stratum, protocol: TCP }
volumeMounts: volumeMounts:
- { name: tools, mountPath: /opt/bin }
- { name: payout, mountPath: /run/xmr, readOnly: true } - { 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 - name: stratum
port: 3333 port: 3333
targetPort: 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 apiVersion: apps/v1
kind: DaemonSet kind: DaemonSet
metadata: metadata:
@ -8,79 +7,40 @@ metadata:
spec: spec:
selector: selector:
matchLabels: { app: xmr-xmrig } matchLabels: { app: xmr-xmrig }
updateStrategy: updateStrategy: { type: RollingUpdate }
type: RollingUpdate
template: template:
metadata: metadata:
labels: { app: xmr-xmrig } labels: { app: xmr-xmrig }
spec: spec:
priorityClassName: scavenger
nodeSelector: nodeSelector:
kubernetes.io/arch: arm64 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: volumes:
- name: tools
emptyDir: {}
- name: payout - name: payout
secret: secret:
secretName: xmr-payout 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: containers:
- name: xmrig - name: xmrig
image: debian:bookworm-slim image: xmrig/xmrig:latest
imagePullPolicy: IfNotPresent
env: env:
- { name: XMRIG_THREADS, valueFrom: { configMapKeyRef: { name: xmr-miner-sources, key: XMRIG_THREADS } } } - name: XMRIG_THREADS
- { name: XMRIG_EXTRA_ARGS,valueFrom: { configMapKeyRef: { name: xmr-miner-sources, key: XMRIG_EXTRA_ARGS } } } 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"] command: ["/bin/sh","-lc"]
args: args:
- | - |
set -eu set -eu
ADDR="$(cat /run/xmr/address)"
THR="${XMRIG_THREADS:-1}" THR="${XMRIG_THREADS:-1}"
EXTRA="${XMRIG_EXTRA_ARGS:-}" EXTRA="${XMRIG_EXTRA_ARGS:-}"
# Lowest CPU/IO priority; connect to cluster p2pool # p2pool ignores wallet user; use 'x' or fixed difficulty with x+<diff>
exec nice -n 19 ionice -c3 /opt/bin/xmrig \ exec nice -n 19 ionice -c3 xmrig \
-o p2pool.crypto.svc.cluster.local:3333 \ -o p2pool.crypto.svc.cluster.local:3333 \
-u x+10000 \ -u x \
-a rx \
-k \ -k \
--donate-level 0 \ --donate-level 0 \
--cpu-priority 1 \ --cpu-priority 1 \
--threads "${THR}" ${EXTRA} --threads "${THR}" ${EXTRA}
volumeMounts: volumeMounts:
- { name: tools, mountPath: /opt/bin }
- { name: payout, mountPath: /run/xmr, readOnly: true } - { name: payout, mountPath: /run/xmr, readOnly: true }
# BestEffort QoS: no requests/limits → yields CPU when others need it