Move storj to ix-dev (#1052)

This commit is contained in:
Stavros Kois
2023-03-24 23:39:12 +02:00
committed by GitHub
parent fc5caa4ec4
commit 1f82a2fd28
22 changed files with 62 additions and 30 deletions

View File

@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://../../../common/2207.0.0
version: 2207.0.0
digest: sha256:a301ba0f99ec1e08a60a7f0a0320aa02d225993572f2f056f09520f06df88b37
generated: "2023-03-22T19:36:11.899870629+02:00"

View File

@@ -0,0 +1,26 @@
name: storj
description: Share your storage on the internet and earn.
annotations:
title: Storj
type: application
version: 1.0.6
apiVersion: v2
appVersion: v1.68.2
kubeVersion: '>=1.16.0-0'
maintainers:
- name: truenas
url: https://www.truenas.com/
dependencies:
- name: common
repository: file://../../../common/2207.0.0
version: 2207.0.0
home: https://www.storj.io
icon: https://assets-global.website-files.com/602eda09fc78afc76e9706b6/60917835a05862243e7de9af_logo.svg
sources:
- https://www.storj.io
- https://github.com/truenas/charts/tree/master/library/ix-dev/charts/storj
keywords:
- storage
- dapps
- networking
- financial

View File

@@ -0,0 +1,3 @@
# storj
[storj](https://www.storj.io/) share your extra storage and earn money

View File

@@ -0,0 +1,3 @@
# storj
[storj](https://www.storj.io/) share your extra storage and earn money

Binary file not shown.

View File

@@ -0,0 +1,24 @@
appVolumeMounts:
data:
emptyDir: true
mountPath: /app/config
identity:
emptyDir: true
mountPath: /app/identity
authToken: user:sasjkadkjhakdlaskdlkajsd
dnsConfig:
options: []
domainAddress: localhost
email: user@example.com
emptyDirVolumes: true
environmentVariables: []
extraAppVolumeMounts: []
terminationGracePeriod: 120
identityCreationMountPath: /root/.local/share/storj/identity/storagenode
nodePort: 30002
runAsGroup: 568
runAsUser: 568
storageSize: 500
wallet: 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
webPort: 30000
zksync: true

View File

@@ -0,0 +1,6 @@
icon_url: https://assets-global.website-files.com/602eda09fc78afc76e9706b6/60917835a05862243e7de9af_logo.svg
categories:
- storage
- dapps
- networking
- finantial

View File

@@ -0,0 +1,290 @@
groups:
- name: "Configuration"
description: "Storj application configuration"
- name: "Storage"
description: "Configure storage for storj"
- name: "Networking"
description: "Networking Configuration for storj"
- name: "Advanced DNS Settings"
description: "Configure DNS settings"
- name: "Resource Limits"
description: "Set CPU/memory limits for Kubernetes Pod"
portals:
web_portal:
protocols:
- "http"
host:
- "$node_ip"
ports:
- "$variable-webPort"
path: "/"
questions:
- variable: webPort
label: "Web Port for Storj"
group: Networking
schema:
type: int
min: 9000
max: 65535
default: 20909
required: true
- variable: nodePort
label: "Node Port for Storj"
group: Networking
schema:
type: int
min: 9000
max: 65535
default: 20988
required: true
- variable: dnsConfig
label: "DNS Configuration"
group: "Advanced DNS Settings"
schema:
type: dict
attrs:
- variable: options
label: "DNS Options"
schema:
type: list
items:
- variable: optionsEntry
label: "Option Entry Configuration"
schema:
type: dict
attrs:
- variable: name
label: "Option Name"
schema:
type: string
required: true
- variable: value
label: "Option Value"
schema:
type: string
required: true
- variable: wallet
label: "Configure Wallet for Storj"
group: "Configuration"
schema:
type: string
required: true
- variable: authToken
label: "Configure Auth token for Storj Node"
group: "Configuration"
schema:
type: string
required: true
- variable: email
label: "Configure Email for Storj"
group: "Configuration"
schema:
type: string
required: true
- variable: domainAddress
label: "Add Your Storage Domain for Storj"
group: "Configuration"
schema:
type: string
required: true
- variable: zksync
label: "Opt-in to zkSync"
description: Appends --operator.wallet-features=zksync flag to the storagenode command
group: "Configuration"
schema:
type: boolean
default: false
- variable: terminationGracePeriod
label: Termination Grace Period
description: Optional duration in seconds the pod needs to terminate gracefully.
group: "Configuration"
schema:
type: int
min: 30
default: 30
- variable: storageSize
label: "Configure Storage Size You Want To Share in GB's"
group: Storage
schema:
type: int
min: 500
default: 500
- variable: runAsUser
label: "Owner User ID"
group: "Configuration"
schema:
immutable: true
type: int
default: 568
min: 1
max: 65535
- variable: runAsGroup
label: "Owner Group ID"
group: "Configuration"
schema:
immutable: true
type: int
default: 568
min: 1
max: 65535
- variable: environmentVariables
label: "Storj Extra Environment Variables"
group: "Configuration"
schema:
type: list
default: []
items:
- variable: environmentVariable
label: "Environment Variable"
schema:
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
- variable: value
label: "Value"
schema:
type: string
- variable: appVolumeMounts
label: "Storj Configuration"
group: "Storage"
schema:
type: dict
attrs:
- variable: data
label: "Configuration Data Volume to Share on Storj"
schema:
type: dict
attrs:
- variable: datasetName
label: "Configuration Volume Dataset Name"
schema:
type: string
hidden: true
$ref:
- "normalize/ixVolume"
show_if: [["hostPathEnabled", "=", false]]
default: "ix_data"
editable: false
- variable: mountPath
label: "Configuration Mount Path"
description: "Path Where the Volume Will be Mounted Inside the Pod"
schema:
type: path
hidden: true
editable: false
default: "/app/config"
- variable: hostPathEnabled
label: "Enable Custom Host Path for Storj Configuration Volume"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: hostPath
label: "Host Path for Storj Configuration Volume"
schema:
type: hostpath
required: true
- variable: identity
label: "Configure Identity Volume for Storage Node"
schema:
type: dict
attrs:
- variable: datasetName
label: "Configure Storj Identity Volume to Allocate"
schema:
type: string
hidden: true
$ref:
- "normalize/ixVolume"
show_if: [["hostPathEnabled", "=", false]]
default: "ix_identity"
editable: false
- variable: mountPath
label: "Configure Storj Identity Volume to Allocate"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
hidden: true
editable: false
default: "/app/identity"
- variable: hostPathEnabled
label: "Enable Custom Host Path for Storj Identity Volume"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: hostPath
label: "Host Path for Storj identity Volume"
schema:
type: hostpath
required: true
- variable: extraAppVolumeMounts
label: "Extra Host Path Volumes"
group: "Storage"
schema:
type: list
items:
- variable: extraAppVolume
label: "Host Path Volume"
description: "Add an extra host path volume for storj"
schema:
type: dict
attrs:
- variable: mountPath
label: "Mount Path in Pod"
description: "Path where the volume will be mounted inside the pod."
schema:
type: path
required: true
- variable: hostPath
label: "Host Path"
description: "Host path"
schema:
type: hostpath
required: true
- variable: enableResourceLimits
label: "Enable Pod resource limits"
group: "Resource Limits"
schema:
type: boolean
default: false
- variable: cpuLimit
label: "CPU Limresource limitsit"
description: "CPU resource limit allow plain integer values with suffix m(milli) e.g 1000m, 100."
group: "Resource Limits"
schema:
type: string
show_if: [["enableResourceLimits", "=", true]]
valid_chars: "^\\d+(?:\\.\\d+(?!.*m$)|m?$)"
default: "4000m"
- variable: memLimit
label: "Memory Limit"
group: "Resource Limits"
description: "Memory limits is specified by number of bytes. Followed by quantity suffix like E,P,T,G,M,k and Ei,Pi,Ti,Mi,Gi,Ki can also be used. e.g 129e6, 129M, 128974848000m, 123Mi"
schema:
type: string
show_if: [["enableResourceLimits", "=", true]]
valid_chars: "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$"
default: "8Gi"

View File

@@ -0,0 +1,6 @@
{{/*
Retrieve cert path
*/}}
{{- define "certPath" -}}
{{ printf }}
{{- end -}}

View File

@@ -0,0 +1,102 @@
{{ include "common.storage.hostPathValidate" .Values }}
apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "common.names.fullname" . }}
labels:
app: {{ template "common.names.name" . }}
chart: {{ template "common.names.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
rollme: {{ randAlphaNum 5 | quote }}
spec:
replicas: {{ (default 1 .Values.replicas) }}
strategy:
type: "Recreate"
selector:
matchLabels:
app: {{ template "common.names.name" . }}
release: {{ .Release.Name }}
template:
metadata:
name: {{ template "common.names.fullname" . }}
labels:
app: {{ template "common.names.name" . }}
release: {{ .Release.Name }}
{{- include "common.labels.selectorLabels" . | nindent 8 }}
annotations: {{ include "common.annotations" . | nindent 8 }}
spec:
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod | default 30 }}
initContainers:
- name: generate-identity
image: "alpine/curl:latest"
securityContext:
runAsUser: 0
runAsGroup: 0
command:
- ./init_script/init_config.sh
env:
{{ $envListIdentity := (default list) }}
{{ $envListIdentity = mustAppend $envListIdentity (dict "name" "DEFAULT_CERT_PATH" "value" (printf "%s/ca.cert" .Values.identityCreationMountPath)) }}
{{ $envListIdentity = mustAppend $envListIdentity (dict "name" "DEFAULT_IDENTITY_CERT_PATH" "value" (printf "%s/identity.cert" .Values.identityCreationMountPath)) }}
{{ $envListIdentity = mustAppend $envListIdentity (dict "name" "AUTH_KEY" "valueFromSecret" true "secretName" "storj-credentials" "secretKey" "authToken") }}
{{ include "common.containers.environmentVariables" (dict "environmentVariables" $envListIdentity) | nindent 12 }}
volumeMounts:
- name: initial-scripts
mountPath: /init_script/
- name: identity
mountPath: {{ .Values.identityCreationMountPath }}
- name: setup
{{ include "common.containers.imageConfig" .Values.image | nindent 8 }}
command:
- /bin/sh
- -c
- 'test ! -f {{ .Values.appVolumeMounts.data.mountPath }}/config.yaml && export SETUP="true"; /entrypoint;'
{{ include "common.storage.allContainerVolumeMounts" .Values | nindent 8 }}
securityContext:
runAsUser: {{ .Values.runAsUser }}
runAsGroup: {{ .Values.runAsGroup }}
containers:
- name: {{ .Chart.Name }}
{{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
{{ include "common.resources.limitation" . | nindent 10 }}
volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
{{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
- name: extrappvolume-{{ $index }}
mountPath: {{ $hostPathConfiguration.mountPath }}
{{ end }}
securityContext:
runAsUser: {{ .Values.runAsUser }}
runAsGroup: {{ .Values.runAsGroup }}
ports:
- name: web
containerPort: 14002
- name: tcp
containerPort: 28967
protocol: TCP
- name: udp
containerPort: 28967
protocol: UDP
{{ if .Values.zksync }}
args:
- --operator.wallet-features=zksync
{{ end }}
env:
{{ $envList := (default list .Values.environmentVariables) }}
{{ $envList = mustAppend $envList (dict "name" "WALLET" "valueFromSecret" true "secretName" "storj-credentials" "secretKey" "wallet") }}
{{ $envList = mustAppend $envList (dict "name" "ADDRESS" "value" (printf "%s:%d" (.Values.domainAddress) (.Values.nodePort | int))) }}
{{ $envList = mustAppend $envList (dict "name" "EMAIL" "value" (printf "%s" (.Values.email))) }}
{{ $envList = mustAppend $envList (dict "name" "STORAGE" "value" (printf "%dGB" (.Values.storageSize | int))) }}
{{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
{{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
{{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
- name: extrappvolume-{{ $index }}
hostPath:
path: {{ $hostPathConfiguration.hostPath }}
{{ end }}
- name: initial-scripts
configMap:
defaultMode: 0755
name: "initial-scripts"

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: "initial-scripts"
annotations:
rollme: {{ randAlphaNum 5 | quote }}
data:
init_config.sh: |-
#!/bin/sh
if ! [ -f ${DEFAULT_CERT_PATH} ] && ! [ -f ${DEFAULT_IDENTITY_CERT_PATH} ]; then
curl -L https://github.com/storj/storj/releases/latest/download/identity_linux_amd64.zip -o identity_linux_amd64.zip
unzip -o identity_linux_amd64.zip
chmod +x identity
./identity create storagenode
./identity authorize storagenode ${AUTH_KEY}
chown -R {{ .Values.runAsUser }}:{{ .Values.runAsGroup }} {{ .Values.identityCreationMountPath }}
fi

View File

@@ -0,0 +1,28 @@
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ template "common.names.fullname" . }}-preinstall-job"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
helm.sh/chart: {{ template "common.names.chart" . }}
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
metadata:
name: "{{ template "common.names.fullname" . }}-preinstall-hook"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
helm.sh/chart: {{ template "common.names.chart" . }}
spec:
restartPolicy: Never
containers:
- name: pre-install-job
image: "alpine:latest"
command: ["chown", "-R", "{{ .Values.runAsUser }}:{{ .Values.runAsGroup }}", "{{ .Values.appVolumeMounts.data.mountPath }}", "{{ .Values.appVolumeMounts.identity.mountPath }}"]
volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}

View File

@@ -0,0 +1,11 @@
{{ $selectors := list }}
{{ $selectors = mustAppend $selectors (dict "key" "app" "value" (include "common.names.name" .) ) }}
{{ $selectors = mustAppend $selectors (dict "key" "release" "value" .Release.Name ) }}
{{ $ports := list }}
{{ $ports = mustAppend $ports (dict "name" "web" "port" .Values.webPort "nodePort" .Values.webPort "targetPort" 14002) }}
{{ $ports = mustAppend $ports (dict "name" "tcp" "port" .Values.nodePort "nodePort" .Values.nodePort "targetPort" 28967) }}
{{ $ports = mustAppend $ports (dict "name" "udp" "port" .Values.nodePort "nodePort" .Values.nodePort "targetPort" 28967 "protocol" "UDP") }}
{{ $params := . }}
{{ $_ := set $params "commonService" (dict "type" "NodePort" "ports" $ports ) }}
{{ $_1 := set .Values "extraSelectorLabels" $selectors }}
{{ include "common.classes.service" $params }}

View File

@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: storj-credentials
labels: {{ include "common.labels" . | nindent 4 }}
type: Opaque
data:
authToken: {{ .Values.authToken | b64enc | quote }}
wallet: {{ .Values.wallet | b64enc | quote }}

View File

@@ -0,0 +1 @@
{"filename": "ix_values.yaml", "keys": ["image"], "test_filename": "test_values.yaml"}

View File

@@ -0,0 +1,51 @@
#!/usr/bin/python3
import json
import sys
import re
from catalog_update.upgrade_strategy import semantic_versioning
from catalog_validation.exceptions import ValidationException
version_regx = r'[\w]*-v[0-9]+.[0-9]+.[0-9]+-go[0-9]+.[0-9].+[0-9]+'
version_with_arch = version_regx + r'[-\w]*'
sub_go_version = r'-go[0-9]+.[0-9].+[0-9]+[-\w]*'
version_hash = r'[\w]*-v'
app_version_regx = 'v[0-9]+.[0-9]+.[0-9]'
def newer_mapping(image_tags):
key = list(image_tags.keys())[0]
tags = {}
for tag in image_tags[key]:
match = re.fullmatch(version_with_arch, tag)
if match:
removed_go_arch_version = re.sub(sub_go_version, '', tag)
app_version = re.sub(version_hash, '', removed_go_arch_version)
if tags.get(app_version):
tags.get(app_version).append(tag)
else:
tags[app_version] = [tag]
version = semantic_versioning(list(tags))
if not version:
return {}
version_tag = tags[version][0]
for tag in tags.get(version):
archi = re.sub(version_regx, '', tag)
if archi == 'amd64' or archi == '':
version_tag = tag
break
app_version = re.findall(app_version_regx, version_tag).pop()
return {
'tags': {key: f'{version_tag}'},
'app_version': f'{app_version}',
}
if __name__ == '__main__':
try:
versions_json = json.loads(sys.stdin.read())
except ValueError:
raise ValidationException('Invalid JSON')
print(json.dumps(newer_mapping(versions_json)))

View File

@@ -0,0 +1,5 @@
identityCreationMountPath: /root/.local/share/storj/identity/storagenode
image:
pullPolicy: IfNotPresent
repository: storjlabs/storagenode
tag: 1d42f9ac3-v1.68.2-go1.18.8