Skip to content
This repository has been archived by the owner. It is now read-only.

[stable] Add IPFS Chart #1192

Merged
merged 20 commits into from Jul 11, 2017
Merged

[stable] Add IPFS Chart #1192

merged 20 commits into from Jul 11, 2017

Conversation

yuvipanda
Copy link
Contributor

@yuvipanda yuvipanda commented May 29, 2017

Adds a chart that lets you install IPFS with a StatefulSet.

yuvipanda added 5 commits May 29, 2017
- Uses persistent volumes for the IPFS Path, so we retain objects
  across restarts.
- Uses a StatefulSet rather than Deployment, since we want a PVC
  for each pod running. Using a StatefulSet lets us scale up and down
  without sacrificing a persistent cache.
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented May 29, 2017

Hi @yuvipanda. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 29, 2017
runAsUser: 1000
containers:
- name: {{ .Chart.Name }}
image: jbenet/go-ipfs:release
Copy link

@victorb victorb May 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to use ipfs/go-ipfs instead of from Juan's account, and also lock it to a version, v0.4.9 is latest available in Docker Hub.

Copy link
Contributor Author

@yuvipanda yuvipanda May 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Fixed it :)

apiVersion: v1
kind: Service
metadata:
name: {{ if .Values.service.nameOverride }} {{ .Values.service.nameOverride }} {{ else }} {{ template "fullname" . }} {{ end }}
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you want to do that? This should just be {{ template "fullname" . }}.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I want to be allow users to override service names. In this case, end users will be asked to hit the DNS entry for the service name, and that should be overrideable so it can be something like 'ipfs' so other users in the same namespace can just specify 'ipfs'. The default is still the behavior seen in the current charts in the repo.

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: {{ template "name" . }}
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name should be {{ template "fullname" . }}.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

template:
metadata:
labels:
app: {{ template "fullname" . }}
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this {{ template "name" . }} for the app label.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

labels:
app: {{ template "fullname" . }}
spec:
securityContext:
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the reason behind this?

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - the image needs to write to the PVC to function, and it runs as UID 1000 (rather than root).

runAsUser: 1000
containers:
- name: {{ .Chart.Name }}
image: ipfs/go-ipfs:v0.4.9
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make image configurable.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

nameOverride: null

resources:
requests:
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't specify defaults for resources.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

metadata:
name: {{ if .Values.service.nameOverride }} {{ .Values.service.nameOverride }} {{ else }} {{ template "fullname" . }} {{ end }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just got this from helm create, will read and update!

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@unguiculus unguiculus self-assigned this May 30, 2017
spec:
replicas: {{ .Values.replicaCount }}
serviceName: {{ template "name" . }}
volumeClaimTemplates:
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could if it is a requirement for merging :) but it's not particularly useful without persistent volumes however - but I guess so is the case for MongoDB!

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Optional but enabled by default!

@@ -1,14 +1,14 @@
replicaCount: 1

image: ipfs/go-ipfs:v0.4.9

service:
type: ClusterIP
nameOverride: null
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove nameOverride: null

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

targetPort: 8080
name: gateway
selector:
app: {{ template "name" . }}
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires an additional selector: release: {{ .Release.Name }}

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

template:
metadata:
labels:
app: {{ template "name" . }}
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least the release label should be added here as well.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

volumeMounts:
- name: ipfs-storage
mountPath: /data/ipfs
{{- if .Values.resources }}
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not necessary. Add default to values.yaml:

resources: {}

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


service:
type: ClusterIP
nameOverride: null
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove nameOverride.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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.
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary. Will test this. Otherwise we'd have this problem with lots of charts. I think this is only a problem if you mount a volume from the host, which is not the case.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into permissionDenied errors when I tried (on GKE). Perhaps the runAsUser isn't necessary but fs is?

could just connect to it by specifying 'ipfs'.
*/}}
{{- define "servicename" -}}
{{- if .Values.service.nameOverride -}}
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add truncation.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, am not sure this needs truncation. The user is responsible for setting it, and the default fullname handles truncation already.

| `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 |
| `storage.size` | Size of the PVC for each IPFS pod, used as persistent cache | `10Gi` |
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add missing config entries.

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
spec:
type: {{ .Values.service.type }}
Copy link
Member

@unguiculus unguiculus May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Statefulsets require a headless service. This means you should always have this:

type: ClusterIP
clusterIP: None

Copy link
Contributor Author

@yuvipanda yuvipanda May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the service need to be headless? We also need a service anyway, and this paradigm works well - ipfs.namespace round robins to one of them, and you can do ipfs-0.ipfs or ipfs-1.ipfs for each one if you need.

@unguiculus
Copy link
Member

unguiculus commented May 30, 2017

@k8s-bot ok to test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 30, 2017
@yuvipanda
Copy link
Contributor Author

yuvipanda commented Jun 4, 2017

Anything else I need to do before I can get it merged? :)

Copy link
Member

@unguiculus unguiculus left a comment

I deployed it on GKE. Everything seems to come up successfully. The log looks ok. When I access it on port 8080 with port-forwarding, I get a 404.

{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }}
Copy link
Member

@unguiculus unguiculus Jun 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

service.externalPort is not used anywhere. Thus, a default installation prints this:

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):
  export POD_NAME=$(kubectl get pods --namespace default -l "app=wiggly-alpaca-ipfs" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl port-forward $POD_NAME 8080:

Also note that the label selector is wrong. Use this: -l "app={{ template "name" . }},release={{ .Release.Name }}"

Copy link
Contributor Author

@yuvipanda yuvipanda Jul 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

@unguiculus
Copy link
Member

unguiculus commented Jul 2, 2017

Marking as stale. Please update within one week.

@yuvipanda
Copy link
Contributor Author

yuvipanda commented Jul 2, 2017

@yuvipanda
Copy link
Contributor Author

yuvipanda commented Jul 10, 2017

The 404 is expected, since it's only an API Gateway service. If you access, for example, /ipfs/Qmb8wsGZNXt5VXZh1pEmYynjB6Euqpq3HYyeAdw2vScTkQ, it'll lead you to the same page as https://ipfs.io/ipfs/Qmb8wsGZNXt5VXZh1pEmYynjB6Euqpq3HYyeAdw2vScTkQ. It can also serve a particular hash based on a Host Header. For example, if you do a curl -H 'Host: ipfs.io' <ip> you'll actually get back the contents of ipfs.io landing page.

@unguiculus unguiculus merged commit a78cbd1 into helm:master Jul 11, 2017
2 checks passed
@unguiculus
Copy link
Member

unguiculus commented Jul 11, 2017

@yuvipanda

Two things about the Chart.yaml I noticed after merging:

  • The maintainer name should be a Github user
  • The appVersion field should be added

Would you mind creating another PR for this?

lachie83 added a commit to lachie83/charts that referenced this issue Jul 11, 2017
* upstream/master:
  Add IPFS Chart (helm#1192)
  [stable/ghost] Release 0.4.12 (helm#1429)
  [stable/opencart] Release 0.4.10 (helm#1425)
  [stable/redmine] Release 1.2.0 (helm#1414)
  [stable/wordpress] Release 0.6.8 (helm#1403)
  [stable/rabbitmq] Release 0.5.4 (helm#1395)
  [stable/mongodb] Release 0.4.12 (helm#1392)
  [stable/phabricator] Release 0.4.11 (helm#1384)
  [stable/drupal] Release 0.8.1 (helm#1340)
  [stable/odoo] Release 0.5.3 (helm#1323)
  update pilot svc name to default for nicer UX (helm#1464)
  [stable/grafana] Improve curl invocation (helm#1463)
@yuvipanda
Copy link
Contributor Author

yuvipanda commented Jul 12, 2017

@unguiculus I sent #1469. Thanks!

@yuvipanda yuvipanda deleted the ipfs branch Jul 12, 2017
yanns pushed a commit to yanns/charts that referenced this issue Jul 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. code reviewed UX reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants