From 78a636d8918e65eed9108c40ceaeb72aff7f6fcd Mon Sep 17 00:00:00 2001 From: Hayden Fuss Date: Thu, 18 Feb 2021 23:09:23 -0500 Subject: [PATCH] Miner v0.5.0 - Syslog, extra args, and custom entrypoint with dumb-init (#22) * Miner v0.5.0 - Syslog, extra args, and custom entrypoint with dumb-init * fixing image build and test * Fixing dumb-init * testing new miner image * removing worker_id * debugging new image * new image * no need to specify tls version * hmm * fixing scheme and supporting multiple pools * latest miner * nocolor seems to trump syslog ? * Final image and working chart --- .github/workflows/miner-build.yml | 3 +-- charts/miner/Chart.yaml | 4 ++-- charts/miner/templates/statefulset.yaml | 15 +++++++++------ charts/miner/values.yaml | 13 ++++++++++--- gitops/deploys/application-miner-brx-01a.yaml | 2 +- miner/CHANGELOG.md | 9 +++++++++ miner/Dockerfile | 19 +++++++++++-------- miner/VERSION | 2 +- miner/entrypoint.sh | 16 ++++++++++++++++ 9 files changed, 60 insertions(+), 23 deletions(-) create mode 100755 miner/entrypoint.sh diff --git a/.github/workflows/miner-build.yml b/.github/workflows/miner-build.yml index e25a73f..5318b40 100644 --- a/.github/workflows/miner-build.yml +++ b/.github/workflows/miner-build.yml @@ -39,8 +39,7 @@ jobs: - name: build and test run: | docker build . -t ghcr.io/hfuss/miner:${{ steps.versions.outputs.dirty-version }} - docker run -i ghcr.io/hfuss/miner:${{ steps.versions.outputs.dirty-version }} 'nsfminer --help' - docker run -i ghcr.io/hfuss/miner:${{ steps.versions.outputs.dirty-version }} 'ethminer --help' + docker run --entrypoint /usr/local/bin/nsfminer -i ghcr.io/hfuss/miner:${{ steps.versions.outputs.dirty-version }} '--help' docker push ghcr.io/hfuss/miner:${{ steps.versions.outputs.dirty-version }} working-directory: miner diff --git a/charts/miner/Chart.yaml b/charts/miner/Chart.yaml index 76ccd6d..c34f3ee 100644 --- a/charts/miner/Chart.yaml +++ b/charts/miner/Chart.yaml @@ -4,5 +4,5 @@ description: A Helm chart for deploying an Ethereum GPU miner on Kubernetes. maintainers: - name: hfuss type: application -version: 0.1.0 -appVersion: "0.4.0" +version: 0.2.0 +appVersion: "0.5.0" diff --git a/charts/miner/templates/statefulset.yaml b/charts/miner/templates/statefulset.yaml index 8d16ecc..27b7a98 100644 --- a/charts/miner/templates/statefulset.yaml +++ b/charts/miner/templates/statefulset.yaml @@ -34,13 +34,16 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - --report-hashrate + - --syslog + - --exit + {{- if .Values.extraArgs }} + {{- toYaml .Values.extraArgs | nindent 12 }} + {{- end }} env: - - name: WORKER_ID - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: MINE_POOL - value: {{ .Values.config.miningPool | quote }} + - name: MINING_POOLS + value: {{ .Values.miningPools | join " " | quote }} ports: - name: jsonrpc containerPort: 3333 diff --git a/charts/miner/values.yaml b/charts/miner/values.yaml index 927c64f..62bbc5d 100644 --- a/charts/miner/values.yaml +++ b/charts/miner/values.yaml @@ -2,14 +2,21 @@ image: repository: ghcr.io/hfuss/miner pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. - tag: v0.4.0 + tag: v0.5.0 # TODO v0.5.0 imagePullSecrets: [] nameOverride: "" fullnameOverride: "" -config: - miningPool: us1.ethermine.org +miningPools: + - us1.ethermine.org + - us2.ethermine.org + - eu1.ethermine.org + - asia1.ethermine.org + +extraArgs: [] +# - --eval +# - --failover-timeout=1 serviceAccount: # Specifies whether a service account should be created diff --git a/gitops/deploys/application-miner-brx-01a.yaml b/gitops/deploys/application-miner-brx-01a.yaml index 0cecd5d..324f339 100644 --- a/gitops/deploys/application-miner-brx-01a.yaml +++ b/gitops/deploys/application-miner-brx-01a.yaml @@ -10,7 +10,7 @@ spec: source: repoURL: https://github.com/hfuss/ethernetes path: charts/miner - targetRevision: latest-miner + targetRevision: main helm: values: | nodeSelector: diff --git a/miner/CHANGELOG.md b/miner/CHANGELOG.md index f67f5f2..69d25e8 100644 --- a/miner/CHANGELOG.md +++ b/miner/CHANGELOG.md @@ -15,6 +15,15 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies - ... +## [v0.5.0] +### Added +- Custom `entrypoint.sh` is copied to the image as `/usr/local/bin/custom-entrypoint.sh` to allow + for extra args and `dumb-init` + +### Dependencies +- Latest Ethereum miner [`https://github.com/no-fee-ethereum-mining/nsfminer@v1.3.5`](https://github.com/no-fee-ethereum-mining/nsfminer/releases/tag/v1.3.5) + + ## [v0.4.0] ### Changed - Decreasing the final image size using the `base` image rather than diff --git a/miner/Dockerfile b/miner/Dockerfile index 95fede0..ddb6950 100644 --- a/miner/Dockerfile +++ b/miner/Dockerfile @@ -10,15 +10,19 @@ RUN mkdir /ethminer WORKDIR /ethminer RUN apt-get install -y curl \ - && curl -sL -o ethminer.tgz https://github.com/no-fee-ethereum-mining/nsfminer/releases/download/v1.2.4/nsfminer_1.2.4-ubuntu_18.04-cuda_11.2-opencl.tgz \ + && curl -sL -o ethminer.tgz https://github.com/no-fee-ethereum-mining/nsfminer/releases/download/v1.3.5/nsfminer_1.3.5-ubuntu_18.04-cuda_11.2-opencl.tgz \ && tar -xzvf ethminer.tgz \ && mv nsfminer /usr/local/bin/ \ - && rm -rf * + && rm -rf * \ + && curl -sL https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_amd64.deb -o dumb-init_1.2.5_amd64.deb FROM docker.io/nvidia/cuda:11.2.0-base-ubuntu18.04 as final COPY --from=ethminer /usr/local/bin/nsfminer /usr/local/bin/nsfminer -RUN ln -sf /usr/local/bin/nsfminer /usr/local/bin/ethminer +COPY --from=ethminer /ethminer/dumb-init_*.deb . +RUN ln -sf /usr/local/bin/nsfminer /usr/local/bin/ethminer \ + && dpkg -i dumb-init_*.deb +COPY entrypoint.sh /usr/local/bin/custom-entrypoint.sh # TODO see if these env vars do anything still ENV GPU_FORCE_64BIT_PTR=0 \ @@ -27,11 +31,10 @@ ENV GPU_FORCE_64BIT_PTR=0 \ GPU_MAX_ALLOC_PERCENT=100 \ GPU_SINGLE_ALLOC_PERCENT=100 \ WALLET_ADDRESS=0xf0bEA86827AE84B7a712a4Bc716a15C465be3878 \ - MINE_POOL=us1.ethermine.org \ + MINING_POOLS="us1.ethermine.org" \ STRATUM_TLS_PORT=5555 \ - API_PORT=3333 \ - WORKER_ID=rdu-01a + API_PORT=3333 -ENTRYPOINT ["sh", "-c"] -CMD ["nsfminer -U -P stratum+tls12://${WALLET_ADDRESS}.${WORKER_ID}@${MINE_POOL}:${STRATUM_TLS_PORT} --report-hashrate --api-port -${API_PORT}"] +ENTRYPOINT ["/usr/local/bin/custom-entrypoint.sh"] +CMD ["--help"] EXPOSE ${API_PORT}/tcp diff --git a/miner/VERSION b/miner/VERSION index 60a2d3e..79a2734 100644 --- a/miner/VERSION +++ b/miner/VERSION @@ -1 +1 @@ -0.4.0 \ No newline at end of file +0.5.0 \ No newline at end of file diff --git a/miner/entrypoint.sh b/miner/entrypoint.sh new file mode 100755 index 0000000..00c2ac9 --- /dev/null +++ b/miner/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +miningPools=($MINING_POOLS) +poolArgs="" +for pool in "${miningPools[@]}"; do + poolArgs="${poolArgs} -P stratum+ssl://${WALLET_ADDRESS}.${HOSTNAME}@${pool}:${STRATUM_TLS_PORT}" +done + +# negative port number indicates API is in read-only mode preventing miner from being tampered with +# ensure SIGINTs get mapped to SIGTERMs +exec dumb-init --rewrite 15:2 nsfminer \ + -U \ + ${poolArgs} \ + --api-port "-${API_PORT}" $@ \ No newline at end of file