Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates: refactor kustomize #92

Merged
merged 13 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions .github/workflows/publish-xmrig-cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@ 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
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}
# DOCKERHUB_REGISTRY=docker.io
# DOCKERHUB_USER: ${{ github.repository_owner }}


jobs:
publish:
Expand All @@ -45,20 +42,14 @@ 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}
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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish-xmrig-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ 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
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}
# DOCKERHUB_REGISTRY=docker.io
# DOCKERHUB_USER: ${{ github.repository_owner }}


jobs:
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/publish-xmrig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ 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}
# DOCKERHUB_REGISTRY=docker.io
# DOCKERHUB_USER: ${{ github.repository_owner }}


jobs:
publish:
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .wordlist-md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ Nvidia
cryptocurrency
aspell
venv
ubuntu
ubuntu
cuda
1 change: 1 addition & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends: default

rules:
comments-indentation: disable
document-start: disable
line-length: disable
indentation:
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -49,6 +49,9 @@ push:
lint-yaml:
$(VENV)/yamllint -c .yamllint .

lint-kustomize:
scripts/validate_kustomize.sh

lint-spellcheck:
$(VENV)/pyspelling -c .spellcheck.yaml

Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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?
Expand All @@ -20,17 +24,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
Expand All @@ -44,7 +48,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"
Expand All @@ -67,13 +71,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 \
Expand All @@ -94,13 +99,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
Expand Down
5 changes: 0 additions & 5 deletions k8s/base/deployment/kustomization.yaml

This file was deleted.

5 changes: 4 additions & 1 deletion k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

components:
- ../components/quota

resources:
- xmrig-ds.yaml
- namespace.yaml
2 changes: 1 addition & 1 deletion k8s/base/namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions k8s/components/daemon-set/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

resources:
- xmrig-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions k8s/components/deployment/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
25 changes: 25 additions & 0 deletions k8s/components/proxy-miner/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions k8s/components/proxy/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading