diff --git a/contrib/helm/chihaya/.helmignore b/contrib/helm/chihaya/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/contrib/helm/chihaya/.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/contrib/helm/chihaya/Chart.yaml b/contrib/helm/chihaya/Chart.yaml new file mode 100755 index 0000000..1754677 --- /dev/null +++ b/contrib/helm/chihaya/Chart.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +name: chihaya +home: https://chihaya.io +version: 0.1.0 +description: A Helm chart for running the Chihaya BitTorrent tracker on Kubernetes. +sources: + - https://github.com/chihaya/chihaya +maintainers: + - name: Jimmy Zelinskie + email: jimmyzelinskie@gmail.com diff --git a/contrib/helm/chihaya/templates/NOTES.txt b/contrib/helm/chihaya/templates/NOTES.txt new file mode 100644 index 0000000..f894f25 --- /dev/null +++ b/contrib/helm/chihaya/templates/NOTES.txt @@ -0,0 +1,6 @@ +You can port forward a local port to Prometheus or the HTTP tracker by running: + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "fullname" . }}" -o jsonpath="{.items[0].metadata.name}") + # Prometheus port + kubectl port-forward $POD_NAME 8080:{{ $v := .Values.config.chihaya.prometheus_addr | split ":" }}{{ $v._1 }} + # HTTP tracker port + kubectl port-forward $POD_NAME 8080:{{ $v := .Values.config.chihaya.http.addr | split ":" }}{{ $v._1 }} diff --git a/contrib/helm/chihaya/templates/_helpers.tpl b/contrib/helm/chihaya/templates/_helpers.tpl new file mode 100644 index 0000000..234480d --- /dev/null +++ b/contrib/helm/chihaya/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 24 -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 24 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 24 -}} +{{- end -}} diff --git a/contrib/helm/chihaya/templates/configmap.yaml b/contrib/helm/chihaya/templates/configmap.yaml new file mode 100644 index 0000000..8b3ca87 --- /dev/null +++ b/contrib/helm/chihaya/templates/configmap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "fullname" . }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" +data: + config.yaml: | +{{ toYaml .Values.config | indent 4 }} diff --git a/contrib/helm/chihaya/templates/deployment.yaml b/contrib/helm/chihaya/templates/deployment.yaml new file mode 100644 index 0000000..b66d6d4 --- /dev/null +++ b/contrib/helm/chihaya/templates/deployment.yaml @@ -0,0 +1,41 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "fullname" . }} + spec: + volumes: + - name: config + configMap: + name: {{ template "fullname" . }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "--config=/etc/chihaya/config.yaml" + ports: + - name: bittorrent-http + containerPort: {{ $v := .Values.config.chihaya.http.addr | split ":" }}{{ $v._1 }} + protocol: TCP + - name: bittorrent-udp + containerPort: {{ $v := .Values.config.chihaya.udp.addr | split ":" }}{{ $v._1 }} + protocol: UDP + - name: metrics + containerPort: {{ $v := .Values.config.chihaya.prometheus_addr | split ":" }}{{ $v._1 }} + livenessProbe: + httpGet: + path: / + port: {{ $v := .Values.config.chihaya.prometheus_addr | split ":" }}{{ $v._1 }} + volumeMounts: + - name: config + mountPath: /etc/chihaya + resources: +{{ toYaml .Values.resources | indent 10 }} diff --git a/contrib/helm/chihaya/templates/service.yaml b/contrib/helm/chihaya/templates/service.yaml new file mode 100644 index 0000000..c798c39 --- /dev/null +++ b/contrib/helm/chihaya/templates/service.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: "/" + prometheus.io/port: {{ $v := .Values.config.chihaya.prometheus_addr | split ":" }}{{ $v._1 | quote }} +spec: + type: {{ .Values.service.type }} + ports: + - name: bittorrent-http + port: {{ $v := .Values.config.chihaya.http.addr | split ":" }}{{ $v._1 }} + targetPort: {{ $v := .Values.config.chihaya.http.addr | split ":" }}{{ $v._1 }} + protocol: TCP + - name: bittorrent-udp + port: {{ $v := .Values.config.chihaya.udp.addr | split ":" }}{{ $v._1 }} + targetPort: {{ $v := .Values.config.chihaya.udp.addr | split ":" }}{{ $v._1 }} + protocol: UDP + - name: metrics + port: {{ $v := .Values.config.chihaya.prometheus_addr | split ":" }}{{ $v._1 }} + targetPort: {{ $v := .Values.config.chihaya.prometheus_addr | split ":" }}{{ $v._1 }} + protocol: TCP + selector: + app: {{ template "fullname" . }} diff --git a/contrib/helm/chihaya/values.yaml b/contrib/helm/chihaya/values.yaml new file mode 100644 index 0000000..d82a940 --- /dev/null +++ b/contrib/helm/chihaya/values.yaml @@ -0,0 +1,33 @@ +replicaCount: 1 +image: + repository: quay.io/jzelinskie/chihaya + tag: v2.0.0-rc.1 + pullPolicy: IfNotPresent +service: + name: chihaya + type: ClusterIP +resources: + limits: + cpu: 100m + memory: 1Gi +config: + chihaya: + announce_interval: 15m + prometheus_addr: 0.0.0.0:6880 + http: + addr: 0.0.0.0:6881 + allow_ip_spoofing: true + real_ip_header: X-Forwarded-For + read_timeout: 5s + write_timeout: 5s + request_timeout: 5s + udp: + addr: 0.0.0.0:6881 + allow_ip_spoofing: true + max_clock_skew: 10s + private_key: "/K8AybyuKkob03fZJb+3Fu87eVcBNWsvVyDDxGd3wfvVGix10j6iGDEyS/ELPvQIIZvUPl2PnyfnpG6g1YJ/sw==" + storage: + gc_interval: 14m + peer_lifetime: 15m + shards: 16 + max_numwant: 50