├── .circleci └── config.yml ├── .gitignore ├── LICENSE ├── README.md ├── charts └── ipfs-cluster │ ├── Chart.yaml │ ├── templates │ ├── _helpers.tpl │ ├── configmap-bootstrap.yaml │ ├── configmap-env.yaml │ ├── ingress.yaml │ ├── secret.yaml │ ├── service.yaml │ └── statefulset.yaml │ └── values.yaml ├── helmfile.d ├── 10-ipfs-cluster.yaml └── config │ ├── ipfs-cluster-values-ci.yaml.gotmpl │ └── ipfs-cluster-values-production.yaml.gotmpl └── scripts ├── integration-tests.sh └── start-kind-local-registry.sh /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | jobs: 4 | 5 | helmLint: 6 | docker: 7 | - image: web3f/ci-commons:v3.1.6 8 | steps: 9 | - checkout 10 | - run: 11 | command: | 12 | helm lint ./charts/ipfs-cluster 13 | 14 | integrationTests: 15 | docker: 16 | - image: web3f/ci-commons:v3.1.6 17 | steps: 18 | - checkout 19 | - setup_remote_docker: 20 | version: 20.10.7 21 | - run: 22 | description: run integration tests 23 | command: | 24 | /scripts/integration-tests.sh kindest/node:v1.19.11 25 | 26 | publishChart: 27 | docker: 28 | - image: web3f/ci-commons:v3.1.6 29 | steps: 30 | - checkout 31 | - run: 32 | command: | 33 | /scripts/publish-chart.sh 34 | 35 | deploy: 36 | environment: 37 | HELM_ENV: production 38 | docker: 39 | - image: web3f/ci-commons:v3.1.6 40 | steps: 41 | - checkout 42 | - setup_remote_docker 43 | - run: 44 | command: | 45 | /scripts/deploy.sh -c community 46 | 47 | workflows: 48 | version: 2 49 | test_and_deploy: 50 | jobs: 51 | - helmLint: 52 | filters: 53 | tags: 54 | only: /.*/ 55 | - integrationTests: 56 | filters: 57 | tags: 58 | only: /.*/ 59 | requires: 60 | - helmLint 61 | - publishChart: 62 | context: github-bot 63 | requires: 64 | - integrationTests 65 | filters: 66 | branches: 67 | ignore: /.*/ 68 | tags: 69 | only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ 70 | - deploy: 71 | context: 72 | - digital_ocean_access 73 | - vault_community 74 | filters: 75 | branches: 76 | ignore: /.*/ 77 | tags: 78 | only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ 79 | requires: 80 | - publishChart -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3f/ipfs-cluster-chart/4e46c8e9d60e412bc32cff410f76a849002fcccc/.gitignore -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![CircleCI](https://circleci.com/gh/w3f/ipfs-cluster-chart.svg?style=svg)](https://circleci.com/gh/w3f/ipfs-cluster-chart) 2 | 3 | # ipfs-cluster-chart 4 | Helm Chart for: https://cluster.ipfs.io/documentation/guides/k8s/ 5 | 6 | ## NOTE 7 | 8 | The chart is inspired from: 9 | - https://github.com/ipfs/ipfs-cluster-website/blob/1258134676f5293422eb97b702ae56b207261e62/content/documentation/guides/k8s.md 10 | - https://cluster.ipfs.io/documentation/guides/k8s/ -------------------------------------------------------------------------------- /charts/ipfs-cluster/Chart.yaml: -------------------------------------------------------------------------------- 1 | description: IPFS Cluster chart 2 | name: ipfs-cluster 3 | version: v0.0.7 4 | apiVersion: v2 5 | -------------------------------------------------------------------------------- /charts/ipfs-cluster/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* Returns the cluster secret name */}} 2 | {{- define "ipfs-cluster.secretName" -}} 3 | {{ .Release.Name }} 4 | {{- end }} 5 | 6 | {{/* Returns the configmap env name */}} 7 | {{- define "ipfs-cluster.configmapEnvName" -}} 8 | {{ .Release.Name }}-env 9 | {{- end }} 10 | 11 | {{/* Returns the configmap bootstrap name */}} 12 | {{- define "ipfs-cluster.configmapBootstrapName" -}} 13 | {{ .Release.Name }}-bootstrap 14 | {{- end }} 15 | 16 | {{/* Returns the statefulset name */}} 17 | {{- define "ipfs-cluster.statefulsetName" -}} 18 | {{ .Release.Name }} 19 | {{- end }} 20 | 21 | {{/* Returns the service name */}} 22 | {{- define "ipfs-cluster.serviceName" -}} 23 | {{ .Release.Name }} 24 | {{- end }} 25 | 26 | {{/* Returns the service name http */}} 27 | {{- define "ipfs-cluster.serviceNameHttp" -}} 28 | {{ .Release.Name }}-http 29 | {{- end }} 30 | 31 | {{/* Returns the service name local */}} 32 | {{- define "ipfs-cluster.serviceNameLocal" -}} 33 | {{ .Release.Name }}-local 34 | {{- end }} -------------------------------------------------------------------------------- /charts/ipfs-cluster/templates/configmap-bootstrap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ include "ipfs-cluster.configmapBootstrapName" . }} 5 | data: 6 | entrypoint.sh: | 7 | #!/bin/sh 8 | #set -e 9 | set -x 10 | user=ipfs 11 | 12 | # This is a custom entrypoint for k8s designed to connect to the bootstrap 13 | # node running in the cluster. It has been set up using a configmap to 14 | # allow changes on the fly. 15 | 16 | 17 | if [ ! -f /data/ipfs-cluster/service.json ]; then 18 | ipfs-cluster-service init 19 | fi 20 | 21 | PEER_HOSTNAME=`cat /proc/sys/kernel/hostname` 22 | 23 | grep -q ".*ipfs-cluster-0.*" /proc/sys/kernel/hostname 24 | if [ $? -eq 0 ]; then 25 | CLUSTER_ID=${BOOTSTRAP_PEER_ID} \ 26 | CLUSTER_PRIVATEKEY=${BOOTSTRAP_PEER_PRIV_KEY} \ 27 | exec ipfs-cluster-service daemon --upgrade 28 | else 29 | BOOTSTRAP_ADDR=/dns4/${SVC_NAME}-0.${SVC_NAME}/tcp/9096/ipfs/${BOOTSTRAP_PEER_ID} 30 | 31 | if [ -z $BOOTSTRAP_ADDR ]; then 32 | exit 1 33 | fi 34 | # Only ipfs user can get here 35 | exec ipfs-cluster-service daemon --upgrade --bootstrap $BOOTSTRAP_ADDR --leave 36 | fi 37 | 38 | configure-ipfs.sh: | 39 | #!/bin/sh 40 | set -e 41 | set -x 42 | user=ipfs 43 | repo=/data/ipfs 44 | # This is a custom entrypoint for k8s designed to run ipfs nodes in an appropriate 45 | # setup for production scenarios. 46 | 47 | mkdir -p /data/ipfs && chown -R ipfs /data/ipfs 48 | 49 | if [ `id -u` -eq 0 ]; then 50 | echo "Changing user to $user" 51 | # ensure folder is writable 52 | su-exec "$user" test -w "$repo" || chown -R -- "$user" "$repo" 53 | # restart script with new privileges 54 | exec su-exec "$user" sh "$0" "$@" 55 | fi 56 | 57 | if [ -f /data/ipfs/config ]; then 58 | if [ -f /data/ipfs/repo.lock ]; then 59 | rm /data/ipfs/repo.lock 60 | fi 61 | exit 0 62 | fi 63 | 64 | ipfs init --profile=badgerds,server 65 | ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 66 | ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 67 | ipfs config --json Swarm.ConnMgr.HighWater 2000 68 | ipfs config --json Datastore.BloomFilterSize 1048576 69 | ipfs config Datastore.StorageMax 100GB 70 | ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' 71 | ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]' -------------------------------------------------------------------------------- /charts/ipfs-cluster/templates/configmap-env.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ include "ipfs-cluster.configmapEnvName" . }} 5 | data: 6 | bootstrap-peer-id: {{ .Values.bootstrapPeerId }} -------------------------------------------------------------------------------- /charts/ipfs-cluster/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: {{ .Release.Name }} 5 | annotations: 6 | external-dns.alpha.kubernetes.io/cloudflare-proxied: "true" 7 | kubernetes.io/ingress.class: "nginx" 8 | cert-manager.io/cluster-issuer: letsencrypt 9 | nginx.ingress.kubernetes.io/rewrite-target: /$1 10 | spec: 11 | tls: 12 | - hosts: 13 | - {{ .Values.httpDomain }} 14 | secretName: {{ .Release.Name }}-tls 15 | rules: 16 | - host: {{ .Values.httpDomain }} 17 | http: 18 | paths: 19 | - path: /(.+) 20 | pathType: Prefix 21 | backend: 22 | service: 23 | name: {{ include "ipfs-cluster.serviceNameHttp" . }} 24 | port: 25 | name: gateway 26 | -------------------------------------------------------------------------------- /charts/ipfs-cluster/templates/secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: {{ include "ipfs-cluster.secretName" . }} 5 | type: Opaque 6 | data: 7 | cluster-secret: {{ .Values.clusterSecret | b64enc }} 8 | bootstrap-peer-priv-key: {{ .Values.bootstrapPeerPrivateKey | b64enc }} -------------------------------------------------------------------------------- /charts/ipfs-cluster/templates/service.yaml: -------------------------------------------------------------------------------- 1 | # Exposed 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: {{ include "ipfs-cluster.serviceName" . }} 6 | annotations: 7 | external-dns.alpha.kubernetes.io/hostname: {{ .Values.domain }} 8 | labels: 9 | node: {{ .Release.Name }} 10 | spec: 11 | type: LoadBalancer 12 | ports: 13 | - name: swarm 14 | targetPort: swarm 15 | port: 4001 16 | - name: swarm-udp 17 | targetPort: swarm-udp 18 | port: 4002 19 | - name: cluster-swarm 20 | targetPort: cluster-swarm 21 | port: 9096 #public with secret protection 22 | selector: 23 | app: {{ .Release.Name }} 24 | --- 25 | # Exposed behind Proxy 26 | apiVersion: v1 27 | kind: Service 28 | metadata: 29 | name: {{ include "ipfs-cluster.serviceNameHttp" . }} 30 | labels: 31 | node: {{ .Release.Name }} 32 | spec: 33 | ports: 34 | - name: gateway 35 | targetPort: gateway 36 | port: 8080 37 | selector: 38 | app: {{ .Release.Name }} 39 | --- 40 | # Not Exposed 41 | apiVersion: v1 42 | kind: Service 43 | metadata: 44 | name: {{ include "ipfs-cluster.serviceNameLocal" . }} 45 | labels: 46 | node: {{ .Release.Name }} 47 | spec: 48 | ports: 49 | - name: api 50 | targetPort: api 51 | port: 5001 52 | - name: proxy-http 53 | targetPort: proxy-http 54 | port: 9095 55 | - name: ws 56 | targetPort: ws 57 | port: 8081 58 | - name: api-http 59 | targetPort: api-http 60 | port: 9094 61 | selector: 62 | app: {{ .Release.Name }} -------------------------------------------------------------------------------- /charts/ipfs-cluster/templates/statefulset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: {{ include "ipfs-cluster.statefulsetName" . }} 5 | labels: 6 | app: {{ .Release.Name }} 7 | spec: 8 | replicas: {{ .Values.replicaCount }} 9 | revisionHistoryLimit: 3 10 | updateStrategy: 11 | type: RollingUpdate 12 | selector: 13 | matchLabels: 14 | app: {{ .Release.Name }} 15 | serviceName: {{ include "ipfs-cluster.serviceName" . }} 16 | template: 17 | metadata: 18 | labels: 19 | app: {{ .Release.Name }} 20 | annotations: 21 | checksum/config-bootstrap: {{ include (print $.Template.BasePath "/configmap-bootstrap.yaml") . | sha256sum }} 22 | checksum/config-env: {{ include (print $.Template.BasePath "/configmap-env.yaml") . | sha256sum }} 23 | spec: 24 | initContainers: 25 | - name: configure-ipfs 26 | image: {{ .Values.ipfsImage.repo }}:{{ .Values.ipfsImage.tag }} 27 | command: ["sh", "/custom/configure-ipfs.sh"] 28 | volumeMounts: 29 | - name: ipfs-storage 30 | mountPath: /data/ipfs 31 | - name: configure-script 32 | mountPath: /custom 33 | containers: 34 | - name: ipfs 35 | image: {{ .Values.ipfsImage.repo }}:{{ .Values.ipfsImage.tag }} 36 | imagePullPolicy: IfNotPresent 37 | env: 38 | - name: IPFS_FD_MAX 39 | value: "4096" 40 | ports: 41 | - name: swarm 42 | protocol: TCP 43 | containerPort: 4001 44 | - name: swarm-udp 45 | protocol: UDP 46 | containerPort: 4002 47 | - name: api 48 | protocol: TCP 49 | containerPort: 5001 50 | - name: ws 51 | protocol: TCP 52 | containerPort: 8081 53 | - name: gateway 54 | protocol: TCP 55 | containerPort: 8080 56 | livenessProbe: 57 | tcpSocket: 58 | port: swarm 59 | initialDelaySeconds: 30 60 | timeoutSeconds: 5 61 | periodSeconds: 15 62 | volumeMounts: 63 | - name: ipfs-storage 64 | mountPath: /data/ipfs 65 | - name: configure-script 66 | mountPath: /custom 67 | resources: 68 | {} 69 | - name: ipfs-cluster 70 | image: {{ .Values.ipfsClusterImage.repo }}:{{ .Values.ipfsClusterImage.tag }} 71 | imagePullPolicy: IfNotPresent 72 | command: ["sh", "/custom/entrypoint.sh"] 73 | envFrom: 74 | - configMapRef: 75 | name: {{ include "ipfs-cluster.configmapEnvName" . }} 76 | env: 77 | - name: BOOTSTRAP_PEER_ID 78 | valueFrom: 79 | configMapKeyRef: 80 | name: {{ include "ipfs-cluster.configmapEnvName" . }} 81 | key: bootstrap-peer-id 82 | - name: BOOTSTRAP_PEER_PRIV_KEY 83 | valueFrom: 84 | secretKeyRef: 85 | name: {{ include "ipfs-cluster.secretName" . }} 86 | key: bootstrap-peer-priv-key 87 | - name: CLUSTER_SECRET 88 | valueFrom: 89 | secretKeyRef: 90 | name: {{ include "ipfs-cluster.secretName" . }} 91 | key: cluster-secret 92 | - name: CLUSTER_MONITOR_PING_INTERVAL 93 | value: "3m" 94 | - name: CLUSTER_RESTAPI_LIBP2PLISTENMULTIADDRESS 95 | value: "/ip4/0.0.0.0/tcp/9096" 96 | - name: CLUSTER_RESTAPI_ID 97 | value: {{ .Values.clusterRestApiId }} 98 | - name: CLUSTER_RESTAPI_PRIVATEKEY 99 | value: {{ .Values.clusterRestApiPrivateKey }} 100 | - name: CLUSTER_RESTAPI_BASICAUTHCREDENTIALS 101 | value: {{ .Values.clusterRestApiBasicAuth }} 102 | - name: CLUSTER_CRDT_TRUSTEDPEERS 103 | value: {{ .Values.clusterCRDTtrustedPeers }} 104 | - name: SVC_NAME 105 | value: {{ include "ipfs-cluster.serviceName" . }} 106 | ports: 107 | - name: api-http 108 | containerPort: 9094 109 | protocol: TCP 110 | - name: proxy-http 111 | containerPort: 9095 112 | protocol: TCP 113 | - name: cluster-swarm 114 | containerPort: 9096 115 | protocol: TCP 116 | livenessProbe: 117 | tcpSocket: 118 | port: cluster-swarm 119 | initialDelaySeconds: 5 120 | timeoutSeconds: 5 121 | periodSeconds: 10 122 | volumeMounts: 123 | - name: cluster-storage 124 | mountPath: /data/ipfs-cluster 125 | - name: configure-script 126 | mountPath: /custom 127 | resources: 128 | {} 129 | volumes: 130 | - name: configure-script 131 | configMap: 132 | name: {{ include "ipfs-cluster.configmapBootstrapName" . }} 133 | {{ if ne .Values.persistence.enabled true }} 134 | - name: cluster-storage 135 | emptyDir: {} 136 | - name: ipfs-storage 137 | emptyDir: {} 138 | {{ else }} 139 | volumeClaimTemplates: 140 | - metadata: 141 | name: cluster-storage 142 | spec: 143 | accessModes: ["ReadWriteOnce"] 144 | resources: 145 | requests: 146 | storage: {{ .Values.persistence.clusterStorage }} 147 | - metadata: 148 | name: ipfs-storage 149 | spec: 150 | accessModes: ["ReadWriteOnce"] 151 | resources: 152 | requests: 153 | storage: {{ .Values.persistence.ipfsStorage }} 154 | {{ end }} -------------------------------------------------------------------------------- /charts/ipfs-cluster/values.yaml: -------------------------------------------------------------------------------- 1 | ipfsImage: 2 | repo: ipfs/go-ipfs 3 | tag: v0.10.0 4 | 5 | ipfsClusterImage: 6 | repo: ipfs/ipfs-cluster 7 | tag: v0.14.1 8 | 9 | #### secretes examples ##### 10 | #https://cluster.ipfs.io/documentation/guides/k8s/ 11 | 12 | #od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n' 13 | clusterSecret: 1ec8276f98cf47c16acfd9bf39fca38f8e3cfcbe229530a7ba9f08ef9757c439 14 | 15 | #go get github.com/whyrusleeping/ipfs-key 16 | #ipfs-key --type Ed25519 | base64 17 | bootstrapPeerPrivateKey: CAESQKyMCUbsfSRq8NBOFQOxv9uvgXm1zvSHyThj3AQV6UBHvTJ+TbTrk1Z6639aE6FOSMGbAG+besQOtk5SPsP2Gxo= 18 | bootstrapPeerId: 12D3KooWNYut1XL31b4KUnCZmC8Mu7WqGn6QdwnptGpS5tnhSttR 19 | 20 | clusterRestApiId: 12D3KooWMfXzp2nmNrb7DM4PETYZbaKALnrnwiqnhvrUC66KyYrb 21 | clusterRestApiPrivateKey: CAESQEmvGJbMboEibpcWCTKOtDYU2eEyyHLN9gDdJli6Z2tksAkhFWNx0Fk3vOlwLIitE2rfGtIj61Ovla/mHC42Plg= 22 | clusterRestApiBasicAuth: "w3f:password" 23 | 24 | clusterCRDTtrustedPeers: "12D3KooWNYut1XL31b4KUnCZmC8Mu7WqGn6QdwnptGpS5tnhSttR,12D3KooWNYut1XL31b4KUnCZmC8Mu7WqGn6QdwnptGpS5tnhSttR" 25 | ################## 26 | 27 | replicaCount: 1 28 | 29 | domain: ipfs.w3f.community 30 | httpDomain: ipfs-gateway.w3f.community 31 | 32 | persistence: 33 | enabled: true 34 | clusterStorage: 5Gi 35 | ipfsStorage: 200Gi -------------------------------------------------------------------------------- /helmfile.d/10-ipfs-cluster.yaml: -------------------------------------------------------------------------------- 1 | environments: 2 | ci: 3 | local: 4 | production: 5 | 6 | repositories: 7 | - name: w3f 8 | url: https://w3f.github.io/helm-charts/ 9 | 10 | releases: 11 | 12 | - name: ipfs-cluster 13 | {{ if eq .Environment.Name "production" }} 14 | chart: w3f/ipfs-cluster 15 | namespace: ipfs 16 | version: v0.0.7 17 | {{ else }} 18 | chart: ../charts/ipfs-cluster 19 | {{ end }} 20 | values: 21 | - ./config/ipfs-cluster-values-{{ .Environment.Name }}.yaml.gotmpl 22 | -------------------------------------------------------------------------------- /helmfile.d/config/ipfs-cluster-values-ci.yaml.gotmpl: -------------------------------------------------------------------------------- 1 | environment: {{ .Environment.Name }} 2 | 3 | image: 4 | tag: {{ env "CIRCLE_SHA1" | default "kind" }} 5 | -------------------------------------------------------------------------------- /helmfile.d/config/ipfs-cluster-values-production.yaml.gotmpl: -------------------------------------------------------------------------------- 1 | environment: {{ .Environment.Name }} 2 | 3 | persistence: 4 | enabled: true 5 | 6 | replicaCount: 2 7 | 8 | clusterSecret: {{ "ref+vault://op/vaults/k8s-community-secrets/items/ipfs-cluster-secret?proto=http#password" | fetchSecretValue }} 9 | bootstrapPeerPrivateKey: {{ "ref+vault://op/vaults/k8s-community-secrets/items/ipfs-boostrap-peer-privkey?proto=http#password" | fetchSecretValue }} 10 | bootstrapPeerId: {{ "ref+vault://op/vaults/k8s-community-secrets/items/ipfs-boostrap-peer-id?proto=http#password" | fetchSecretValue }} 11 | 12 | clusterRestApiId: {{ "ref+vault://op/vaults/k8s-community-secrets/items/ipfs-cluster-restapi-id?proto=http#password" | fetchSecretValue }} 13 | clusterRestApiPrivateKey: {{ "ref+vault://op/vaults/k8s-community-secrets/items/ipfs-cluster-restapi-privkey?proto=http#password" | fetchSecretValue }} 14 | clusterRestApiBasicAuth: {{ "ref+vault://op/vaults/k8s-community-secrets/items/ipfs-cluster-restapi-basicauth?proto=http#password" | fetchSecretValue }} 15 | clusterCRDTtrustedPeers: {{ "ref+vault://op/vaults/k8s-community-secrets/items/ipfs-cluster-crdt-peers?proto=http#password" | fetchSecretValue }} 16 | -------------------------------------------------------------------------------- /scripts/integration-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /scripts/common.sh 4 | source /scripts/bootstrap-helm.sh 5 | 6 | 7 | run_tests() { 8 | echo Running tests... 9 | 10 | wait_pod_ready ipfs-cluster default 2/2 11 | } 12 | 13 | 14 | main(){ 15 | 16 | /scripts/build-helmfile.sh 17 | 18 | run_tests 19 | } 20 | 21 | main 22 | -------------------------------------------------------------------------------- /scripts/start-kind-local-registry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | 4 | #here the guide: https://kind.sigs.k8s.io/docs/user/local-registry/ 5 | 6 | # create registry container unless it already exists 7 | reg_name='kind-registry' 8 | reg_port='5000' 9 | running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" 10 | if [ "${running}" != 'true' ]; then 11 | docker run \ 12 | -d --restart=always -p "${reg_port}:5000" --name "${reg_name}" \ 13 | registry:2 14 | fi 15 | 16 | # create a cluster with the local registry enabled in containerd 17 | cat <