From 9695c955488db5e330bf455da5af21626ebcdcdf Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 13:25:36 -0600 Subject: [PATCH 01/13] update: validation script --- ...ate_manifests.sh => validate_kustomize.sh} | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) rename scripts/{validate_manifests.sh => validate_kustomize.sh} (69%) diff --git a/scripts/validate_manifests.sh b/scripts/validate_kustomize.sh similarity index 69% rename from scripts/validate_manifests.sh rename to scripts/validate_kustomize.sh index 872c8ef..49b6105 100755 --- a/scripts/validate_manifests.sh +++ b/scripts/validate_kustomize.sh @@ -1,9 +1,6 @@ #!/bin/bash # shellcheck disable=SC2034,SC2044 -# DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -DIR="$(pwd)" - display_help(){ echo "./$(basename "$0") [ -d | --directory DIRECTORY ] [ -e | --enforce-all-schemas ] [ -h | --help ] [ -sl | --schema-location ] Script to validate the manifests generated by Kustomize @@ -15,11 +12,13 @@ Where: } which kustomize && KUSTOMIZE_CMD="kustomize build" +which helm && GOT_HELM="--enable-helm" +# DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" KUSTOMIZE_CMD="${KUSTOMIZE_CMD:-oc kustomize}" IGNORE_MISSING_SCHEMAS="--ignore-missing-schemas" -SCHEMA_LOCATION="${DIR}/openshift-json-schema" -KUSTOMIZE_DIRS="${DIR}" +SCHEMA_LOCATION="./openshift-json-schema" +KUSTOMIZE_DIRS="." init(){ for i in "${@}" @@ -62,33 +61,32 @@ kustomization_auto_fix(){ } kustomization_build(){ - BUILD=${1} - KUSTOMIZE_BUILD_OUTPUT=$(${KUSTOMIZE_CMD} "${BUILD}") - # echo "$KUSTOMIZE_BUILD_OUTPUT" | kubeval ${IGNORE_MISSING_SCHEMAS} --schema-location="file://${SCHEMA_LOCATION}" --force-color + BUILD=${1} + KUSTOMIZE_BUILD_OUTPUT=$(${KUSTOMIZE_CMD} "${BUILD}" "${GOT_HELM}") + # echo "$KUSTOMIZE_BUILD_OUTPUT" | kubeval ${IGNORE_MISSING_SCHEMAS} --schema-location="file://${SCHEMA_LOCATION}" --force-color - build_response=$? + cmd_response=$? - if [ $build_response -ne 0 ]; then - echo "[ERROR]" - exit 1 - fi + if [ $cmd_response -ne 0 ]; then + echo "[ERROR]" + exit 1 + fi - echo "[OK]" + echo "[OK]" } -process_kustomization(){ - +kustomization_process(){ echo "Validating..." - for BUILD in $(find "${KUSTOMIZE_DIRS}" -name "kustomization.yaml" -exec dirname {} \;) + for LINT in $(find "${KUSTOMIZE_DIRS}" -name "kustomization.yaml" -exec dirname {} \;) do - echo "${BUILD}" - - kustomization_build "${BUILD}" - # kustomization_auto_fix "${BUILD}" - + echo "${LINT}" + kustomization_build "${LINT}" + # kustomization_auto_fix "${LINT}" done + + echo "Kustomize check passed :)" } init "${@}" -process_kustomization +kustomization_process From 420af8695f912b9dec2e2be00847bc8f89cf18ba Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 16:09:21 -0600 Subject: [PATCH 02/13] refactor --- k8s/base/deployment/kustomization.yaml | 5 -- k8s/base/kustomization.yaml | 2 +- k8s/base/namespace.yaml | 2 +- .../cronjob/cron-xmrig-sa.yaml | 0 .../cronjob/cron-xmrig-scale-limit.yaml | 0 .../cronjob/cron-xmrig-scale-unlimit.yaml | 0 .../cronjob/kustomization.yaml | 4 +- k8s/components/daemon-set/kustomization.yaml | 5 ++ .../daemon-set}/xmrig-ds.yaml | 0 .../deployment/deployment.yaml} | 10 ++-- k8s/components/deployment/kustomization.yaml | 13 +++++ k8s/{base => components/pod}/xmrig-pod.yaml | 0 k8s/components/proxy-miner/kustomization.yaml | 25 ++++++++++ k8s/components/proxy/deployment.yaml | 48 ++++++++++++++++++ k8s/components/proxy/kustomization.yaml | 14 ++++++ .../proxy/xmrig-proxy-svc.yaml | 0 k8s/overlays/burn-in/kustomization.yaml | 3 ++ k8s/overlays/cuda/kustomization.yaml | 6 +-- k8s/overlays/default/kustomization.yaml | 3 ++ k8s/overlays/hugepages-2m/kustomization.yaml | 6 +-- k8s/overlays/proxy-miner/kustomization.yaml | 38 ++------------ k8s/overlays/proxy/kustomization.yaml | 49 ------------------- openshift/machine-config/kustomization.yaml | 4 +- 23 files changed, 131 insertions(+), 106 deletions(-) delete mode 100644 k8s/base/deployment/kustomization.yaml rename k8s/{base => components}/cronjob/cron-xmrig-sa.yaml (100%) rename k8s/{base => components}/cronjob/cron-xmrig-scale-limit.yaml (100%) rename k8s/{base => components}/cronjob/cron-xmrig-scale-unlimit.yaml (100%) rename k8s/{base => components}/cronjob/kustomization.yaml (61%) create mode 100644 k8s/components/daemon-set/kustomization.yaml rename k8s/{base => components/daemon-set}/xmrig-ds.yaml (100%) rename k8s/{base/deployment/xmrig-deploy.yaml => components/deployment/deployment.yaml} (83%) create mode 100644 k8s/components/deployment/kustomization.yaml rename k8s/{base => components/pod}/xmrig-pod.yaml (100%) create mode 100644 k8s/components/proxy-miner/kustomization.yaml create mode 100644 k8s/components/proxy/deployment.yaml create mode 100644 k8s/components/proxy/kustomization.yaml rename k8s/{overlays => components}/proxy/xmrig-proxy-svc.yaml (100%) delete mode 100644 k8s/overlays/proxy/kustomization.yaml diff --git a/k8s/base/deployment/kustomization.yaml b/k8s/base/deployment/kustomization.yaml deleted file mode 100644 index 50709fd..0000000 --- a/k8s/base/deployment/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - xmrig-deploy.yaml diff --git a/k8s/base/kustomization.yaml b/k8s/base/kustomization.yaml index e38e03e..dca4a51 100644 --- a/k8s/base/kustomization.yaml +++ b/k8s/base/kustomization.yaml @@ -2,4 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - xmrig-ds.yaml + - namespace.yaml diff --git a/k8s/base/namespace.yaml b/k8s/base/namespace.yaml index b8fe34c..1b85d07 100644 --- a/k8s/base/namespace.yaml +++ b/k8s/base/namespace.yaml @@ -3,4 +3,4 @@ apiVersion: v1 metadata: name: burn-in annotations: - openshift.io/display-name: Hardware Burn-In + openshift.io/display-name: Stress Cluster Workload diff --git a/k8s/base/cronjob/cron-xmrig-sa.yaml b/k8s/components/cronjob/cron-xmrig-sa.yaml similarity index 100% rename from k8s/base/cronjob/cron-xmrig-sa.yaml rename to k8s/components/cronjob/cron-xmrig-sa.yaml diff --git a/k8s/base/cronjob/cron-xmrig-scale-limit.yaml b/k8s/components/cronjob/cron-xmrig-scale-limit.yaml similarity index 100% rename from k8s/base/cronjob/cron-xmrig-scale-limit.yaml rename to k8s/components/cronjob/cron-xmrig-scale-limit.yaml diff --git a/k8s/base/cronjob/cron-xmrig-scale-unlimit.yaml b/k8s/components/cronjob/cron-xmrig-scale-unlimit.yaml similarity index 100% rename from k8s/base/cronjob/cron-xmrig-scale-unlimit.yaml rename to k8s/components/cronjob/cron-xmrig-scale-unlimit.yaml diff --git a/k8s/base/cronjob/kustomization.yaml b/k8s/components/cronjob/kustomization.yaml similarity index 61% rename from k8s/base/cronjob/kustomization.yaml rename to k8s/components/cronjob/kustomization.yaml index 4d4fd89..4379d3f 100644 --- a/k8s/base/cronjob/kustomization.yaml +++ b/k8s/components/cronjob/kustomization.yaml @@ -1,5 +1,5 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component resources: - cron-xmrig-sa.yaml diff --git a/k8s/components/daemon-set/kustomization.yaml b/k8s/components/daemon-set/kustomization.yaml new file mode 100644 index 0000000..497948c --- /dev/null +++ b/k8s/components/daemon-set/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: + - xmrig-ds.yaml diff --git a/k8s/base/xmrig-ds.yaml b/k8s/components/daemon-set/xmrig-ds.yaml similarity index 100% rename from k8s/base/xmrig-ds.yaml rename to k8s/components/daemon-set/xmrig-ds.yaml diff --git a/k8s/base/deployment/xmrig-deploy.yaml b/k8s/components/deployment/deployment.yaml similarity index 83% rename from k8s/base/deployment/xmrig-deploy.yaml rename to k8s/components/deployment/deployment.yaml index c2e5710..aa5447f 100644 --- a/k8s/base/deployment/xmrig-deploy.yaml +++ b/k8s/components/deployment/deployment.yaml @@ -3,10 +3,6 @@ kind: Deployment metadata: labels: app: xmrig - app.kubernetes.io/component: xmrig - app.kubernetes.io/instance: xmrig - app.kubernetes.io/name: xmrig - app.kubernetes.io/part-of: xmrig name: xmrig spec: replicas: 1 @@ -32,13 +28,13 @@ spec: - name: POOL_PASS value: k8s - name: EXTRA_ARGS - value: '--no-huge-pages --cpu-no-yield --max-cpu-usage=100 -t=1 --no-color' + value: '--no-huge-pages --cpu-no-yield --max-cpu-usage=100 -t=2' resources: limits: - cpu: '1' + cpu: '3' memory: 2400Mi requests: - cpu: '1' + cpu: '2' ports: - containerPort: 3333 protocol: TCP diff --git a/k8s/components/deployment/kustomization.yaml b/k8s/components/deployment/kustomization.yaml new file mode 100644 index 0000000..7be99b2 --- /dev/null +++ b/k8s/components/deployment/kustomization.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +labels: +- includeSelectors: true + pairs: + app.kubernetes.io/component: xmrig + app.kubernetes.io/instance: xmrig + app.kubernetes.io/name: xmrig + app.kubernetes.io/part-of: xmrig + +resources: + - deployment.yaml diff --git a/k8s/base/xmrig-pod.yaml b/k8s/components/pod/xmrig-pod.yaml similarity index 100% rename from k8s/base/xmrig-pod.yaml rename to k8s/components/pod/xmrig-pod.yaml diff --git a/k8s/components/proxy-miner/kustomization.yaml b/k8s/components/proxy-miner/kustomization.yaml new file mode 100644 index 0000000..e0d01d6 --- /dev/null +++ b/k8s/components/proxy-miner/kustomization.yaml @@ -0,0 +1,25 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +labels: +- includeSelectors: true + pairs: + app.kubernetes.io/component: xmrig + app.kubernetes.io/instance: xmrig + app.kubernetes.io/name: xmrig + app.kubernetes.io/part-of: xmrig + +components: + - ../../components/deployment + +patches: + - target: + group: apps + kind: Deployment + name: xmrig + patch: |- + - op: replace + path: /spec/template/spec/containers/0/env/0 + value: + name: POOL_URL + value: xmrig-proxy:3333 diff --git a/k8s/components/proxy/deployment.yaml b/k8s/components/proxy/deployment.yaml new file mode 100644 index 0000000..8491eba --- /dev/null +++ b/k8s/components/proxy/deployment.yaml @@ -0,0 +1,48 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: xmrig-proxy +spec: + replicas: 1 + selector: + matchLabels: + app: xmrig-proxy + strategy: + type: RollingUpdate + template: + metadata: + labels: + app: xmrig-proxy + spec: + containers: + - env: + - name: POOL_URL + value: gulf.moneroocean.stream:10128 + - name: POOL_USER + value: 4AwPZobe6PsLbfk5ntnv6Wa9DPL3aPd4N2b761EmsMpAQbBaJaAajQGhtBXDL9Mo4G649oAmWzNJU5L3YBS458iw2XkJp26 + - name: POOL_PASS + value: k8s-proxy + - name: EXTRA_ARGS + value: "" + image: ghcr.io/codekow/xmrig-proxy:latest + imagePullPolicy: IfNotPresent + name: xmrig-proxy + ports: + - containerPort: 3333 + protocol: TCP + - containerPort: 8080 + protocol: TCP + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 500m + memory: 128Mi + volumeMounts: + - mountPath: /home/miner + name: empty + restartPolicy: Always + volumes: + - emptyDir: {} + name: empty diff --git a/k8s/components/proxy/kustomization.yaml b/k8s/components/proxy/kustomization.yaml new file mode 100644 index 0000000..29282d5 --- /dev/null +++ b/k8s/components/proxy/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +labels: +- includeSelectors: true + pairs: + app.kubernetes.io/component: xmrig + app.kubernetes.io/instance: xmrig + app.kubernetes.io/name: xmrig + app.kubernetes.io/part-of: xmrig + +resources: + - deployment.yaml + - xmrig-proxy-svc.yaml diff --git a/k8s/overlays/proxy/xmrig-proxy-svc.yaml b/k8s/components/proxy/xmrig-proxy-svc.yaml similarity index 100% rename from k8s/overlays/proxy/xmrig-proxy-svc.yaml rename to k8s/components/proxy/xmrig-proxy-svc.yaml diff --git a/k8s/overlays/burn-in/kustomization.yaml b/k8s/overlays/burn-in/kustomization.yaml index d8354b7..82ea0b4 100644 --- a/k8s/overlays/burn-in/kustomization.yaml +++ b/k8s/overlays/burn-in/kustomization.yaml @@ -1,6 +1,9 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization +components: + - ../../components/daemon-set + resources: - ../../base diff --git a/k8s/overlays/cuda/kustomization.yaml b/k8s/overlays/cuda/kustomization.yaml index e943905..9434af0 100644 --- a/k8s/overlays/cuda/kustomization.yaml +++ b/k8s/overlays/cuda/kustomization.yaml @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - ../../base + - ../burn-in patches: - target: @@ -10,8 +10,8 @@ patches: kind: DaemonSet name: xmrig patch: |- - - op: remove - path: /metadata/labels + # - op: remove + # path: /metadata/labels - op: replace path: /metadata/name value: burn-in-cuda-remove diff --git a/k8s/overlays/default/kustomization.yaml b/k8s/overlays/default/kustomization.yaml index 774a422..e003081 100644 --- a/k8s/overlays/default/kustomization.yaml +++ b/k8s/overlays/default/kustomization.yaml @@ -1,5 +1,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization +components: + - ../../components/deployment + resources: - ../../base diff --git a/k8s/overlays/hugepages-2m/kustomization.yaml b/k8s/overlays/hugepages-2m/kustomization.yaml index 87bde0e..24d4d66 100644 --- a/k8s/overlays/hugepages-2m/kustomization.yaml +++ b/k8s/overlays/hugepages-2m/kustomization.yaml @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - ../../base + - ../burn-in patches: - target: @@ -10,8 +10,8 @@ patches: kind: DaemonSet name: xmrig patch: |- - - op: remove - path: /metadata/labels + # - op: remove + # path: /metadata/labels - op: replace path: /metadata/name value: burn-in-hugepages-2m-remove diff --git a/k8s/overlays/proxy-miner/kustomization.yaml b/k8s/overlays/proxy-miner/kustomization.yaml index 42ebcbe..71bdf52 100644 --- a/k8s/overlays/proxy-miner/kustomization.yaml +++ b/k8s/overlays/proxy-miner/kustomization.yaml @@ -1,37 +1,9 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -resources: - - ../../base/deployment +components: + - ../../components/proxy + - ../../components/proxy-miner -patches: - - target: - group: apps - kind: Deployment - name: xmrig - patch: |- - - op: remove - path: /metadata/labels - - op: replace - path: /metadata/name - value: burn-in-hugepages-2m-remove - - op: replace - path: /spec/selector/matchLabels/app - value: burn-in-hugepages-2m - - op: replace - path: /spec/template/metadata/labels/app - value: burn-in-hugepages-2m - - op: replace - path: /spec/template/spec/containers/0/name - value: burn-in-hugepages-2m - - op: replace - path: /spec/template/spec/containers/0/env - value: - - name: POOL_URL - value: xmrig-proxy:3333 - - name: POOL_USER - value: $(HOSTNAME) - - name: POOL_PASS - value: x - - name: EXTRA_ARGS - value: '--no-huge-pages --cpu-no-yield --max-cpu-usage=100 -t=1 --no-color' +resources: + - ../../base diff --git a/k8s/overlays/proxy/kustomization.yaml b/k8s/overlays/proxy/kustomization.yaml deleted file mode 100644 index 5afeb45..0000000 --- a/k8s/overlays/proxy/kustomization.yaml +++ /dev/null @@ -1,49 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - ../../base/deployment - - xmrig-proxy-svc.yaml - -patches: - - target: - group: apps - kind: Deployment - name: xmrig - patch: |- - - op: remove - path: /metadata/labels - - op: replace - path: /metadata/name - value: xmrig-proxy - - op: replace - path: /spec/selector/matchLabels/app - value: xmrig-proxy - - op: replace - path: /spec/template/metadata/labels/app - value: xmrig-proxy - - op: replace - path: /spec/template/spec/containers/0/name - value: xmrig-proxy - - op: replace - path: /spec/template/spec/containers/0/env/2 - value: - name: POOL_PASS - value: k8s-proxy - - op: replace - path: /spec/template/spec/containers/0/env/3 - value: - name: EXTRA_ARGS - value: '' - - op: replace - path: /spec/template/spec/containers/0/image - value: ghcr.io/codekow/xmrig-proxy:latest - - op: replace - path: /spec/template/spec/containers/0/resources - value: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 500m - memory: 128Mi diff --git a/openshift/machine-config/kustomization.yaml b/openshift/machine-config/kustomization.yaml index 2dadfad..ce87511 100644 --- a/openshift/machine-config/kustomization.yaml +++ b/openshift/machine-config/kustomization.yaml @@ -1,5 +1,5 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component resources: - burn-in-master-mc.yaml From 26206c2fe2953be4c7af43f2e67fc6f025e79302 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 16:20:24 -0600 Subject: [PATCH 03/13] update: version --- .github/workflows/publish-xmrig-cuda.yml | 2 +- .github/workflows/publish-xmrig-proxy.yml | 2 +- .github/workflows/publish-xmrig.yml | 2 +- README.md | 15 ++++++++------- k8s/overlays/cuda/kustomization.yaml | 2 +- xmrig/Dockerfile | 2 +- xmrig/Dockerfile.build | 4 ++-- xmrig/Dockerfile.build.cuda | 6 +++--- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/publish-xmrig-cuda.yml b/.github/workflows/publish-xmrig-cuda.yml index 94c3515..13297a0 100644 --- a/.github/workflows/publish-xmrig-cuda.yml +++ b/.github/workflows/publish-xmrig-cuda.yml @@ -23,7 +23,7 @@ on: # yamllint disable-line rule:truthy env: IMAGE_NAME: xmrig - IMAGE_VERSION: 6.22.0-cuda + IMAGE_VERSION: 6.22.2-cuda GHCR_REGISTRY: ghcr.io GHCR_USER: ${{ github.repository_owner }} GHCR_IMAGE: ${GHCR_REGISTRY}/${GHCR_USER}/${IMAGE_NAME} diff --git a/.github/workflows/publish-xmrig-proxy.yml b/.github/workflows/publish-xmrig-proxy.yml index a4a6967..c0354be 100644 --- a/.github/workflows/publish-xmrig-proxy.yml +++ b/.github/workflows/publish-xmrig-proxy.yml @@ -19,7 +19,7 @@ on: # yamllint disable-line rule:truthy env: IMAGE_NAME: xmrig-proxy - IMAGE_VERSION: 6.22.0 + IMAGE_VERSION: 6.22.2 GHCR_REGISTRY: ghcr.io GHCR_USER: ${{ github.repository_owner }} GHCR_IMAGE: ${GHCR_REGISTRY}/${GHCR_USER}/${IMAGE_NAME} diff --git a/.github/workflows/publish-xmrig.yml b/.github/workflows/publish-xmrig.yml index ac70023..e2b62dc 100644 --- a/.github/workflows/publish-xmrig.yml +++ b/.github/workflows/publish-xmrig.yml @@ -23,7 +23,7 @@ on: # yamllint disable-line rule:truthy env: IMAGE_NAME: xmrig - IMAGE_VERSION: 6.22.0 + IMAGE_VERSION: 6.22.2 GHCR_REGISTRY: ghcr.io GHCR_USER: ${{ github.repository_owner }} GHCR_IMAGE: ${GHCR_REGISTRY}/${GHCR_USER}/${IMAGE_NAME} diff --git a/README.md b/README.md index 1f907ed..0b38356 100644 --- a/README.md +++ b/README.md @@ -20,17 +20,17 @@ Running the container(s) without parameters ~~helps contribute $$~~ [sends metri ### Usage Docker / Podman -``` +```sh docker run -it --rm ghcr.io/codekow/xmrig ``` -``` +```sh podman run -it --rm ghcr.io/codekow/xmrig ``` Run meta miner -``` +```sh # see xmrig/bin/entrypoint.sh for more info. # this might get documented... :) podman run -it --rm ghcr.io/codekow/xmrig start_meta_miner @@ -44,7 +44,7 @@ For those of you who want to ~~get rich~~ [lose money](https://whattomine.com/co NOTE: This container does not run as `root` by default -``` +```sh export POOL_URL="Pool URL" export POOL_USER="Public Monero address" export POOL_PASS="Miner ID - optional for most pools" @@ -67,13 +67,14 @@ podman run \ Running processes as `root` comes with risks and rewards (like most things). If you are trying to: + - Improve hash rates (aka: performance) modifying [Model Specific Register](https://xmrig.com/docs/miner/randomx-optimization-guide/msr) (MSR) - Like [taking risks](https://xkcd.com/1252) - Have a history of making [bad choices](https://en.wikipedia.org/wiki/Hot_Pockets) Then the following is for you. -``` +```sh sudo podman run \ -it --rm \ --privileged \ @@ -94,13 +95,13 @@ XMR: For those with time to look at the code... -``` +```sh # ubuntu apt install podman apt install curl git make aspell python3.10-venv ``` -``` +```sh # run before submitting a PR make lint make build diff --git a/k8s/overlays/cuda/kustomization.yaml b/k8s/overlays/cuda/kustomization.yaml index 9434af0..70df4e1 100644 --- a/k8s/overlays/cuda/kustomization.yaml +++ b/k8s/overlays/cuda/kustomization.yaml @@ -26,7 +26,7 @@ patches: value: burn-in-cuda - op: replace path: /spec/template/spec/containers/0/image - value: ghcr.io/codekow/xmrig:6.22.0-cuda + value: ghcr.io/codekow/xmrig:6.22.2-cuda - op: replace path: /spec/template/spec/containers/0/env/3 value: diff --git a/xmrig/Dockerfile b/xmrig/Dockerfile index 5c9ac7e..aa6713c 100644 --- a/xmrig/Dockerfile +++ b/xmrig/Dockerfile @@ -10,7 +10,7 @@ LABEL \ RUN apk add --no-cache curl nodejs # setup: xmrig -ENV XMRIG_VERSION="6.22.0" +ENV XMRIG_VERSION="6.22.2" ARG XMRIG_HASH="aa866149d6234a1f00e344a702b719a0d6b4c40d3905d861ed536df1933a1d25" ARG XMRIG_URL="https://github.com/MoneroOcean/xmrig/releases/download/v${XMRIG_VERSION}-mo1/xmrig-v${XMRIG_VERSION}-mo1-lin64-compat.tar.gz" diff --git a/xmrig/Dockerfile.build b/xmrig/Dockerfile.build index fd7278d..cf276e8 100644 --- a/xmrig/Dockerfile.build +++ b/xmrig/Dockerfile.build @@ -1,7 +1,7 @@ # builder FROM docker.io/library/alpine:3 AS build -ARG XMRIG_VERSION='6.22.0' +ARG XMRIG_VERSION='6.22.2' # hadolint ignore=DL3018 RUN apk --no-cache add bash curl git make cmake libstdc++ gcc g++ automake libtool autoconf linux-headers @@ -42,7 +42,7 @@ LABEL \ RUN apk add --no-cache curl nodejs # setup: xmrig -ENV XMRIG_VERSION="6.22.0" +ENV XMRIG_VERSION="6.22.2" COPY --from=build --chown=root /root/xmrig/build/xmrig /usr/local/bin # setup: meta-miner diff --git a/xmrig/Dockerfile.build.cuda b/xmrig/Dockerfile.build.cuda index a88a6fb..510daeb 100644 --- a/xmrig/Dockerfile.build.cuda +++ b/xmrig/Dockerfile.build.cuda @@ -11,7 +11,7 @@ RUN apt install -y git wget curl build-essential cmake automake libtool autoconf update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100 -ARG CUDA_PLUGIN_VERSION="6.22.0" +ARG CUDA_PLUGIN_VERSION="6.22.2" WORKDIR /root RUN curl -sL https://github.com/xmrig/xmrig-cuda/archive/refs/tags/v${CUDA_PLUGIN_VERSION}.tar.gz | tar zxf - && \ @@ -23,7 +23,7 @@ RUN cmake .. -DCUDA_LIB=/usr/lib/x86_64-linux-gnu/stubs/libcuda.so -DCUDA_TOOLKI FROM docker.io/ubuntu:22.04 AS build -ARG XMRIG_VERSION="6.22.0" +ARG XMRIG_VERSION="6.22.2" # hadolint ignore=DL3018 RUN apt update && \ @@ -61,7 +61,7 @@ LABEL \ org.opencontainers.image.source="https://github.com/codekow/container-xmrig" # setup: xmrig -ENV XMRIG_VERSION="6.22.0" +ENV XMRIG_VERSION="6.22.2" RUN apt update && \ apt -y install --no-install-recommends curl wget ca-certificates nodejs && \ From 80abd57b4d413953ac8ca5b5acc2e77ac1c665c6 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 16:27:09 -0600 Subject: [PATCH 04/13] add: badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0b38356..90e67a4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # XMRig Container - Mine / Benchmark in Docker / Podman / Kubernetes +[![Publish xmrig](https://github.com/codekow/container-xmrig/actions/workflows/publish-xmrig.yml/badge.svg)](https://github.com/codekow/container-xmrig/actions/workflows/publish-xmrig.yml) +[![Publish xmrig-proxy](https://github.com/codekow/container-xmrig/actions/workflows/publish-xmrig-proxy.yml/badge.svg)](https://github.com/codekow/container-xmrig/actions/workflows/publish-xmrig-proxy.yml) +[![Publish xmrig-cuda](https://github.com/codekow/container-xmrig/actions/workflows/publish-xmrig-cuda.yml/badge.svg)](https://github.com/codekow/container-xmrig/actions/workflows/publish-xmrig-cuda.yml) + The purpose of this repo is to have a way to test limits and burn in hardware. Have you configured your security policies and resource limits effectively to curb user abuse? From d3eb62f84419b4459c0a9a95ac4115d2235cdf96 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 16:44:29 -0600 Subject: [PATCH 05/13] update: cuda --- .github/workflows/publish-xmrig-cuda.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/publish-xmrig-cuda.yml b/.github/workflows/publish-xmrig-cuda.yml index 13297a0..eac8586 100644 --- a/.github/workflows/publish-xmrig-cuda.yml +++ b/.github/workflows/publish-xmrig-cuda.yml @@ -45,14 +45,9 @@ jobs: - name: Prepare id: prep run: | - #VERSION=${GITHUB_REF#refs/tags/v} VERSION=${{ env.IMAGE_VERSION }} - MINOR=${VERSION%.*} - MAJOR=${VERSION%%.*} GHCR_IMAGE=${{ env.GHCR_IMAGE }} - #TAGS="${DOCKERHUB_IMAGE}:${MAJOR},${DOCKERHUB_IMAGE}:${MINOR}" - #TAGS="${TAGS},${DOCKERHUB_IMAGE}:${VERSION}" - TAGS="${TAGS},${GHCR_IMAGE}:${MAJOR},${GHCR_IMAGE}:${MINOR}" + TAGS="${GHCR_IMAGE}:latest-cuda" TAGS="${TAGS},${GHCR_IMAGE}:${VERSION}" echo ::set-output name=name::${{ env.IMAGE_NAME }} echo ::set-output name=tags::${TAGS} From 64640366fca14ca1d5b1c1ff8db5e06797bb48d7 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 16:47:54 -0600 Subject: [PATCH 06/13] fix: lint --- .wordlist-md | 3 ++- .yamllint | 1 + k8s/components/daemon-set/xmrig-ds.yaml | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.wordlist-md b/.wordlist-md index 018cf87..3a5f6cb 100644 --- a/.wordlist-md +++ b/.wordlist-md @@ -36,4 +36,5 @@ Nvidia cryptocurrency aspell venv -ubuntu \ No newline at end of file +ubuntu +cuda diff --git a/.yamllint b/.yamllint index f435d89..1e0cf1d 100644 --- a/.yamllint +++ b/.yamllint @@ -1,6 +1,7 @@ extends: default rules: + comments-indentation: disable document-start: disable line-length: disable indentation: diff --git a/k8s/components/daemon-set/xmrig-ds.yaml b/k8s/components/daemon-set/xmrig-ds.yaml index 3acf609..b735cdc 100644 --- a/k8s/components/daemon-set/xmrig-ds.yaml +++ b/k8s/components/daemon-set/xmrig-ds.yaml @@ -44,10 +44,10 @@ spec: image: ghcr.io/codekow/xmrig:latest resources: limits: - # cpu: '5' - # memory: 2400Mi - # requests: - # memory: 2400Mi + # cpu: '5' + # memory: 2400Mi + # requests: + # memory: 2400Mi volumes: - name: empty emptyDir: {} From d2c8b1a322d4c57b8d0ae9d33d947d3e1735f820 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 17:21:02 -0600 Subject: [PATCH 07/13] update: lint --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 911ee2a..f5bcff2 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ SHELL=/bin/bash build: lint pre-build xmrig-build xmrig-build-cuda xmrig-proxy-build post-build -lint: venv lint-yaml lint-spellcheck +lint: venv lint-yaml lint-spellcheck lint-kustomize pre-build: @@ -49,6 +49,9 @@ push: lint-yaml: $(VENV)/yamllint -c .yamllint . +lint-kustomize: + scripts/validate_kustomize.sh + lint-spellcheck: $(VENV)/pyspelling -c .spellcheck.yaml From 6f642a2ecb57b05c26da0acf1ddf109e00d39ed6 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 17:21:09 -0600 Subject: [PATCH 08/13] add: quota --- k8s/base/kustomization.yaml | 3 +++ k8s/components/quota/kustomization.yaml | 5 +++++ k8s/components/quota/quota.yaml | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 k8s/components/quota/kustomization.yaml create mode 100644 k8s/components/quota/quota.yaml diff --git a/k8s/base/kustomization.yaml b/k8s/base/kustomization.yaml index dca4a51..53b476e 100644 --- a/k8s/base/kustomization.yaml +++ b/k8s/base/kustomization.yaml @@ -1,5 +1,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization +components: + - ../components/quota + resources: - namespace.yaml diff --git a/k8s/components/quota/kustomization.yaml b/k8s/components/quota/kustomization.yaml new file mode 100644 index 0000000..34caf67 --- /dev/null +++ b/k8s/components/quota/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: + - quota.yaml diff --git a/k8s/components/quota/quota.yaml b/k8s/components/quota/quota.yaml new file mode 100644 index 0000000..6563068 --- /dev/null +++ b/k8s/components/quota/quota.yaml @@ -0,0 +1,22 @@ +--- +apiVersion: v1 +kind: ResourceQuota +metadata: + name: quota-compute +spec: + hard: + # requests.cpu: '1' + # requests.memory: 1Gi + limits.cpu: '32' + limits.memory: 128Gi + requests.nvidia.com/gpu: '0' +--- +apiVersion: v1 +kind: ResourceQuota +metadata: + name: quota-objects +spec: + hard: + count/sealedsecrets.bitnami.com: '0' + count/cronjobs.batch: '4' + count/daemonsets.apps: '0' From e0b76d156eb2f33fa947ae59ccf889bb10dcbe37 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 17:27:20 -0600 Subject: [PATCH 09/13] update: hash --- xmrig/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmrig/Dockerfile b/xmrig/Dockerfile index aa6713c..5a5650a 100644 --- a/xmrig/Dockerfile +++ b/xmrig/Dockerfile @@ -11,7 +11,7 @@ RUN apk add --no-cache curl nodejs # setup: xmrig ENV XMRIG_VERSION="6.22.2" -ARG XMRIG_HASH="aa866149d6234a1f00e344a702b719a0d6b4c40d3905d861ed536df1933a1d25" +ARG XMRIG_HASH="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ARG XMRIG_URL="https://github.com/MoneroOcean/xmrig/releases/download/v${XMRIG_VERSION}-mo1/xmrig-v${XMRIG_VERSION}-mo1-lin64-compat.tar.gz" RUN curl -sL "${XMRIG_URL}" -o bin.tgz && \ From 928238cdb83c92c4e4896ad0cd953a1a1264b0ce Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 14 Nov 2024 17:35:08 -0600 Subject: [PATCH 10/13] fix: cuda --- xmrig/Dockerfile.build.cuda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmrig/Dockerfile.build.cuda b/xmrig/Dockerfile.build.cuda index 510daeb..81c3cc7 100644 --- a/xmrig/Dockerfile.build.cuda +++ b/xmrig/Dockerfile.build.cuda @@ -11,7 +11,7 @@ RUN apt install -y git wget curl build-essential cmake automake libtool autoconf update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100 -ARG CUDA_PLUGIN_VERSION="6.22.2" +ARG CUDA_PLUGIN_VERSION="6.22.0" WORKDIR /root RUN curl -sL https://github.com/xmrig/xmrig-cuda/archive/refs/tags/v${CUDA_PLUGIN_VERSION}.tar.gz | tar zxf - && \ From 40c953c16061b3e636851ff9480f212a11d459ce Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Sat, 16 Nov 2024 18:30:25 -0600 Subject: [PATCH 11/13] update: gh actions --- .github/workflows/publish-xmrig-cuda.yml | 22 +++++++++------------- .github/workflows/publish-xmrig-proxy.yml | 2 -- .github/workflows/publish-xmrig.yml | 14 ++++---------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/.github/workflows/publish-xmrig-cuda.yml b/.github/workflows/publish-xmrig-cuda.yml index eac8586..3e8a011 100644 --- a/.github/workflows/publish-xmrig-cuda.yml +++ b/.github/workflows/publish-xmrig-cuda.yml @@ -15,11 +15,11 @@ on: # yamllint disable-line rule:truthy paths: - xmrig/** - .github/workflows/** - # pull_request: - # branches: ["main"] - # paths: - # - xmrig/** - # - .github/workflows/** + pull_request: + branches: ["main"] + paths: + - xmrig/** + - .github/workflows/** env: IMAGE_NAME: xmrig @@ -27,9 +27,6 @@ env: GHCR_REGISTRY: ghcr.io GHCR_USER: ${{ github.repository_owner }} GHCR_IMAGE: ${GHCR_REGISTRY}/${GHCR_USER}/${IMAGE_NAME} - # DOCKERHUB_REGISTRY=docker.io - # DOCKERHUB_USER: ${{ github.repository_owner }} - jobs: publish: @@ -49,11 +46,10 @@ jobs: GHCR_IMAGE=${{ env.GHCR_IMAGE }} TAGS="${GHCR_IMAGE}:latest-cuda" TAGS="${TAGS},${GHCR_IMAGE}:${VERSION}" - echo ::set-output name=name::${{ env.IMAGE_NAME }} - echo ::set-output name=tags::${TAGS} - echo ::set-output name=version::${VERSION} - #echo ::set-output name=dockerhub_image::${DOCKERHUB_IMAGE} - echo ::set-output name=ghcr_image::${GHCR_IMAGE} + echo "name=${{ env.IMAGE_NAME }}" >> $GITHUB_OUTPUT + echo "tags=${TAGS}" >> $GITHUB_OUTPUT + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "ghcr_image=${GHCR_IMAGE}" >> $GITHUB_OUTPUT # https://github.com/docker/login-action - name: Log into GitHub Container Registry diff --git a/.github/workflows/publish-xmrig-proxy.yml b/.github/workflows/publish-xmrig-proxy.yml index c0354be..caf12e6 100644 --- a/.github/workflows/publish-xmrig-proxy.yml +++ b/.github/workflows/publish-xmrig-proxy.yml @@ -23,8 +23,6 @@ env: GHCR_REGISTRY: ghcr.io GHCR_USER: ${{ github.repository_owner }} GHCR_IMAGE: ${GHCR_REGISTRY}/${GHCR_USER}/${IMAGE_NAME} - # DOCKERHUB_REGISTRY=docker.io - # DOCKERHUB_USER: ${{ github.repository_owner }} jobs: diff --git a/.github/workflows/publish-xmrig.yml b/.github/workflows/publish-xmrig.yml index e2b62dc..a14b680 100644 --- a/.github/workflows/publish-xmrig.yml +++ b/.github/workflows/publish-xmrig.yml @@ -27,9 +27,6 @@ env: GHCR_REGISTRY: ghcr.io GHCR_USER: ${{ github.repository_owner }} GHCR_IMAGE: ${GHCR_REGISTRY}/${GHCR_USER}/${IMAGE_NAME} - # DOCKERHUB_REGISTRY=docker.io - # DOCKERHUB_USER: ${{ github.repository_owner }} - jobs: publish: @@ -50,15 +47,12 @@ jobs: MINOR=${VERSION%.*} MAJOR=${VERSION%%.*} GHCR_IMAGE=${{ env.GHCR_IMAGE }} - #TAGS="${DOCKERHUB_IMAGE}:${MAJOR},${DOCKERHUB_IMAGE}:${MINOR}" - #TAGS="${TAGS},${DOCKERHUB_IMAGE}:${VERSION},${DOCKERHUB_IMAGE}:latest" TAGS="${TAGS},${GHCR_IMAGE}:${MAJOR},${GHCR_IMAGE}:${MINOR}" TAGS="${TAGS},${GHCR_IMAGE}:${VERSION},${GHCR_IMAGE}:latest" - echo ::set-output name=name::${{ env.IMAGE_NAME }} - echo ::set-output name=tags::${TAGS} - echo ::set-output name=version::${VERSION} - #echo ::set-output name=dockerhub_image::${DOCKERHUB_IMAGE} - echo ::set-output name=ghcr_image::${GHCR_IMAGE} + echo "name=${{ env.IMAGE_NAME }}" >> $GITHUB_OUTPUT + echo "tags=${TAGS}" >> $GITHUB_OUTPUT + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "ghcr_image=${GHCR_IMAGE}" >> $GITHUB_OUTPUT # https://github.com/docker/login-action - name: Log into GitHub Container Registry From bcb8a71860e6748691eb35f8b5e163001ddf3045 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Sat, 16 Nov 2024 18:37:59 -0600 Subject: [PATCH 12/13] update: version --- xmrig-proxy/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmrig-proxy/Dockerfile b/xmrig-proxy/Dockerfile index a259fb2..46212fe 100644 --- a/xmrig-proxy/Dockerfile +++ b/xmrig-proxy/Dockerfile @@ -15,8 +15,8 @@ ENV \ RUN apk add --no-cache curl # setup: xmrig-proxy -ENV XMRIG_PROXY_VERSION="6.21.0" -ARG XMRIG_PROXY_HASH="ffd1d5f166d13a772f566392054edcfc3b1fa9d0a7cf6cd52bc0f57f9b93c8dc" +ENV XMRIG_PROXY_VERSION="6.22.0" +ARG XMRIG_PROXY_HASH="e132801753b4c23904238ac3b9ff6f74468dea2113c4eaccc9e0341c86c7a4c1" ARG XMRIG_PROXY_URL="https://github.com/xmrig/xmrig-proxy/releases/download/v${XMRIG_PROXY_VERSION}/xmrig-proxy-${XMRIG_PROXY_VERSION}-linux-static-x64.tar.gz" RUN curl -sL "${XMRIG_PROXY_URL}" -o bin.tgz && \ From c80fe44cacb3b93afaa608f3786023f1426162d8 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Sat, 16 Nov 2024 18:40:38 -0600 Subject: [PATCH 13/13] update: gh actions --- .github/workflows/publish-xmrig-proxy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-xmrig-proxy.yml b/.github/workflows/publish-xmrig-proxy.yml index caf12e6..2bf4ecd 100644 --- a/.github/workflows/publish-xmrig-proxy.yml +++ b/.github/workflows/publish-xmrig-proxy.yml @@ -12,10 +12,12 @@ on: # yamllint disable-line rule:truthy branches: ["main"] # Publish semver tags as releases. tags: ["v*.*.*"] - paths: ["xmrig-proxy/**"] + paths: + - xmrig-proxy/** pull_request: branches: ["main"] - paths: ["xmrig-proxy/**"] + paths: + - xmrig-proxy/** env: IMAGE_NAME: xmrig-proxy