Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Recreated helms charts for IPFS #6157

Merged
merged 3 commits into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/ops/ipfs/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
14 changes: 14 additions & 0 deletions packages/ops/ipfs/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
Thank you for installing IPFS by XRFoundation

1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "ipfs.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 9095:
echo "Visit your application at above port"
{{- end }}

We would love to hear your feedback:
- contact us on https://xrfoundation.io/
- join our Discord on https://discord.gg/xrf

85 changes: 67 additions & 18 deletions packages/ops/ipfs/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,34 +1,83 @@
{{/* Returns the cluster secret name */}}
{{- define "ipfs-cluster.secretName" -}}
{{ .Release.Name }}
{{/*
Expand the name of the chart.
*/}}
{{- define "ipfs.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "ipfs.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "ipfs.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "ipfs.labels" -}}
helm.sh/chart: {{ include "ipfs.chart" . }}
{{ include "ipfs.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/* Returns the configmap env name */}}
{{- define "ipfs-cluster.configmapEnvName" -}}
{{- define "ipfs.configmapEnvName" -}}
{{ .Release.Name }}-env
{{- end }}

{{/* Returns the configmap bootstrap name */}}
{{- define "ipfs-cluster.configmapBootstrapName" -}}
{{- define "ipfs.configmapBootstrapName" -}}
{{ .Release.Name }}-bootstrap
{{- end }}

{{/* Returns the statefulset name */}}
{{- define "ipfs-cluster.statefulsetName" -}}
{{ .Release.Name }}
{{/* Returns the storage cluster name */}}
{{- define "ipfs.storageClusterName" -}}
{{ .Release.Name }}-cluster
{{- end }}

{{/* Returns the service name */}}
{{- define "ipfs-cluster.serviceName" -}}
{{ .Release.Name }}
{{/* Returns the storage ipfs name */}}
{{- define "ipfs.storageIpfsName" -}}
{{ .Release.Name }}-ipfs
{{- end }}

{{/* Returns the service name http */}}
{{- define "ipfs-cluster.serviceNameHttp" -}}
{{ .Release.Name }}-http

{{/*
Selector labels
*/}}
{{- define "ipfs.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ipfs.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/* Returns the service name local */}}
{{- define "ipfs-cluster.serviceNameLocal" -}}
{{ .Release.Name }}-local
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "ipfs.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ipfs.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
11 changes: 5 additions & 6 deletions packages/ops/ipfs/templates/configmap-bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "ipfs-cluster.configmapBootstrapName" . }}
name: {{ include "ipfs.configmapBootstrapName" . }}
labels:
{{- include "ipfs.labels" . | nindent 4 }}
data:
entrypoint.sh: |
#!/bin/sh
#set -e
set -x
user=ipfs

# This is a custom entrypoint for k8s designed to connect to the bootstrap
# node running in the cluster. It has been set up using a configmap to
# allow changes on the fly.


if [ ! -f /data/ipfs-cluster/service.json ]; then
ipfs-cluster-service init
fi
Expand Down Expand Up @@ -66,6 +65,6 @@ data:
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
ipfs config --json Swarm.ConnMgr.HighWater 2000
ipfs config --json Datastore.BloomFilterSize 1048576
ipfs config Datastore.StorageMax 100GB
ipfs config Datastore.StorageMax 1GB
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
4 changes: 3 additions & 1 deletion packages/ops/ipfs/templates/configmap-env.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "ipfs-cluster.configmapEnvName" . }}
name: {{ include "ipfs.configmapEnvName" . }}
labels:
{{- include "ipfs.labels" . | nindent 4 }}
data:
bootstrap-peer-id: {{ .Values.bootstrapPeerId }}
72 changes: 54 additions & 18 deletions packages/ops/ipfs/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "ipfs.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Release.Name }}
name: {{ $fullName }}
labels:
{{- include "ipfs.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
external-dns.alpha.kubernetes.io/cloudflare-proxied: "true"
kubernetes.io/ingress.class: "nginx"
cert-manager.io/cluster-issuer: letsencrypt
nginx.ingress.kubernetes.io/rewrite-target: /$1
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
- hosts:
- {{ .Values.httpDomain }}
secretName: {{ .Release.Name }}-tls
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
- host: {{ .Values.httpDomain }}
http:
paths:
- path: /(.+)
pathType: Prefix
backend:
service:
name: {{ include "ipfs-cluster.serviceNameHttp" . }}
port:
name: gateway
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion packages/ops/ipfs/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "ipfs-cluster.secretName" . }}
name: {{ include "ipfs.fullname" . }}
labels:
{{- include "ipfs.labels" . | nindent 4 }}
type: Opaque
data:
cluster-secret: {{ .Values.clusterSecret | b64enc }}
Expand Down
78 changes: 24 additions & 54 deletions packages/ops/ipfs/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,62 +1,32 @@
# Exposed
apiVersion: v1
kind: Service
metadata:
name: {{ include "ipfs-cluster.serviceName" . }}
annotations:
external-dns.alpha.kubernetes.io/hostname: {{ .Values.domain }}
name: {{ include "ipfs.fullname" . }}
labels:
node: {{ .Release.Name }}
{{- include "ipfs.labels" . | nindent 4 }}
spec:
type: LoadBalancer
ports:
- name: swarm
targetPort: swarm
port: 4001
- name: swarm-udp
targetPort: swarm-udp
port: 4002
- name: cluster-swarm
targetPort: cluster-swarm
port: 9096 #public with secret protection
- name: swarm
targetPort: swarm
port: 4001
- name: swarm-udp
targetPort: swarm-udp
port: 4002
- name: ws
targetPort: ws
port: 8081
- name: http
targetPort: http
port: 8080
- name: api-http
targetPort: api-http
port: 9094
- name: proxy-http
targetPort: proxy-http
port: 9095
- name: cluster-swarm
targetPort: cluster-swarm
port: 9096
selector:
app: {{ .Release.Name }}
---
# Exposed behind Proxy
apiVersion: v1
kind: Service
metadata:
name: {{ include "ipfs-cluster.serviceNameHttp" . }}
labels:
node: {{ .Release.Name }}
spec:
ports:
- name: gateway
targetPort: gateway
port: 8080
selector:
app: {{ .Release.Name }}
---
# Not Exposed
apiVersion: v1
kind: Service
metadata:
name: {{ include "ipfs-cluster.serviceNameLocal" . }}
labels:
node: {{ .Release.Name }}
spec:
ports:
- name: api
targetPort: api
port: 5001
- name: proxy-http
targetPort: proxy-http
port: 9095
- name: ws
targetPort: ws
port: 8081
- name: api-http
targetPort: api-http
port: 9094
selector:
app: {{ .Release.Name }}
{{- include "ipfs.selectorLabels" . | nindent 4 }}
Loading