Merge pull request #249 from truenas/NAS-113095

NAS-113095 / 22.02 / Resolve "Machinaris Chart v0.6.x (new arch requires multiple containers)"
This commit is contained in:
M. Rehan
2021-12-10 02:21:31 +05:00
committed by GitHub
15 changed files with 2213 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
# OWNERS file for Kubernetes
OWNERS

View File

@@ -0,0 +1,17 @@
apiVersion: v1
appVersion: v0.6.7
dependencies:
- name: common
repository: file://../../../library/common/2112.0.0
version: 2112.0.0
description: Global, Versioned, peer-to-peer filesystem.
home: https://github.com/guydavis/machinaris
icon: https://raw.githubusercontent.com/guydavis/machinaris/main/web/static/favicon.ico
keywords:
- storage
- crypto
- blockchain
name: machinaris
sources:
- https://github.com/guydavis/machinaris
version: 1.1.0

71
test/machinaris/1.1.0/README.md Executable file
View File

@@ -0,0 +1,71 @@
Machinaris
=====
[MACHINARIS](https://github.com/guydavis/machinaris) is an easy-to-use WebUI for Chia plotting and farming. This includes Chia, Plotman, MadMax, Chiadog under main node along with various coin-forks which can be enabled conditionally.
Coins include Cactus, Chives, CrypoDoge, Flax, Flora, HDDCoin, Maize, NChain, StaiCoin, Stor and BTCGreen.
Introduction
------------
This chart bootstraps MACHINARIS deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
# Machinaris Defaults
This section contains information about the defaults of Machinaris application for visibility.
## 1. Environment Variables
Following are the default environment variables for Machinaris main node and the coin forks.
### Machinaris Node
Machinaris main node comes with following default environment variables:
| Variable | Default Value | Description |
| ---------------- | ----------------------------------------------------- | --------------------- |
| TZ | Same as to User selected Timezone | Timezone information |
| worker_address | Same as to LAN IP address | Worker Address |
| blockchains | chia | Block Chain |
| plots_dir | Same as to User selected plots volume | Plots Directory |
| mode | fullnode | Machinaris Mode |
These values can be overridden while configuring Machinaris application.
### Coin Forks
Coin forks also come with a set of default environment variables:
| Variable | Default Value | Description |
| ---------------- | ----------------------------------------------------- | --------------------- |
| TZ | Same as to User selected Timezone | Timezone information |
| worker_address | Same as to LAN IP address | Worker Address |
| blockchains | chia | BlockChain |
| plots_dir | Same as to User selected plots volume | Plots Directory |
| mode | fullnode | Machinaris Mode |
| controller_host| Same as to LAN IP address | Controller Host |
| worker_api_port| Coin's Workload REST API Port | Worker API Port |
These defaults can be overridden for each coin fork when you enable them through Machinaris application configuration.
## 2. Volumes
Before getting to defaults, please take the following note:
>
>If Custom Host Path is not enabled for a Volume Configuration then, application will use ix-volumes and create datasets inside for Host Path by default.
>
>The path for ix-volumes has the following composition:
>```
>/mnt/<pool_name>/ix-applications/releases/<application_name>/volumes/ix-volumes/
>```
>And with the dataset inside, would be like:
>```
>/mnt/<pool_name>/ix-applications/releases/<application_name>/volumes/ix-volumes/><dataset_name>
>```
>
Following are the Volume Configurations for Machinaris main node & the coin-forks by default:
| Volume | hostPath (default value) | mountPath in container | Description |
| ---------------------- | ----------------------------------------------------- | ----------------------- | ----------------------------------------------- |
| `config` | `<ix-volumes>/config` | `/root/.chia` | Chia config for main node |
| `plots` | `<ix-volumes>/plots` | `/plots` | Plots volume for main node & coin forks |
| `plotting` | `<ix-volumes>/plotting` | `/plotting` | Plotting temp volume for main node & coin forks |
| `<coinName>-config` | `<ix-volumes>/<coinName>-config` | `/root/.chia` | Chia config for each of the coin-fork containers|
Where `<ix-volumes>` is `/mnt/<pool_name>/ix-applications/releases/<application_name>/volumes/ix_volumes/` and `<coinName>` is one of the following: `[ cactus, chives, crypodoge, flax, flora, hddcoin, maize, nchain, staicoin, stor, btcgreen ]`.

View File

@@ -0,0 +1,66 @@
Machinaris
=====
[MACHINARIS](https://github.com/guydavis/machinaris) is an easy-to-use WebUI for Chia plotting and farming. This includes Chia, Plotman, MadMax, Chiadog under main node along with various coin-forks which can be enabled conditionally.
Coins include Cactus, Chives, CrypoDoge, Flax, Flora, HDDCoin, Maize, NChain, StaiCoin, Stor and BTCGreen.
# Machinaris Defaults
This section contains information about the defaults of Machinaris application for visibility.
## 1. Environment Variables
Following are the default environment variables for Machinaris main node and the coin forks.
### Machinaris Node
Machinaris main node comes with following default environment variables:
| Variable | Default Value | Description |
| ---------------- | ----------------------------------------------------- | --------------------- |
| TZ | Same as to User selected Timezone | Timezone information |
| worker_address | Same as to LAN IP address | Worker Address |
| blockchains | chia | Block Chain |
| plots_dir | Same as to User selected plots volume | Plots Directory |
| mode | fullnode | Machinaris Mode |
These values can be overridden while configuring Machinaris application.
### Coin Forks
Coin forks also come with a set of default environment variables:
| Variable | Default Value | Description |
| ---------------- | ----------------------------------------------------- | --------------------- |
| TZ | Same as to User selected Timezone | Timezone information |
| worker_address | Same as to LAN IP address | Worker Address |
| blockchains | chia | BlockChain |
| plots_dir | Same as to User selected plots volume | Plots Directory |
| mode | fullnode | Machinaris Mode |
| controller_host| Same as to LAN IP address | Controller Host |
| worker_api_port| Coin's Workload REST API Port | Worker API Port |
These defaults can be overridden for each coin fork when you enable them through Machinaris application configuration.
## 2. Volumes
Before getting to defaults, please take the following note:
>
>If Custom Host Path is not enabled for a Volume Configuration then, application will use ix-volumes and create datasets inside for Host Path by default.
>
>The path for ix-volumes has the following composition:
>```
>/mnt/<pool_name>/ix-applications/releases/<application_name>/volumes/ix-volumes/
>```
>And with the dataset inside, would be like:
>```
>/mnt/<pool_name>/ix-applications/releases/<application_name>/volumes/ix-volumes/><dataset_name>
>```
>
Following are the Volume Configurations for Machinaris main node & the coin-forks by default:
| Volume | hostPath (default value) | mountPath in container | Description |
| ---------------------- | ----------------------------------------------------- | ----------------------- | ----------------------------------------------- |
| `config` | `<ix-volumes>/config` | `/root/.chia` | Chia config for main node |
| `plots` | `<ix-volumes>/plots` | `/plots` | Plots volume for main node & coin forks |
| `plotting` | `<ix-volumes>/plotting` | `/plotting` | Plotting temp volume for main node & coin forks |
| `<coinName>-config` | `<ix-volumes>/<coinName>-config` | `/root/.chia` | Chia config for each of the coin-fork containers|
Where `<ix-volumes>` is `/mnt/<pool_name>/ix-applications/releases/<application_name>/volumes/ix_volumes/` and `<coinName>` is one of the following: `[ cactus, chives, crypodoge, flax, flora, hddcoin, maize, nchain, staicoin, stor, btcgreen ]`.

Binary file not shown.

View File

@@ -0,0 +1,180 @@
image:
pullPolicy: IfNotPresent
repository: ghcr.io/guydavis/machinaris
tag: v0.6.7
updateStrategy: Recreate
ports:
- name: chia-network
protocol: TCP
containerPort: 8444
hostPort: 8444
- name: machinaris-ui
protocol: TCP
containerPort: 8926
- name: machinaris-api
protocol: TCP
containerPort: 8927
hostPort: 8927
- protocol: TCP
containerPort: 8447
hostPort: 8447
coins:
- cactus
- chives
- cryptodoge
- flax
- flora
- hddcoin
- maize
- nchain
- staicoin
- stor
- btcgreen
cactus:
apiPort: 8936
ports:
- name: api
protocol: TCP
containerPort: 8936
hostPort: 8936
- name: blockchain
protocol: TCP
containerPort: 11444
hostPort: 11444
- name: farming
protocol: TCP
containerPort: 11447
hostPort: 11447
chives:
apiPort: 8931
ports:
- name: api
protocol: TCP
containerPort: 8931
- name: blockchain
protocol: TCP
containerPort: 9699
- name: farming
protocol: TCP
containerPort: 9647
cryptodoge:
apiPort: 8937
ports:
- name: api
protocol: TCP
containerPort: 8937
- name: blockchain
protocol: TCP
containerPort: 15994
- name: farming
protocol: TCP
containerPort: 16895
flax:
apiPort: 8928
ports:
- name: api
protocol: TCP
containerPort: 8928
- name: blockchain
protocol: TCP
containerPort: 6888
- name: farming
protocol: TCP
containerPort: 6885
flora:
apiPort: 8932
ports:
- name: api
protocol: TCP
containerPort: 8932
- name: blockchain
protocol: TCP
containerPort: 18644
- name: farming
protocol: TCP
containerPort: 18647
hddcoin:
apiPort: 8930
ports:
- name: api
protocol: TCP
containerPort: 8930
- name: blockchain
protocol: TCP
containerPort: 28444
- name: farming
protocol: TCP
containerPort: 28447
maize:
apiPort: 8933
ports:
- name: api
protocol: TCP
containerPort: 8933
- name: blockchain
protocol: TCP
containerPort: 8644
- name: farming
protocol: TCP
containerPort: 8647
nchain:
apiPort: 8929
ports:
- name: api
protocol: TCP
containerPort: 8929
- name: blockchain
protocol: TCP
containerPort: 58445
- name: farming
protocol: TCP
containerPort: 38447
staicoin:
apiPort: 8934
ports:
- name: api
protocol: TCP
containerPort: 8934
- name: blockchain
protocol: TCP
containerPort: 1999
- name: farming
protocol: TCP
containerPort: 1692
stor:
apiPort: 8935
ports:
- name: api
protocol: TCP
containerPort: 8935
- name: blockchain
protocol: TCP
containerPort: 8668
- name: farming
protocol: TCP
containerPort: 8337
btcgreen:
apiPort: 8938
ports:
- name: api
protocol: TCP
containerPort: 8938
- name: blockchain
protocol: TCP
containerPort: 9282
- name: farming
protocol: TCP
containerPort: 18655

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://../../../library/common/2112.0.0
version: 2112.0.0
digest: sha256:47115d9b91afe42c8537dcf0fd8224f2f7d1c775f9ff860efa68a6b57d17d1c0
generated: "2021-12-06T19:55:04.707082+05:00"

View File

@@ -0,0 +1,40 @@
{{/*
Init container for coin deployments
*/}}
{{- define "initContainers" -}}
{{- $values := . -}}
{{- $machinarisApiUrl := (printf "http://%v:%v/" $values.nodeIP $values.apiPort) -}}
initContainers:
- name: init-{{ $values.coinName }}
image: curlimages/curl:7.80.0
command: ['sh', '-c', 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' {{ $machinarisApiUrl }})" != "200" ]]; do echo "Machinaris is offline. Retrying in 2 seconds.." && sleep 2; done']
{{- end -}}
{{/*
Evironment variables (support for overrides)
*/}}
{{- define "allEnvironmentVariables" -}}
{{- $finalEnvironmentVariables := .defaultEnv -}}
{{- range $env := .environmentVariables -}}
{{- $_ := set $finalEnvironmentVariables $env.name $env.value -}}
{{- end -}}
env:
{{- range $envVariableName := keys $finalEnvironmentVariables }}
- name: {{ $envVariableName | quote }}
value: {{ (get $finalEnvironmentVariables $envVariableName) | quote }}
{{- end -}}
{{- end -}}
{{/*
Resource limits
*/}}
{{- define "resourceLimits" -}}
{{- if .Values.enableResourceLimits -}}
resources:
limits:
cpu: {{ .Values.cpuLimit }}
memory: {{ .Values.memLimit }}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,46 @@
{{- $ref := . }}
{{- range $coinName := $ref.Values.coins }}
{{- $coinEnabled := get $ref.Values (printf "%vEnabled" $coinName) }}
{{- if $coinEnabled }}
{{- $coin := get $ref.Values $coinName }}
{{- $_ := set $ref "common" (dict "nameSuffix" $coinName) }}
{{- $_ := set $coin.volumeMounts "plots" $ref.Values.appVolumeMounts.plots }}
{{- $_ := set $coin.volumeMounts "plotting" $ref.Values.appVolumeMounts.plotting }}
apiVersion: {{ template "common.capabilities.deployment.apiVersion" $ref }}
kind: Deployment
metadata:
name: {{ template "common.names.fullname" $ref }}
labels: {{ include "common.labels" $ref | nindent 4 }}
spec:
strategy:
type: {{ $ref.Values.updateStrategy }}
selector:
matchLabels: {{ include "common.labels.selectorLabels" $ref | nindent 6 }}
template:
metadata:
name: {{ template "common.names.fullname" $ref }}
labels: {{ include "common.labels.selectorLabels" $ref | nindent 8 }}
spec:
hostNetwork: true
{{- include "initContainers" (dict "nodeIP" $ref.Values.nodeIP "apiPort" $ref.Values.machinarisApiPort "coinName" $coinName ) | nindent 6 }}
containers:
- name: {{ $ref.Chart.Name }}
{{- include "resourceLimits" $ref | nindent 10 }}
tty: true
{{ include "common.containers.imageConfig" (dict "repository" $ref.Values.image.repository "tag" $ref.Values.image.tag "pullPolicy" $ref.Values.image.pullPolicy "postfix" $ref.common.nameSuffix) | nindent 10 }}
{{ include "common.containers.configurePorts" $coin | nindent 10 }}
volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" (dict "appVolumeMounts" $coin.volumeMounts "ixVolumes" $ref.Values.ixVolumes) | nindent 12 }}
{{ range $index, $hostPathConfiguration := $ref.Values.extraAppVolumeMounts }}
- name: extrappvolume-{{ $index }}
mountPath: {{ $hostPathConfiguration.mountPath }}
{{ end }}
{{ include "allEnvironmentVariables" (dict "defaultEnv" (dict "TZ" $ref.Values.timezone "worker_address" $ref.Values.nodeIP "controller_host" $ref.Values.nodeIP "worker_api_port" $coin.apiPort "blockchains" $coinName "plots_dir" $ref.Values.appVolumeMounts.plots.mountPath "mode" "fullnode") "environmentVariables" $coin.environmentVariables) | nindent 10 }}
volumes: {{ include "common.storage.configureAppVolumes" (dict "appVolumeMounts" $coin.volumeMounts "ixVolumes" $ref.Values.ixVolumes) | nindent 8 }}
{{ range $index, $hostPathConfiguration := $ref.Values.extraAppVolumeMounts }}
- name: extrappvolume-{{ $coinName }}-{{ $index }}
hostPath:
path: {{ $hostPathConfiguration.hostPath }}
{{ end }}
---
{{- end }}
{{- end }}

View File

@@ -0,0 +1,38 @@
{{- if hasKey . "common" }}
{{- $_ := unset .common "nameSuffix" }}
{{- end }}
apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "common.names.fullname" . }}
labels: {{ include "common.labels" . | nindent 4 }}
spec:
strategy:
type: {{ .Values.updateStrategy }}
selector:
matchLabels: {{ include "common.labels.selectorLabels" . | nindent 6 }}
template:
metadata:
name: {{ template "common.names.fullname" . }}
labels: {{ include "common.labels.selectorLabels" . | nindent 8 }}
spec:
# FIXME: Let's please remove hostnetwork when upstream hostport issue is sorted out with kube-router
hostNetwork: true
containers:
- name: {{ .Chart.Name }}
{{- include "resourceLimits" . | nindent 10 }}
tty: true
{{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
{{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
- name: extrappvolume-{{ $index }}
mountPath: {{ $hostPathConfiguration.mountPath }}
{{ end }}
{{ include "common.containers.configurePorts" .Values | nindent 10 }}
{{ include "allEnvironmentVariables" (dict "defaultEnv" (dict "TZ" .Values.timezone "worker_address" .Values.nodeIP "blockchains" "chia" "plots_dir" .Values.appVolumeMounts.plots.mountPath "mode" "fullnode") "environmentVariables" .Values.environmentVariables) | nindent 10 }}
volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
{{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
- name: extrappvolume-{{ $index }}
hostPath:
path: {{ $hostPathConfiguration.hostPath }}
{{ end }}

View File

@@ -0,0 +1,6 @@
{{ $svc := .Values }}
{{ $ports := list }}
{{ $ports = mustAppend $ports (dict "name" "pms" "port" $svc.machinaris_ui_port "nodePort" $svc.machinaris_ui_port "targetPort" "machinaris-ui") }}
{{ $params := . }}
{{ $_ := set $params "commonService" (dict "ports" $ports "type" "NodePort" ) }}
{{ include "common.classes.service" $params }}

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ .Release.Name }}-cactus-deployment-test"
annotations:
"helm.sh/hook": test
spec:
hostNetwork: true
restartPolicy: Never
containers:
- name: {{ .Release.Name }}-cactus-deployment-test
image: busybox
# Note: Adding sleep 15, as even when cactus pod status is ready, I've seen API
# taking a few seconds to be live and running.
command: ['sh', '-c', 'sleep 30 && nc -vz {{ .Values.nodeIP }} {{ .Values.cactus.apiPort }}']

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ .Release.Name }}-machinaris-deployment-test"
annotations:
"helm.sh/hook": test
spec:
hostNetwork: true
restartPolicy: Never
containers:
- name: {{ .Release.Name }}-machinaris-deployment-test
image: busybox
command: ['sh', '-c', 'nc -vz {{ .Values.nodeIP }} {{ .Values.machinarisApiPort }}']

View File

@@ -0,0 +1,78 @@
image:
pullPolicy: IfNotPresent
repository: ghcr.io/guydavis/machinaris
tag: v0.6.7
machinaris_ui_port: 31003
machinarisApiPort: 8927
ports:
- name: chia-network
protocol: TCP
containerPort: 8444
hostPort: 8444
- name: machinaris-ui
protocol: TCP
containerPort: 8926
- name: machinaris-api
protocol: TCP
containerPort: 8927
hostPort: 8927
- protocol: TCP
containerPort: 8447
hostPort: 8447
timezone: America/Edmonton
updateStrategy: Recreate
nodeIP: 127.0.0.1
appVolumeMounts:
config:
emptyDir: true
mountPath: /root/.chia
plots:
emptyDir: true
mountPath: /plots
plotting:
emptyDir: true
mountPath: /plotting
environmentVariables:
- name: mode
value: fullnode
coins:
- cactus
cactusEnabled: true
cactus:
apiPort: 8936
ports:
- name: api
protocol: TCP
containerPort: 8936
hostPort: 8936
- name: blockchain
protocol: TCP
containerPort: 11444
hostPort: 11444
- name: farming
protocol: TCP
containerPort: 11447
hostPort: 11447
volumeMounts:
cactus-config:
emptyDir: true
mountPath: /root/.chia
mnemonic:
emptyDir: true
mountPath: /root/.chia/mnemonic.txt
readOnly: true
subPath: mnemonic.txt
environmentVariables:
- name: mode
value: plotter
enableResourceLimits: true
cpuLimit: 0.5
memLimit: 1G