_configuration.tpl 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {{- define "ipfs.configuration" -}}
  2. {{/* Default Swarm Addresses https://github.com/ipfs/kubo/blob/master/docs/config.md#addressesswarm */}}
  3. {{ $swarmAddressesList := (list
  4. (printf "/ip4/0.0.0.0/tcp/%v" .Values.ipfsNetwork.swarmPort)
  5. (printf "/ip6/::/tcp/%v" .Values.ipfsNetwork.swarmPort)
  6. (printf "/ip4/0.0.0.0/udp/%v/quic" .Values.ipfsNetwork.swarmPort)
  7. (printf "/ip4/0.0.0.0/udp/%v/quic-v1" .Values.ipfsNetwork.swarmPort)
  8. (printf "/ip4/0.0.0.0/udp/%v/quic-v1/webtransport" .Values.ipfsNetwork.swarmPort)
  9. (printf "/ip6/::/udp/%v/quic" .Values.ipfsNetwork.swarmPort)
  10. (printf "/ip6/::/udp/%v/quic-v1" .Values.ipfsNetwork.swarmPort)
  11. (printf "/ip6/::/udp/%v/quic-v1/webtransport" .Values.ipfsNetwork.swarmPort)
  12. ) }}
  13. {{ $swarmAddresses := printf "[ \"%s\" ]" (join "\", \"" $swarmAddressesList) }}
  14. {{/* Default API Address https://github.com/ipfs/kubo/blob/master/docs/config.md#addressesapi */}}
  15. {{ $apiAddresses := printf "/ip4/0.0.0.0/tcp/%v" .Values.ipfsNetwork.apiPort }}
  16. {{/* Default Gateway Address https://github.com/ipfs/kubo/blob/master/docs/config.md#addressesgateway */}}
  17. {{ $gatewayAddresses := printf "/ip4/0.0.0.0/tcp/%v" .Values.ipfsNetwork.gatewayPort }}
  18. {{ $allowOrigins := "[ \"*\" ]" }}
  19. {{ $allowMethods := "[ \"PUT\", \"POST\" ]" }}
  20. {{/* Configmaps */}}
  21. configmap:
  22. config-script:
  23. enabled: true
  24. data:
  25. init-config.sh: |
  26. #!/bin/sh
  27. set -e
  28. if [ ! -f /data/ipfs/config ]; then
  29. # Create the IPFS config file
  30. echo "Initializing IPFS"
  31. ipfs init
  32. fi
  33. # Configure the Addresses.API
  34. echo "Configuring the Addresses.API to {{ $apiAddresses }}"
  35. ipfs config Addresses.API {{ $apiAddresses }}
  36. # Configure the Addresses.Gateway
  37. echo "Configuring the Addresses.Gateway to {{ $gatewayAddresses }}"
  38. ipfs config Addresses.Gateway {{ $gatewayAddresses }}
  39. # Configure the Addresses.Swarm
  40. echo "Configuring the Addresses.Swarm to {{ $swarmAddresses | squote }}"
  41. ipfs config Addresses.Swarm --json {{ $swarmAddresses | squote }}
  42. # Configure the API.HTTPHeaders.Access-Control-Allow-Origin
  43. echo "Configuring the API.HTTPHeaders.Access-Control-Allow-Origin to {{ $allowOrigins | squote }}"
  44. ipfs config API.HTTPHeaders.Access-Control-Allow-Origin --json {{ $allowOrigins | squote }}
  45. # Configure the API.HTTPHeaders.Access-Control-Allow-Methods
  46. echo "Configuring the API.HTTPHeaders.Access-Control-Allow-Methods to {{ $allowMethods | squote }}"
  47. ipfs config API.HTTPHeaders.Access-Control-Allow-Methods --json {{ $allowMethods | squote }}
  48. echo "Finished configuring IPFS"
  49. {{- end -}}