diff --git a/stable/ipfs/.helmignore b/stable/ipfs/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/ipfs/.helmignore @@ -0,0 +1,21 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/stable/ipfs/Chart.yaml b/stable/ipfs/Chart.yaml new file mode 100644 index 0000000000..3482bbfea7 --- /dev/null +++ b/stable/ipfs/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +description: A Helm chart for the Interplanetary File System +name: ipfs +version: 0.1.0 +icon: https://raw.githubusercontent.com/ipfs/logo/master/raster-generated/ipfs-logo-128-ice-text.png +home: https://ipfs.io/ +keywords: + - ipfs + - distributed-web +sources: + - https://github.com/ipfs/go-ipfs +maintainers: + - name: Yuvi Panda + email: yuvipanda@gmail.com diff --git a/stable/ipfs/README.md b/stable/ipfs/README.md new file mode 100644 index 0000000000..1ffb542ba2 --- /dev/null +++ b/stable/ipfs/README.md @@ -0,0 +1,68 @@ +# IPFS + +> [IPFS](https://ipfs.io/) is a part of the distributed web - a peer-to-peer hypermedia protocol to make the web faster, safer, and more open. + +## TL;DR; + +```bash +$ helm install stable/ipfs +``` + +## Introduction + +This chart bootstraps a [IPFS](https://ipfs.io) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install --name my-release stable/ipfs +``` + +The command deploys IPFS on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```bash +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the Memcached chart and their default values. + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `replicaCount` | The number of replicas of go-ipfs to run | 1 | +| `service.type` | Type of the service: `ClusterIP`, `LoadBalancer` or `NodePort` | `ClusterIP` | +| `service.nameOverride` | The name to use for the service | The full name of the release | +| `persistence.enabled` | Turn on persistent storage for the IPFS data directory | `true` | +| `persistence.storageClass` | StorageClass to set for the persistent volume claim. | The default storageclass in the cluster| +| `persistence.annotations` | Extra annotations for the persistent volume claim. | `{}` | +| `persistence.accessModes` | List of access modes for use with the persistent volume claim | `["ReadWriteOnce"]` | +| `persistence.size` | Size of the PVC for each IPFS pod, used as persistent cache | `8Gi` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```bash +$ helm install --name my-release \ + --set storage.size="20Gi" \ + stable/ipfs +``` + +The above command sets the disk size to 20Gi. + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install --name my-release -f values.yaml stable/ipfs +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) as a base for customization. diff --git a/stable/ipfs/templates/NOTES.txt b/stable/ipfs/templates/NOTES.txt new file mode 100644 index 0000000000..a85d39b42c --- /dev/null +++ b/stable/ipfs/templates/NOTES.txt @@ -0,0 +1,26 @@ +You have successfully installed IPFS in your kubernetes cluster! + +You can access the IPFS API from inside your cluster by connecting to port 5001 on + {{ template "servicename" . }}.{{ .Release.Namespace }} + +You can also connect to port 8080 on the same hostname for talking to the IPFS Gateway. + + +If you want to connect to it from your local computer, you can find a URL to connect with the +following (for the gateway service): + +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "servicename" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "servicename" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo "Use the API Gateway by accessing http://$SERVICE_IP:8080/ipfs/" +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Use the API Gateway by accessing http://localhost:8080/ipfs/" + kubectl --namespace {{ .Release.Namespace}} port-forward $POD_NAME 8080:8080 + +{{- end }} diff --git a/stable/ipfs/templates/_helpers.tpl b/stable/ipfs/templates/_helpers.tpl new file mode 100644 index 0000000000..454532f440 --- /dev/null +++ b/stable/ipfs/templates/_helpers.tpl @@ -0,0 +1,31 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "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). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a name for the service to use. + +We allow overrides for name of service, since this service provides an API that could be directly +called by end-users. For example, you could call it 'ipfs' and then all users running in a namespace +could just connect to it by specifying 'ipfs'. +*/}} +{{- define "servicename" -}} +{{- if .Values.service.nameOverride -}} +{{- .Values.service.nameOverride -}} +{{- else -}} +{{- template "fullname" . }} +{{- end -}} +{{- end -}} diff --git a/stable/ipfs/templates/service.yaml b/stable/ipfs/templates/service.yaml new file mode 100644 index 0000000000..75db3ceb24 --- /dev/null +++ b/stable/ipfs/templates/service.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "servicename" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +spec: + type: {{ .Values.service.type }} + ports: + - port: 5001 + targetPort: 5001 + protocol: TCP + name: api + - port: 8080 + targetPort: 8080 + name: gateway + selector: + app: {{ template "name" . }} + release: {{ .Release.Name }} diff --git a/stable/ipfs/templates/statefulset.yaml b/stable/ipfs/templates/statefulset.yaml new file mode 100644 index 0000000000..12d6a91ab2 --- /dev/null +++ b/stable/ipfs/templates/statefulset.yaml @@ -0,0 +1,65 @@ +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +spec: + replicas: {{ .Values.replicaCount }} + serviceName: {{ template "servicename" . }} + template: + metadata: + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} + spec: + securityContext: + # The image runs as uid 1000 by default, and needs to be able to write to + # the persistent volume to be able to start. + fsGroup: 1000 + runAsUser: 1000 + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} + ports: + - containerPort: 5001 + name: api + - containerPort: 8080 + name: gateway + volumeMounts: + - name: ipfs-storage + mountPath: /data/ipfs + resources: +{{ toYaml .Values.resources | indent 10 }} + + {{- if .Values.persistence.enabled }} + volumeClaimTemplates: + - metadata: + name: ipfs-storage + annotations: + {{- if .Values.persistence.storageClass | quote }} + volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass | quote }} + {{- else }} + volume.alpha.kubernetes.io/storage-class: default + {{- end }} + {{- range $key, $value := .Values.persistence.annotations }} + {{ $key }}: {{ $value }} + {{- end }} + spec: + accessModes: + {{- range .Values.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} + {{- else }} + volumes: + - name: ipfs-storage + emptyDir: {} + {{- end }} diff --git a/stable/ipfs/values.yaml b/stable/ipfs/values.yaml new file mode 100644 index 0000000000..e308422ce6 --- /dev/null +++ b/stable/ipfs/values.yaml @@ -0,0 +1,14 @@ +replicaCount: 1 + +image: ipfs/go-ipfs:v0.4.9 + +service: + type: ClusterIP + +resources: {} + +persistence: + enabled: true + size: "8Gi" + accessModes: + - ReadWriteOnce