Skip to content

Commit

Permalink
more work
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros-k committed Mar 6, 2023
1 parent 2397e21 commit caeb99a
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/ct-install-config/charts-ct-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ debug: false
upgrade: true
chart-dirs:
- library/enterprise
- library/community
excluded-charts:
- library/common-test
- library/common
1 change: 1 addition & 0 deletions .github/ct-install-config/charts-ct-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ check-version-increment: true
debug: true
chart-dirs:
- library/enterprise
- library/community
excluded-charts:
- library/common-test
- library/common
Binary file modified library/community/ipfs/charts/common-1.0.0.tgz
Binary file not shown.
51 changes: 51 additions & 0 deletions library/community/ipfs/templates/_configuration.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{- define "ipfs.configuration" -}}
{{ $swarmAddresses := (list
"/ip4/0.0.0.0/tcp/{{ .Values.ipfs.network.swarmPort }}"
"/ip6/::/tcp/{{ .Values.ipfs.network.swarmPort }}"
"/ip4/0.0.0.0/udp/{{ .Values.ipfs.network.swarmPort }}/quic"
"/ip4/0.0.0.0/udp/{{ .Values.ipfs.network.swarmPort }}/quic-v1"
"/ip4/0.0.0.0/udp/{{ .Values.ipfs.network.swarmPort }}/quic-v1/webtransport"
"/ip6/::/udp/{{ .Values.ipfs.network.swarmPort }}/quic"
"/ip6/::/udp/{{ .Values.ipfs.network.swarmPort }}/quic-v1"
"/ip6/::/udp/{{ .Values.ipfs.network.swarmPort }}/quic-v1/webtransport"
) }}
{{ $apiAddresses := "/ip4/127.0.0.1/tcp/{{ .Values.ipfs.network.apiPort }}" }}
{{ $gatewayAddresses := "/ip4/127.0.0.1/tcp/{{ .Values.ipfs.network.gatewayPort }}" }}

{{/* 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 '[ "{{ join "\",\"" $swarmAddresses }}" ]'"
ipfs config Addresses.Swarm --json '[ "{{ join "\",\"" $swarmAddresses }}" ]'

# Configure the API.HTTPHeaders.Access-Control-Allow-Origin
echo "Configuring the API.HTTPHeaders.Access-Control-Allow-Origin to '[ \"*\" ]'"
ipfs config API.HTTPHeaders.Access-Control-Allow-Origin --json '[ "*" ]'

# Configure the API.HTTPHeaders.Access-Control-Allow-Methods
echo "Configuring the API.HTTPHeaders.Access-Control-Allow-Methods to '[ \"PUT\", \"POST\" ]'"
ipfs config API.HTTPHeaders.Access-Control-Allow-Methods --json '[ "PUT", "POST" ]'

echo "Finished configuring IPFS"
{{- end -}}
37 changes: 31 additions & 6 deletions library/community/ipfs/templates/_ipfs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ workload:
securityContext:
runAsUser: 1000
runAsGroup: 100
# envFrom:
# - configMapRef:
# name: qbit-config
probes:
liveness:
enabled: true
Expand All @@ -43,8 +40,20 @@ workload:
- stat
- /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
initContainers:
{{- include "ix.v1.common.app.permissions" (dict "UID" 1000 "GID" 100 "type" "init") | nindent 8 -}}

{{- include "ix.v1.common.app.permissions" (dict "UID" 1000 "GID" 100 "type" "init") | nindent 8 }}
# zz prefix is used to ensure this container runs after the permissions container
zz-init-config:
enabled: true
type: init
imageSelector: image
securityContext:
runAsUser: 1000
runAsGroup: 100
command: /init-config.sh
resources:
limits:
memory: 512Mi
cpu: 1000m
{{/* Service */}}
service:
ipfs:
Expand All @@ -53,7 +62,7 @@ service:
type: NodePort
targetSelector: ipfs
ports:
webui:
api:
enabled: true
primary: true
port: {{ .Values.ipfs.network.apiPort }}
Expand Down Expand Up @@ -102,6 +111,8 @@ persistence:
mountPath: /data/ipfs
permissions:
mountPath: /mnt/directories/data
zz-init-config:
mountPath: /data/ipfs
staging:
enabled: true
type: {{ .Values.ipfs.storage.staging.type }}
Expand All @@ -113,4 +124,18 @@ persistence:
mountPath: /export
permissions:
mountPath: /mnt/directories/export
{{ if .Release.IsInstall }}
config-script:
enabled: true
type: configmap
objectName: config-script
defaultMode: "0755"
targetSelector:
ipfs:
zz-init-config:
mountPath: /init-config.sh
readOnly: true
subPath: init-config.sh
{{ end }}

{{- end -}}
2 changes: 1 addition & 1 deletion library/community/ipfs/templates/_portal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kind: ConfigMap
metadata:
name: portal
data:
path: "/"
path: /webui
port: {{ .Values.ipfs.network.apiPort | quote }}
protocol: http
host: $node_ip
Expand Down
1 change: 1 addition & 0 deletions library/community/ipfs/templates/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

{{/* Merge the templates with Values */}}
{{- $_ := mustMergeOverwrite .Values (include "ipfs.workload" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "ipfs.configuration" $ | fromYaml) -}}

{{/* Create the configmap for portal manually*/}}
{{- include "ipfs.portal" $ -}}
Expand Down

0 comments on commit caeb99a

Please sign in to comment.