Storj - migrate library (#2219)

* storj - migrate library

* dep update

* lint

* update ui

* fixup

* add migartion

* fix type

* fix script

* fix perms

* move over

* valid key

* update migration
This commit is contained in:
Stavros Kois
2024-02-27 15:57:30 +02:00
committed by GitHub
parent 5e956e212e
commit 798c9f1d85
28 changed files with 979 additions and 452 deletions

View File

@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: file://../../../common/2304.0.1
version: 2304.0.1
digest: sha256:1ed155c6760e1166e2cb75b52bc5e81c6bdf0252c16ff5ede001157077c41670
generated: "2023-04-24T13:41:28.076153579+03:00"
repository: file://../../../common
version: 1.2.9
digest: sha256:af1a9a1f87e3e48453c9f25f909f5ebcd7fa6e25162b7b425448ba752bcdbc5c
generated: "2024-02-23T17:46:31.084498341+02:00"

View File

@@ -3,7 +3,7 @@ description: Share your storage on the internet and earn.
annotations:
title: Storj
type: application
version: 1.0.18
version: 2.0.0
apiVersion: v2
appVersion: v1.68.2
kubeVersion: '>=1.16.0-0'
@@ -13,8 +13,8 @@ maintainers:
email: dev@ixsystems.com
dependencies:
- name: common
repository: file://../../../common/2304.0.1
version: 2304.0.1
repository: file://../../../common
version: 1.2.9
home: https://www.storj.io
icon: https://media.sys.truenas.net/apps/storj/icons/icon.svg
sources:

View File

@@ -1,3 +1,7 @@
# storj
# Storj
[storj](https://www.storj.io/) share your extra storage and earn money
[Storj](https://www.storj.io/) - share your extra storage and earn money
During the first startup a container with root privileges is created.
And it will generate an identity (if it doesn't exist)
After the identity is created, the container will run as a non-root user.

View File

@@ -1,3 +1,7 @@
# storj
# Storj
[storj](https://www.storj.io/) share your extra storage and earn money
[Storj](https://www.storj.io/) - share your extra storage and earn money
During the first startup a container with root privileges is created.
And it will generate an identity (if it doesn't exist)
After the identity is created, the container will run as a non-root user.

Binary file not shown.

View File

@@ -0,0 +1,20 @@
storjConfig:
wallet: 0xab00000999999aaaaaaaccccccdddddddfffffff
authToken: user:sasjkadkjhakdlaskdlkajsd
email: user@example.com
domainAddress: localhost
gracePeriod: 120
storageSizeGB: 500
wallets:
zkSync: true
zkSyncEra: true
storjStorage:
data:
type: pvc
identity:
type: pvc
storjNetwork:
webPort: 30909
p2pPort: 32767

View File

@@ -1,25 +0,0 @@
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
zksyncEra: true

View File

@@ -1,9 +1,9 @@
runAsContext:
- userName: root
groupName: root
gid: 0
uid: 0
description: Storj runs as root user.
- userName: storj
groupName: storj
gid: 568
uid: 568
description: Storj runs as non-root user.
capabilities:
- name: CHOWN
description: Storj is able to chown files.

View File

@@ -0,0 +1,104 @@
#!/usr/bin/python3
import json
import os
import sys
def migrate_volume(volume):
return {
'type': 'hostPath',
'hostPathConfig': {
'hostPath': volume['hostPath']
},
} if volume.get('hostPathEnabled', False) else {
'type': 'ixVolume',
'ixVolumeConfig': {
'datasetName': volume['datasetName'],
},
}
def migrate_common_lib(values):
delete_keys = [
'enableResourceLimits', 'cpuLimit', 'memLimit', 'dnsConfig',
'environmentVariables', 'runAsUser', 'runAsGroup', 'webPort',
'nodePort', 'wallet', 'authToken', 'email', 'domainAddress',
'terminationGracePeriod', 'storageSize', 'zksync', 'zksyncEra',
'extraAppVolumeMounts', 'appVolumeMounts', 'identityCreationMountPath',
]
values.update({
# Migrate Network
'storjNetwork': {
'webPort': values['webPort'],
'p2pPort': values['nodePort'],
},
# Migrate Resources
'resources': {
'limits': {
'cpu': values.get('cpuLimit', '4000m'),
'memory': values.get('memLimit', '8Gi'),
}
},
# Migrate DNS
'podOptions': {
'dnsConfig': {
'options': [
{'name': opt['name'], 'value': opt['value']}
for opt in values.get('dnsConfig', {}).get('options', [])
]
}
},
# Migrate ID
'storjRunAs': {
'user': values['runAsUser'],
'group': values['runAsGroup'],
},
# Migrate Config
'storjConfig': {
'wallet': values['wallet'],
'authToken': values['authToken'],
'email': values['email'],
'domainAddress': values['domainAddress'],
'storageSizeGB': values['storageSize'],
'gracePeriod': values['terminationGracePeriod'],
'wallets': {
'zkSync': values['zksync'],
'zkSyncEra': values['zksyncEra'],
},
'additionalEnvs': [e for e in values.get('environmentVariables', [])],
},
# Migrate Storage
'storjStorage': {
'data': migrate_volume(values['appVolumeMounts']['data']),
'identity': migrate_volume(values['appVolumeMounts']['identity']),
'additionalStorages': [
{
'type': 'hostPath',
'hostPathConfig': {'hostPath': e['hostPath']},
'mountPath': e['mountPath'],
}
for e in values.get('extraAppVolumeMounts', [])
],
},
})
for k in delete_keys:
values.pop(k, None)
return values
def migrate(values):
# If this missing, we have already migrated
if not 'appVolumeMounts' in values.keys():
return values
return migrate_common_lib(values)
if __name__ == '__main__':
if len(sys.argv) != 2:
exit(1)
if os.path.exists(sys.argv[1]):
with open(sys.argv[1], 'r') as f:
print(json.dumps(migrate(json.loads(f.read()))))

View File

@@ -1,302 +1,551 @@
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"
- name: Storj Configuration
description: Configure Storj
- name: User and Group Configuration
description: Configure User and Group for Storj
- name: Advanced Pod Configuration
description: Configure Advanced Pod Options for Storj
- name: Network Configuration
description: Configure Network for Storj
- name: Storage Configuration
description: Configure Storage for Storj
- name: Resources Configuration
description: Configure Resources for Storj
portals:
web_portal:
protocols:
- "http"
- "$kubernetes-resource_configmap_portal_protocol"
host:
- "$node_ip"
- "$kubernetes-resource_configmap_portal_host"
ports:
- "$variable-webPort"
path: "/"
- "$kubernetes-resource_configmap_portal_port"
path: "$kubernetes-resource_configmap_portal_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"
description: |
This port will be used for both TCP and UDP traffic. </br>
Note that this port must be open on your firewall and that internal
Storj port will not be affected by this change, but only the external (Node Port)
group: Networking
schema:
type: int
min: 9000
max: 65535
default: 28967
required: true
- variable: dnsConfig
label: "DNS Configuration"
group: "Advanced DNS Settings"
- variable: storjConfig
label: ""
group: Storj Configuration
schema:
type: dict
attrs:
- variable: options
label: "DNS Options"
- variable: wallet
label: Wallet
description: The wallet to use for Storj.
schema:
type: string
required: true
private: true
- variable: authToken
label: Auth Token
description: The auth token to use for Storj.
schema:
type: string
required: true
private: true
- variable: email
label: Email
description: The email to use for Storj.
schema:
type: string
required: true
- variable: domainAddress
label: Domain Address
description: The domain address to use for Storj.
schema:
type: string
required: true
private: true
- variable: gracePeriod
label: Grace Period
description: The grace period to use for Storj.
schema:
type: int
min: 30
default: 30
required: true
- variable: storageSizeGB
label: Storage Size
description: The storage size to use for Storj.
schema:
type: int
min: 500
default: 500
required: true
- variable: wallets
label: Opt-in to additional Wallets
schema:
type: dict
attrs:
- variable: zkSync
label: zkSync
description: Appends "zksync" to --operator.wallet-features flag to the storagenode command
schema:
type: boolean
default: false
- variable: zkSyncEra
label: zkSync Era
description: Appends "zksync-era" to --operator.wallet-features flag to the storagenode command
schema:
type: boolean
default: false
- variable: additionalEnvs
label: Additional Environment Variables
description: Configure additional environment variables for Storj.
schema:
type: list
default: []
items:
- variable: optionsEntry
label: "Option Entry Configuration"
- variable: env
label: Environment Variable
schema:
type: dict
attrs:
- variable: name
label: "Option Name"
label: Name
schema:
type: string
required: true
- variable: value
label: "Option Value"
label: Value
schema:
type: string
required: true
- variable: wallet
label: "Configure Wallet for Storj"
group: "Configuration"
- variable: storjRunAs
label: ""
group: User and Group Configuration
schema:
type: string
required: true
type: dict
attrs:
- variable: user
label: User ID
description: The user id that Storj will run as.
schema:
type: int
min: 568
default: 568
required: true
- variable: group
label: Group ID
description: The group id that Storj will run as.
schema:
type: int
min: 568
default: 568
required: true
- variable: authToken
label: "Configure Auth token for Storj Node"
group: "Configuration"
- variable: podOptions
label: ""
group: Advanced Pod 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 "zksync" to --operator.wallet-features flag to the storagenode command
group: "Configuration"
schema:
type: boolean
default: false
- variable: zksyncEra
label: "Opt-in to zkSync era"
description: Appends "zksync-era" to --operator.wallet-features 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"
type: dict
attrs:
- variable: dnsConfig
label: Advanced DNS Configuration
schema:
type: dict
attrs:
- variable: name
label: "Name"
- variable: options
label: DNS Options
schema:
type: string
- variable: value
label: "Value"
schema:
type: string
type: list
items:
- variable: optionsEntry
label: DNS Option Entry
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: appVolumeMounts
label: "Storj Configuration"
group: "Storage"
- variable: storjNetwork
label: ""
group: Network Configuration
schema:
type: dict
attrs:
- variable: webPort
label: Web Port
description: The port for the Storj Web UI.
schema:
type: int
default: 20909
min: 9000
max: 65535
required: true
- variable: p2pPort
label: P2P Port
description: |
This port will be used for both TCP and UDP traffic. </br>
Note that this port must be open on your firewall and that internal
Storj port will not be affected by this change, but only the external (Node Port)
schema:
type: int
default: 28967
min: 9000
max: 65535
required: true
- variable: hostNetwork
label: Host Network
description: |
Enable host network for Storj
schema:
type: boolean
default: false
- variable: storjStorage
label: ""
group: Storage Configuration
schema:
type: dict
attrs:
- variable: data
label: "Configuration Data Volume to Share on Storj"
label: Storj Data Storage
description: The path to store Storj Data.
schema:
type: dict
attrs:
- variable: datasetName
label: "Configuration Volume Dataset Name"
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
hidden: true
required: true
immutable: true
default: "ixVolume"
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- variable: ixVolumeConfig
label: ixVolume Configuration
description: The configuration for the ixVolume dataset.
schema:
type: dict
show_if: [["type", "=", "ixVolume"]]
$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"
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: datasetName
label: Dataset Name
description: The name of the dataset to use for storage.
schema:
type: string
required: true
immutable: true
hidden: true
default: "data"
- variable: aclEntries
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
- variable: hostPathConfig
label: Host Path Config
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:
type: dict
show_if: [["type", "=", "hostPath"]]
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: acl
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
$ref:
- "normalize/acl"
- variable: hostPath
label: "Host Path for Storj Configuration Volume"
label: Host Path
description: The host path to use for storage.
schema:
type: hostpath
show_if: [["aclEnable", "=", false]]
required: true
- variable: identity
label: "Configure Identity Volume for Storage Node"
label: Storj Identity Storage
description: The path to store Storj Identity.
schema:
type: dict
attrs:
- variable: datasetName
label: "Configure Storj Identity Volume to Allocate"
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
hidden: true
required: true
immutable: true
default: "ixVolume"
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- variable: ixVolumeConfig
label: ixVolume Configuration
description: The configuration for the ixVolume dataset.
schema:
type: dict
show_if: [["type", "=", "ixVolume"]]
$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"
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: datasetName
label: Dataset Name
description: The name of the dataset to use for storage.
schema:
type: string
required: true
immutable: true
hidden: true
default: "identity"
- variable: aclEntries
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
- variable: hostPathConfig
label: Host Path Config
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:
type: dict
show_if: [["type", "=", "hostPath"]]
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: acl
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
$ref:
- "normalize/acl"
- variable: hostPath
label: "Host Path for Storj identity Volume"
label: Host Path
description: The host path to use for storage.
schema:
type: hostpath
show_if: [["aclEnable", "=", false]]
required: true
- variable: extraAppVolumeMounts
label: "Extra Host Path Volumes"
group: "Storage"
- variable: additionalStorages
label: Additional Storage
description: Additional storage for Storj.
schema:
type: list
default: []
items:
- variable: storageEntry
label: Storage Entry
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.</br>
SMB Share: Is a SMB share that is mounted to a persistent volume claim.
schema:
type: string
required: true
default: "ixVolume"
immutable: true
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- value: "smb-pv-pvc"
description: SMB Share (Mounts a persistent volume claim to a SMB share)
- variable: readOnly
label: Read Only
description: Mount the volume as read only.
schema:
type: boolean
default: false
- variable: mountPath
label: Mount Path
description: The path inside the container to mount the storage.
schema:
type: path
required: true
- variable: hostPathConfig
label: Host Path Config
schema:
type: dict
show_if: [["type", "=", "hostPath"]]
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: acl
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
$ref:
- "normalize/acl"
- variable: hostPath
label: Host Path
description: The host path to use for storage.
schema:
type: hostpath
show_if: [["aclEnable", "=", false]]
required: true
- variable: ixVolumeConfig
label: ixVolume Configuration
description: The configuration for the ixVolume dataset.
schema:
type: dict
show_if: [["type", "=", "ixVolume"]]
$ref:
- "normalize/ixVolume"
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: datasetName
label: Dataset Name
description: The name of the dataset to use for storage.
schema:
type: string
required: true
immutable: true
default: "storage_entry"
- variable: aclEntries
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
- variable: smbConfig
label: SMB Share Configuration
description: The configuration for the SMB Share.
schema:
type: dict
show_if: [["type", "=", "smb-pv-pvc"]]
attrs:
- variable: server
label: Server
description: The server for the SMB share.
schema:
type: string
required: true
- variable: share
label: Share
description: The share name for the SMB share.
schema:
type: string
required: true
- variable: domain
label: Domain (Optional)
description: The domain for the SMB share.
schema:
type: string
- variable: username
label: Username
description: The username for the SMB share.
schema:
type: string
required: true
- variable: password
label: Password
description: The password for the SMB share.
schema:
type: string
required: true
private: true
- variable: size
label: Size (in Gi)
description: The size of the volume quota.
schema:
type: int
required: true
min: 1
default: 1
- variable: resources
group: Resources Configuration
label: ""
schema:
type: list
items:
- variable: extraAppVolume
label: "Host Path Volume"
description: "Add an extra host path volume for storj"
type: dict
attrs:
- variable: limits
label: Limits
schema:
type: dict
attrs:
- variable: mountPath
label: "Mount Path in Pod"
description: "Path where the volume will be mounted inside the pod."
- variable: cpu
label: CPU
description: CPU limit for Storj.
schema:
type: path
type: string
max_length: 6
valid_chars: '^(0\.[1-9]|[1-9][0-9]*)(\.[0-9]|m?)$'
valid_chars_error: |
Valid CPU limit formats are</br>
- Plain Integer - eg. 1</br>
- Float - eg. 0.5</br>
- Milicpu - eg. 500m
default: "4000m"
required: true
- variable: hostPath
label: "Host Path"
description: "Host path"
- variable: memory
label: Memory
description: Memory limit for Storj.
schema:
type: hostpath
type: string
max_length: 12
valid_chars: '^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$'
valid_chars_error: |
Valid Memory limit formats are</br>
- Suffixed with E/P/T/G/M/K - eg. 1G</br>
- Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi</br>
- Plain Integer in bytes - eg. 1024</br>
- Exponent - eg. 134e6
default: "8Gi"
required: true
- variable: enableResourceLimits
label: "Enable Pod resource limits"
group: "Resource Limits"
schema:
type: boolean
default: false
- variable: cpuLimit
label: "CPU Limit"
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 @@
{{ include "ix.v1.common.lib.chart.notes" $ }}

View File

@@ -0,0 +1,56 @@
{{- define "storj.configuration" -}}
secret:
storj:
enabled: true
data:
authToken: {{ .Values.storjConfig.authToken | quote }}
storj-config:
enabled: true
data:
EMAIL: {{ .Values.storjConfig.email }}
STORAGE: {{ printf "%vGB" .Values.storjConfig.storageSizeGB }}
ADDRESS: {{ printf "%s:%v" .Values.storjConfig.domainAddress .Values.storjNetwork.p2pPort }}
WALLET: {{ .Values.storjConfig.wallet | quote }}
configmap:
storj:
enabled: true
data:
init_config.sh: |
#!/bin/sh
echo "Checking for identity certificate"
if ! [ -f ${DEFAULT_CERT_PATH} ] && ! [ -f ${DEFAULT_IDENTITY_CERT_PATH} ]; then
echo "Downloading identity generator tool"
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
echo "Generating identity certificate"
./identity create storagenode
echo "Authorizing identity certificate"
./identity authorize storagenode ${AUTH_KEY}
echo "Storagenode identity certificate generated"
chown -R {{ .Values.storjRunAs.user }}:{{ .Values.storjRunAs.group }} {{ template "storj.idPath" }}
else
echo "Identity certificate already exists"
fi
{{- end -}}
{{- define "storj.args" -}}
{{- $wallets := list -}}
{{- if .Values.storjConfig.wallets.zkSync -}}
{{- $wallets = mustAppend $wallets "zksync" -}}
{{- end -}}
{{- if .Values.storjConfig.wallets.zkSyncEra -}}
{{- $wallets = mustAppend $wallets "zksync-era" -}}
{{- end -}}
{{- if $wallets -}}
args:
- --operator.wallet-features={{ join "," $wallets }}
{{- end -}}
{{- end -}}
{{- define "storj.idPath" -}}
{{- print "/root/.local/share/storj/identity/storagenode" -}}
{{- end -}}

View File

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

View File

@@ -0,0 +1,35 @@
{{- define "storj.get-versions" -}}
{{- $oldChartVersion := "" -}}
{{- $newChartVersion := "" -}}
{{/* Safely access the context, so it wont block CI */}}
{{- if hasKey .Values.global "ixChartContext" -}}
{{- if .Values.global.ixChartContext.upgradeMetadata -}}
{{- $oldChartVersion = .Values.global.ixChartContext.upgradeMetadata.oldChartVersion -}}
{{- $newChartVersion = .Values.global.ixChartContext.upgradeMetadata.newChartVersion -}}
{{- if and (not $oldChartVersion) (not $newChartVersion) -}}
{{- fail "Upgrade Metadata is missing. Cannot proceed" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- toYaml (dict "old" $oldChartVersion "new" $newChartVersion) -}}
{{- end -}}
{{- define "storj.migration" -}}
{{- $versions := (fromYaml (include "storj.get-versions" $)) -}}
{{- if and $versions.old $versions.new -}}
{{- $oldV := semver $versions.old -}}
{{- $newV := semver $versions.new -}}
{{/* If new is v2.x.x */}}
{{- if eq ($newV.Major | int) 2 -}}
{{/* And old is v1.x.x, but lower than .0.18 */}}
{{- if and (eq $oldV.Major 1) (lt ($oldV.Patch | int) 18) -}}
{{/* Block the upgrade */}}
{{- fail "Migration to 2.x.x is only allowed from 1.0.18 or higher" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,63 @@
{{- define "storj.persistence" -}}
persistence:
data:
enabled: true
{{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.storjStorage.data) | nindent 4 }}
targetSelector:
storj:
storj:
mountPath: /app/config
{{- if and (eq .Values.storjStorage.data.type "ixVolume")
(not (.Values.storjStorage.data.ixVolumeConfig | default dict).aclEnable) }}
01-permissions:
mountPath: /mnt/directories/data
{{- end }}
03-setup:
mountPath: /app/config
identity:
enabled: true
{{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.storjStorage.identity) | nindent 4 }}
targetSelector:
storj:
storj:
mountPath: /app/identity
{{- if and (eq .Values.storjStorage.identity.type "ixVolume")
(not (.Values.storjStorage.identity.ixVolumeConfig | default dict).aclEnable) }}
01-permissions:
mountPath: /mnt/directories/identity
{{- end }}
02-generateid:
mountPath: {{ template "storj.idPath" }}
03-setup:
mountPath: /app/identity
initscript:
enabled: true
type: configmap
objectName: storj
defaultMode: "0755"
targetSelector:
storj:
02-generateid:
mountPath: /init_script/init_config.sh
subPath: init_config.sh
tmp:
enabled: true
type: emptyDir
targetSelector:
storj:
storj:
mountPath: /tmp
02-generateid:
mountPath: /tmp
03-setup:
mountPath: /tmp
{{- range $idx, $storage := .Values.storjStorage.additionalStorages }}
{{ printf "storj-%v:" (int $idx) }}
enabled: true
{{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
targetSelector:
storj:
storj:
mountPath: {{ $storage.mountPath }}
{{- end }}
{{- end -}}

View File

@@ -0,0 +1,12 @@
{{- define "storj.portal" -}}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: portal
data:
port: {{ .Values.storjNetwork.webPort | quote }}
path: "/"
protocol: "http"
host: $node_ip
{{- end -}}

View File

@@ -0,0 +1,29 @@
{{- define "storj.service" -}}
service:
storj:
enabled: true
primary: true
type: NodePort
targetSelector: storj
ports:
webui:
enabled: true
primary: true
port: {{ .Values.storjNetwork.webPort }}
nodePort: {{ .Values.storjNetwork.webPort }}
targetPort: 14002
targetSelector: storj
p2p-tcp:
enabled: true
port: {{ .Values.storjNetwork.p2pPort }}
nodePort: {{ .Values.storjNetwork.p2pPort }}
targetPort: 28967
targetSelector: storj
p2p-udp:
enabled: true
port: {{ .Values.storjNetwork.p2pPort }}
nodePort: {{ .Values.storjNetwork.p2pPort }}
targetPort: 28967
protocol: udp
targetSelector: storj
{{- end -}}

View File

@@ -0,0 +1,93 @@
{{- define "storj.workload" -}}
workload:
storj:
enabled: true
primary: true
type: Deployment
podSpec:
hostNetwork: {{ .Values.storjNetwork.hostNetwork }}
terminationGracePeriodSeconds: {{ .Values.storjConfig.gracePeriod }}
containers:
storj:
enabled: true
primary: true
imageSelector: image
securityContext:
runAsUser: {{ .Values.storjRunAs.user }}
runAsGroup: {{ .Values.storjRunAs.group }}
readOnlyRootFilesystem: false
# capabilities:
# add:
# - CHOWN
# - DAC_OVERRIDE
# - FOWNER
# - SETGID
# - SETUID
# - KILL
{{- include "storj.args" $ | nindent 10 }}
envFrom:
- secretRef:
name: storj-config
{{ with .Values.storjConfig.additionalEnvs }}
envList:
{{ range $env := . }}
- name: {{ $env.name }}
value: {{ $env.value }}
{{ end }}
{{ end }}
probes:
liveness:
enabled: false
readiness:
enabled: false
startup:
enabled: false
initContainers:
{{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
"UID" .Values.storjRunAs.user
"GID" .Values.storjRunAs.group
"mode" "check"
"type" "install") | nindent 8 }}
02-generateid:
enabled: true
type: init
imageSelector: curlImage
securityContext:
runAsUser: 0
runAsGroup: 0
runAsNonRoot: false
readOnlyRootFilesystem: false
capabilities:
add:
- CHOWN
- FOWNER
- DAC_OVERRIDE
command:
- /bin/sh
- -c
args:
- ./init_script/init_config.sh
env:
DEFAULT_CERT_PATH: {{ template "storj.idPath" }}/ca.cert
DEFAULT_IDENTITY_CERT_PATH: {{ template "storj.idPath" }}/identity.cert
AUTH_KEY:
secretKeyRef:
name: storj
key: authToken
03-setup:
enabled: true
type: init
imageSelector: image
envFrom:
- secretRef:
name: storj-config
securityContext:
runAsUser: {{ .Values.storjRunAs.user }}
runAsGroup: {{ .Values.storjRunAs.group }}
readOnlyRootFilesystem: false
command:
- /bin/sh
- -c
- |
test ! -f /app/config/config.yaml && export SETUP="true"; /entrypoint
{{- end -}}

View File

@@ -0,0 +1,14 @@
{{- include "ix.v1.common.loader.init" . -}}
{{- include "storj.migration" $ -}}
{{/* Merge the templates with Values */}}
{{- $_ := mustMergeOverwrite .Values (include "storj.workload" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "storj.configuration" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "storj.service" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "storj.persistence" $ | fromYaml) -}}
{{/* Create the configmap for portal manually*/}}
{{- include "storj.portal" $ -}}
{{- include "ix.v1.common.loader.apply" . -}}

View File

@@ -1,109 +0,0 @@
{{ include "common.storage.hostPathValidate" .Values }}
apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "common.names.fullname" . }}-storj
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
{{- $walletFeats := list -}}
{{- if .Values.zksync }}
{{- $walletFeats = mustAppend $walletFeats "zksync" -}}
{{- end -}}
{{ if .Values.zksyncEra }}
{{- $walletFeats = mustAppend $walletFeats "zksync-era" -}}
{{- end -}}
{{- if $walletFeats }}
args:
- --operator.wallet-features={{ join "," $walletFeats }}
{{ 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

@@ -1,18 +0,0 @@
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

@@ -1,28 +0,0 @@
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

@@ -1,11 +0,0 @@
{{ $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

@@ -1,9 +0,0 @@
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,4 @@
# 1.0.18
This version is kept because it contains a fix that is needed for migration to v2.x.x
It should be safe to remove few months after v2.x.x is released.

View File

@@ -0,0 +1 @@
- 1.0.18

View File

@@ -1,5 +1,49 @@
identityCreationMountPath: /root/.local/share/storj/identity/storagenode
image:
pullPolicy: IfNotPresent
repository: storjlabs/storagenode
tag: 1d42f9ac3-v1.68.2-go1.18.8
curlImage:
pullPolicy: IfNotPresent
repository: alpine/curl
tag: latest
podOptions:
dnsConfig:
options: []
resources:
limits:
cpu: 4000m
memory: 8Gi
storjConfig:
wallet: ''
authToken: ''
email: ''
domainAddress: ''
gracePeriod: 30
storageSizeGB: 500
wallets:
zkSync: false
zkSyncEra: false
additionalEnvs: []
storjRunAs:
user: 568
group: 568
storjNetwork:
webPort: 20909
p2pPort: 28967
hostNetwork: false
storjStorage:
data:
type: ixVolume
ixVolumeConfig:
datasetName: data
identity:
type: ixVolume
ixVolumeConfig:
datasetName: identity
additionalStorages: []