From 1af3889d4e895de6972b11ef022291fc1eab7a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomislav=20Kopi=C4=87?= Date: Sat, 13 Sep 2025 11:59:25 +0200 Subject: [PATCH] Create helm chart --- .helmignore | 23 ++++++++++ Chart.yaml | 24 +++++++++++ templates/NOTES.txt | 17 ++++++++ templates/_helpers.tpl | 62 +++++++++++++++++++++++++++ templates/daemonset.yaml | 77 +++++++++++++++++++++++++++++++++ templates/priorityclass.yaml | 7 +++ templates/serviceaccount.yaml | 13 ++++++ values.yaml | 81 +++++++++++++++++++++++++++++++++++ 8 files changed, 304 insertions(+) create mode 100644 .helmignore create mode 100644 Chart.yaml create mode 100644 templates/NOTES.txt create mode 100644 templates/_helpers.tpl create mode 100644 templates/daemonset.yaml create mode 100644 templates/priorityclass.yaml create mode 100644 templates/serviceaccount.yaml create mode 100644 values.yaml diff --git a/.helmignore b/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/.helmignore @@ -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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..3041a20 --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: duino-miner +description: Helm chart for deploying duino miner to kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/templates/NOTES.txt b/templates/NOTES.txt new file mode 100644 index 0000000..4c6887c --- /dev/null +++ b/templates/NOTES.txt @@ -0,0 +1,17 @@ +Your Duino-Coin miner DaemonSet has been successfully deployed! + +Since the miner does not expose any HTTP service, there is no application URL. + +To check that it is running on all nodes, use: + + kubectl get daemonset -n {{ .Release.Namespace }} {{ include "duino-miner.fullname" . }} + +To view logs from one of the miner pods: + + kubectl logs -n {{ .Release.Namespace }} -l app.kubernetes.io/name={{ include "duino-miner.name" . }} --tail=50 -f + +To see which nodes are running the miner: + + kubectl get pods -n {{ .Release.Namespace }} -o wide -l app.kubernetes.io/name={{ include "duino-miner.name" . }} + +Happy mining! diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl new file mode 100644 index 0000000..5d56fb9 --- /dev/null +++ b/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "duino-miner.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "duino-miner.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "duino-miner.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "duino-miner.labels" -}} +helm.sh/chart: {{ include "duino-miner.chart" . }} +{{ include "duino-miner.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "duino-miner.selectorLabels" -}} +app.kubernetes.io/name: {{ include "duino-miner.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "duino-miner.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "duino-miner.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/templates/daemonset.yaml b/templates/daemonset.yaml new file mode 100644 index 0000000..63619fc --- /dev/null +++ b/templates/daemonset.yaml @@ -0,0 +1,77 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: {{ include "duino-miner.fullname" . }} + labels: + {{- include "duino-miner.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "duino-miner.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "duino-miner.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + priorityClassName: {{ .Values.priorityClassName | quote }} + serviceAccountName: {{ include "duino-miner.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + {{- range $key, $value := .Values.env }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} + {{- with .Values.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/templates/priorityclass.yaml b/templates/priorityclass.yaml new file mode 100644 index 0000000..1ac64cf --- /dev/null +++ b/templates/priorityclass.yaml @@ -0,0 +1,7 @@ +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: {{ .Values.priorityClassName | quote }} +value: 1 +globalDefault: false +description: "Absolute lowest priority for duino-miner pods" diff --git a/templates/serviceaccount.yaml b/templates/serviceaccount.yaml new file mode 100644 index 0000000..1865351 --- /dev/null +++ b/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "duino-miner.serviceAccountName" . }} + labels: + {{- include "duino-miner.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..84e94cc --- /dev/null +++ b/values.yaml @@ -0,0 +1,81 @@ +# Docker image configuration for the Duino-Coin miner +image: + repository: simeononsecurity/duinocoin # Docker image repository + pullPolicy: IfNotPresent # When to pull the image (IfNotPresent / Always) + tag: "latest" # Image tag; if empty, defaults to Chart appVersion +imagePullSecrets: [] # Optional secrets for private registries + +# Resource requests and limits for the miner container +resources: + limits: + cpu: 1 # Maximum CPU the container can use + memory: 128Mi # Maximum memory the container can use + requests: + cpu: 0 # Minimum CPU guaranteed (optional, can leave 0) + memory: 0 # Minimum memory guaranteed (optional) + +# Kubernetes priority class to make pods low priority +priorityClassName: "duino-miner-lowest" + +# Environment variables for the Duino-Coin miner +env: + DUCO_USERNAME: "your_actual_username" # Your Duino-Coin wallet or username + DUCO_MINING_KEY: "your_actual_mining_key" # Mining key + DUCO_INTENSITY: "95" # Mining intensity (0–100) + DUCO_THREADS: "1" # Number of threads to use + DUCO_START_DIFF: "MEDIUM" # Difficulty setting + DUCO_DONATE: "5" # Donation percentage + DUCO_IDENTIFIER: "Auto" # Worker identifier + DUCO_ALGORITHM: "DUCO-S1" # Algorithm type + DUCO_LANGUAGE: "english" # Language for logs/messages + DUCO_SOC_TIMEOUT: "20" # SOC timeout + DUCO_REPORT_SEC: "300" # Reporting interval in seconds + DUCO_RASPI_LEDS: "n" # Raspberry Pi LED usage + DUCO_RASPI_CPU_IOT: "n" # Raspberry Pi CPU I/O tuning + DUCO_DISCORD_RP: "n" # Discord Rich Presence + +# Optional overrides for chart naming +nameOverride: "" +fullnameOverride: "" + +# Service account settings +serviceAccount: + create: true # Create a dedicated service account + automount: true # Automatically mount service account token + annotations: {} # Optional annotations for the service account + name: "" # Custom name; leave blank to auto-generate + +# Pod annotations and labels +podAnnotations: {} # Optional Kubernetes annotations for pods +podLabels: {} # Optional Kubernetes labels for pods + +# Security contexts +podSecurityContext: {} # Pod-level security settings +securityContext: {} # Container-level security settings + +# Liveness probe to check if the miner process is running +livenessProbe: + exec: + command: + - /bin/sh + - -c + - "pgrep -x duino-miner > /dev/null" + initialDelaySeconds: 30 # Delay before first check + periodSeconds: 60 # Check interval + +# Readiness probe to check if the miner is ready +readinessProbe: + exec: + command: + - /bin/sh + - -c + - "pgrep -x duino-miner > /dev/null" + initialDelaySeconds: 10 # Delay before first check + periodSeconds: 30 # Check interval + +# Volumes and mounts (if needed) +volumes: [] # Define extra volumes here +volumeMounts: [] # Define mounts inside the container here + +# Node selection and scheduling +nodeSelector: {}