Skip to content

Commit

Permalink
NAS-120628 / 23.10 / Add IPFS app to community train (#1023)
Browse files Browse the repository at this point in the history
* Add ipfs to community train

* run chown before config and only once

* fix selector

* update readme(s)

* add update strategy
  • Loading branch information
stavros-k authored Mar 20, 2023
1 parent 6b56e44 commit 010418b
Show file tree
Hide file tree
Showing 17 changed files with 593 additions and 0 deletions.
6 changes: 6 additions & 0 deletions library/ix-dev/community/ipfs/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://../../../common
version: 1.0.0
digest: sha256:f90dc95623b075f1d9ec4c4ba12464e2e789176ce7282a3aede37222201763b6
generated: "2023-03-09T22:30:24.240799718+02:00"
26 changes: 26 additions & 0 deletions library/ix-dev/community/ipfs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ipfs
description: Interplanetary Filesystem - the Web3 standard for content-addressing, interoperable with HTTP
annotations:
title: IPFS
type: application
version: 1.0.0
apiVersion: v2
appVersion: '0.18.1'
kubeVersion: '>=1.16.0-0'
maintainers:
- name: truenas
url: https://www.truenas.com/
dependencies:
- name: common
repository: file://../../../common
version: 1.0.0
home: https://ipfs.tech/
icon: https://avatars.githubusercontent.com/u/10536621
sources:
- https://github.com/ipfs/kubo
- https://github.com/truenas/charts/tree/master/community/ipfs
- https://ipfs.tech/
keywords:
- storage
- ipfs
- kubo
7 changes: 7 additions & 0 deletions library/ix-dev/community/ipfs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# IPFS

[Interplanetary Filesystem](https://ipfs.tech) - the Web3 standard for content-addressing, interoperable with HTTP

> When application is installed, a container will be launched with **root** privileges.
> This is required in order to apply the correct permissions to the ipfs directories.
> Afterward, the `ipfs` container will run as a **non**-root user (Default: `568`).
7 changes: 7 additions & 0 deletions library/ix-dev/community/ipfs/app-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# IPFS

[Interplanetary Filesystem](https://ipfs.tech) - the Web3 standard for content-addressing, interoperable with HTTP

> When application is installed, a container will be launched with **root** privileges.
> This is required in order to apply the correct permissions to the ipfs directories.
> Afterward, the `ipfs` container will run as a **non**-root user (Default: `568`).
Binary file not shown.
9 changes: 9 additions & 0 deletions library/ix-dev/community/ipfs/ci/basic-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ipfsStorage:
data:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/data
datasetName: data
staging:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/staging
datasetName: staging
16 changes: 16 additions & 0 deletions library/ix-dev/community/ipfs/ci/extra-env-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ipfsConfig:
additionalEnvs:
- name: GOLOG_LOG_LEVEL
value: debug
- name: GOLOG_LOG_FMT
value: json

ipfsStorage:
data:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/data
datasetName: data
staging:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/staging
datasetName: staging
11 changes: 11 additions & 0 deletions library/ix-dev/community/ipfs/ci/hostNet-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ipfsStorage:
data:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/data
datasetName: data
staging:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/staging
datasetName: staging
ipfsNetwork:
hostNetwork: true
5 changes: 5 additions & 0 deletions library/ix-dev/community/ipfs/item.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
icon_url: https://avatars.githubusercontent.com/u/10536621
categories:
- storage
- ipfs
- kubo
219 changes: 219 additions & 0 deletions library/ix-dev/community/ipfs/questions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
groups:
- name: IPFS Configuration
description: Configure IPFS
- name: User and Group Configuration
description: Configure User and Group for IPFS
- name: Network Configuration
description: Configure Network for IPFS
- name: Storage Configuration
description: Configure Storage for IPFS
- name: Resources Configuration
description: Configure Resources for IPFS

portals:
web_portal:
protocols:
- "$kubernetes-resource_configmap_portal_protocol"
host:
- "$kubernetes-resource_configmap_portal_host"
ports:
- "$kubernetes-resource_configmap_portal_port"
path: "$kubernetes-resource_configmap_portal_path"

questions:

- variable: ipfsConfig
label: ""
group: IPFS Configuration
schema:
type: dict
attrs:
- variable: additionalEnvs
label: Additional Environment Variables
description: Configure additional environment variables for IPFS.
schema:
type: list
default: []
items:
- variable: env
label: Environment Variable
schema:
type: dict
attrs:
- variable: name
label: Name
schema:
type: string
required: true
- variable: value
label: Value
schema:
type: string
required: true

- variable: ipfsRunAs
label: ""
group: User and Group Configuration
schema:
type: dict
attrs:
- variable: user
label: User ID
description: The user id that IPFS will run as.
schema:
type: int
min: 1
default: 568
required: true
- variable: group
label: Group ID
description: The group id that IPFS will run as.
schema:
type: int
min: 1
default: 568
required: true

- variable: ipfsNetwork
label: ""
group: Network Configuration
schema:
type: dict
attrs:
- variable: apiPort
label: API Port
description: The port for the IPFS API (And WebUI).
schema:
type: int
default: 30000
min: 9000
max: 65535
required: true
- variable: swarmPort
label: Swarm Port
description: The port for the IPFS Swarm. Both TCP and UDP
schema:
type: int
default: 30001
min: 9000
max: 65535
required: true
- variable: gatewayPort
label: Gateway Port
description: The port for the IPFS Gateway.
schema:
type: int
default: 30002
min: 9000
max: 65535
required: true
- variable: hostNetwork
label: Host Network
description: |
Bind to the host network. It's recommended to keep this disabled.
schema:
type: boolean
default: false

- variable: ipfsStorage
label: ""
group: Storage Configuration
schema:
type: dict
attrs:
- variable: data
label: IPFS Data Storage
description: The path to store IPFS data.
schema:
type: dict
attrs:
- variable: type
label: Type
schema:
type: string
required: true
default: ixVolume
enum:
- value: hostPath
description: Host Path
- value: ixVolume
description: ixVolume
- variable: datasetName
label: Dataset Name
schema:
type: string
show_if: [["type", "=", "ixVolume"]]
required: true
hidden: true
immutable: true
default: data
$ref:
- "normalize/ixVolume"
- variable: hostPath
label: Host Path
schema:
type: hostpath
show_if: [["type", "=", "hostPath"]]
immutable: true
required: true
- variable: staging
label: IPFS Staging Storage
description: The path to store IPFS staging storage.
schema:
type: dict
attrs:
- variable: type
label: Type
schema:
type: string
required: true
default: ixVolume
enum:
- value: hostPath
description: Host Path
- value: ixVolume
description: ixVolume
- variable: datasetName
label: Dataset Name
schema:
type: string
show_if: [["type", "=", "ixVolume"]]
required: true
hidden: true
immutable: true
default: staging
$ref:
- "normalize/ixVolume"
- variable: hostPath
label: Host Path
schema:
type: hostpath
show_if: [["type", "=", "hostPath"]]
immutable: true
required: true

- variable: resources
label: ""
group: Resources Configuration
schema:
type: dict
attrs:
- variable: limits
label: Limits
schema:
type: dict
attrs:
- variable: cpu
label: CPU
description: CPU limit for qBittorrent.
schema:
type: string
default: 4000m
required: true
- variable: memory
label: Memory
description: Memory limit for qBittorrent.
schema:
type: string
default: 8Gi
required: true
1 change: 1 addition & 0 deletions library/ix-dev/community/ipfs/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ include "ix.v1.common.lib.chart.notes" $ }}
60 changes: 60 additions & 0 deletions library/ix-dev/community/ipfs/templates/_configuration.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{{- define "ipfs.configuration" -}}
{{/* Default Swarm Addresses https://github.com/ipfs/kubo/blob/master/docs/config.md#addressesswarm */}}
{{ $swarmAddressesList := (list
(printf "/ip4/0.0.0.0/tcp/%v" .Values.ipfsNetwork.swarmPort)
(printf "/ip6/::/tcp/%v" .Values.ipfsNetwork.swarmPort)
(printf "/ip4/0.0.0.0/udp/%v/quic" .Values.ipfsNetwork.swarmPort)
(printf "/ip4/0.0.0.0/udp/%v/quic-v1" .Values.ipfsNetwork.swarmPort)
(printf "/ip4/0.0.0.0/udp/%v/quic-v1/webtransport" .Values.ipfsNetwork.swarmPort)
(printf "/ip6/::/udp/%v/quic" .Values.ipfsNetwork.swarmPort)
(printf "/ip6/::/udp/%v/quic-v1" .Values.ipfsNetwork.swarmPort)
(printf "/ip6/::/udp/%v/quic-v1/webtransport" .Values.ipfsNetwork.swarmPort)
) }}

{{ $swarmAddresses := printf "[ \"%s\" ]" (join "\", \"" $swarmAddressesList) }}

{{/* Default API Address https://github.com/ipfs/kubo/blob/master/docs/config.md#addressesapi */}}
{{ $apiAddresses := printf "/ip4/0.0.0.0/tcp/%v" .Values.ipfsNetwork.apiPort }}
{{/* Default Gateway Address https://github.com/ipfs/kubo/blob/master/docs/config.md#addressesgateway */}}
{{ $gatewayAddresses := printf "/ip4/0.0.0.0/tcp/%v" .Values.ipfsNetwork.gatewayPort }}
{{ $allowOrigins := "[ \"*\" ]" }}
{{ $allowMethods := "[ \"PUT\", \"POST\" ]" }}


{{/* Configmaps */}}
configmap:
config-script:
enabled: true
data:
init-config.sh: |
#!/bin/sh
set -e

if [ ! -f /data/ipfs/config ]; then
# Create the IPFS config file
echo "Initializing IPFS"
ipfs init
fi

# Configure the Addresses.API
echo "Configuring the Addresses.API to {{ $apiAddresses }}"
ipfs config Addresses.API {{ $apiAddresses }}

# Configure the Addresses.Gateway
echo "Configuring the Addresses.Gateway to {{ $gatewayAddresses }}"
ipfs config Addresses.Gateway {{ $gatewayAddresses }}

# Configure the Addresses.Swarm
echo "Configuring the Addresses.Swarm to {{ $swarmAddresses | squote }}"
ipfs config Addresses.Swarm --json {{ $swarmAddresses | squote }}

# Configure the API.HTTPHeaders.Access-Control-Allow-Origin
echo "Configuring the API.HTTPHeaders.Access-Control-Allow-Origin to {{ $allowOrigins | squote }}"
ipfs config API.HTTPHeaders.Access-Control-Allow-Origin --json {{ $allowOrigins | squote }}

# Configure the API.HTTPHeaders.Access-Control-Allow-Methods
echo "Configuring the API.HTTPHeaders.Access-Control-Allow-Methods to {{ $allowMethods | squote }}"
ipfs config API.HTTPHeaders.Access-Control-Allow-Methods --json {{ $allowMethods | squote }}

echo "Finished configuring IPFS"
{{- end -}}
Loading

0 comments on commit 010418b

Please sign in to comment.