AWS EKS Cluster with GPU instances and miners for Ethereum mining

I’ll try out different options and different miners to find a way to make profitable ETH mining. Benchmarking different instance types and mining clients.

I will start by saying that so far, I am still at a loss of 12% of my investment in AWS infrastructure while 1 ETH = $ 1,750.50

Calculator: https://www.cryptocompare.com/mining/calculator/eth?HashingPower=55&HashingUnit=MH%2Fs&PowerConsumption=360&CostPerkWh=1&MiningPoolFee=1

But for the purpose of study, a testing process as detailed below can be useful. Of course new tests and improvements very welcome!!

Full code can be cloned from GIT repository: https://github.com/Gershon-A/AWS-EKS-Cluster-with-GPU-instances-and-miners.git

✓ awscli v2

✓ eksctl 0.35

✓ kubectl v1.19.1

✓ aws credentials to access AWS account

✓ User profile set properly for setup EKS cluster

  1. We start from g4dn.xlarge, change it in 01-cluster.yaml to feet your needs. (so far, this is the best-performed instance type)

2. Create cluster and node group ( 2 instances)

eksctl create cluster -f 01-cluster.yaml

3. Add created cluster to environment.

aws eks update-kubeconfig --name cluster1 --region us-east-1

4. Verify nodes are ready to use

kubectl get nodes -o wide
  1. After GPU nodes join your cluster, you must apply the NVIDIA device plugin for Kubernetes as a DaemonSet on your cluster with the following command.
kubectl apply -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.7.3/nvidia-device-plugin.yml

2. Verify

kubectl get nodes "-o=custom-columns=NAME:.metadata.name,GPU:.status.allocatable.nvidia\.com/gpu"
NAME GPU
ip-192-168-2-148.ec2.internal 1
ip-192-168-31-129.ec2.internal 1

3. Check if driver installed:

kubectl.exe get pods
NAME READY STATUS RESTARTS AGE
t-rex-5549bfccdb-rbp5d 1/1 Running 0 6h12m
t-rex-5549bfccdb-wnvch 1/1 Running 0 6h12m

kubectl exec --stdin --tty t-rex-5549bfccdb-rbp5d -- nvidia-smi

# nvidia-smi
Thu Jan 7 20:37:42 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.51.06 Driver Version: 450.51.06 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla T4 Off | 00000000:00:1E.0 Off | 0 |
| N/A 43C P0 70W / 70W | 4282MiB / 15109MiB | 100% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+

Currently, 2 miners were tested, etherminer and t-rex.

  1. ethminer

Worked with the ethermine.org pool. Deploy the mainer Add to environment following:

▹This worker name will be shown on https://ethermine.org/

export WORKER_NAME=ethminer-$HOSTNAME

▹This is a “Miner Address” on https://ethermine.org/ e.g ERC20 address You get the earning.

export ETH_WALLET=0x1Fa418c70C5f14b21D00c242Bf369A875F129d12

✓ Deploy

cat "ethminer-deployment.yaml" | sed "s/{{WORKER_NAME}}/$WORKER_NAME/g" | sed "s/{{ETH_WALLET}}/$ETH_WALLET/g" | kubectl apply -f -

✓ Check log to see all working as expected

kubectl logs ethminer-6888dd59cc-q2z6w

✓ To Remove after testing

kubectl.exe delete deployment ethminer

Add to environment following

▹This is a “Miner Address” on https://ethermine.org/ e.g ERC20 address You get the earning.

export ETH_WALLET=0x1Fa418c70C5f14b21D00c242Bf369A875F129d12

▹Connect to preferred pull. Chose pool closet to AWS region e.g us-east-1

export POOL=us1.ethermine.org:4444

✓ Deploy

cat "t-rex-deployment.yaml" | sed "s/{{POOL}}/$POOL/g" | sed "s/{{ETH_WALLET}}/$ETH_WALLET/g" | kubectl apply -f -

✓ Benchmark

kubectl exec --stdin --tty t-rex-5549bfccdb-rbp5d -- ./t-rex --benchmark -a ethash -o stratum+tcp://$POLL -u $ETH_WALLET -p x -w $HOSTNAME --mt 4 --api-bind-telnet 0 --api-bind-http 0 --cpu-priority 5

*You can start port forwarding and have a nice dashboard:

The profit result’s so far:

https://aws.amazon.com/ec2/spot/pricing/

These are the g- and p- series instances: g2, g3, and g4 types are generalized GPU instance types with additional optimizations for graphics-intensive applications like gaming, p2 and p3 instances are optimized for CUDA and machine learning applications

The winner is g4dn.xlarge with hashrate 25.51Mh per pod, while the spot price is $0.157 per Hour

pod log show 25.51 Mh

pod log show 25.76Mh/s

pretty much as etherminer

Cleanup

eksctl delete cluster -f 01-cluster.yaml

Or only specific node group:

eksctl delete nodegroup --cluster=cluster-1 --name=gpu --region=us-east-1

In conclusion

We still see a loss here, but at a price above 1 ETH = $ 1,850 is already starting to pay off.

New tests and improvements are very welcome!!

Full code can be cloned from GIT repository: https://github.com/Gershon-A/AWS-EKS-Cluster-with-GPU-instances-and-miners.git

Thank You!