mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-23 17:47:29 +00:00
commit
9cc31763d0
10 changed files with 179 additions and 1 deletions
21
contrib/helm/chihaya/.helmignore
Normal file
21
contrib/helm/chihaya/.helmignore
Normal file
|
@ -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
|
10
contrib/helm/chihaya/Chart.yaml
Executable file
10
contrib/helm/chihaya/Chart.yaml
Executable file
|
@ -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
|
6
contrib/helm/chihaya/templates/NOTES.txt
Normal file
6
contrib/helm/chihaya/templates/NOTES.txt
Normal file
|
@ -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 }}
|
16
contrib/helm/chihaya/templates/_helpers.tpl
Normal file
16
contrib/helm/chihaya/templates/_helpers.tpl
Normal file
|
@ -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 -}}
|
9
contrib/helm/chihaya/templates/configmap.yaml
Normal file
9
contrib/helm/chihaya/templates/configmap.yaml
Normal file
|
@ -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 }}
|
41
contrib/helm/chihaya/templates/deployment.yaml
Normal file
41
contrib/helm/chihaya/templates/deployment.yaml
Normal file
|
@ -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 }}
|
27
contrib/helm/chihaya/templates/service.yaml
Normal file
27
contrib/helm/chihaya/templates/service.yaml
Normal file
|
@ -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" . }}
|
33
contrib/helm/chihaya/values.yaml
Normal file
33
contrib/helm/chihaya/values.yaml
Normal file
|
@ -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
|
||||||
|
max_numwant: 50
|
||||||
|
default_numwant: 25
|
||||||
|
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
|
||||||
|
storage:
|
||||||
|
gc_interval: 14m
|
||||||
|
peer_lifetime: 16m
|
||||||
|
shards: 1024
|
|
@ -62,7 +62,7 @@ chihaya:
|
||||||
|
|
||||||
# The number of partitions data will be divided into in order to provide a
|
# The number of partitions data will be divided into in order to provide a
|
||||||
# higher degree of parallelism.
|
# higher degree of parallelism.
|
||||||
shards: 1
|
shards: 1024
|
||||||
|
|
||||||
# This block defines configuration used for middleware executed before a
|
# This block defines configuration used for middleware executed before a
|
||||||
# response has been returned to a BitTorrent client.
|
# response has been returned to a BitTorrent client.
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -18,6 +19,8 @@ import (
|
||||||
"github.com/chihaya/chihaya/frontend/udp/bytepool"
|
"github.com/chihaya/chihaya/frontend/udp/bytepool"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var allowedGeneratedPrivateKeyRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
prometheus.MustRegister(promResponseDurationMilliseconds)
|
prometheus.MustRegister(promResponseDurationMilliseconds)
|
||||||
}
|
}
|
||||||
|
@ -68,6 +71,18 @@ type Frontend struct {
|
||||||
|
|
||||||
// NewFrontend allocates a new instance of a Frontend.
|
// NewFrontend allocates a new instance of a Frontend.
|
||||||
func NewFrontend(logic frontend.TrackerLogic, cfg Config) *Frontend {
|
func NewFrontend(logic frontend.TrackerLogic, cfg Config) *Frontend {
|
||||||
|
// Generate a private key if one isn't provided by the user.
|
||||||
|
if cfg.PrivateKey == "" {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
pkeyRunes := make([]rune, 64)
|
||||||
|
for i := range pkeyRunes {
|
||||||
|
pkeyRunes[i] = allowedGeneratedPrivateKeyRunes[rand.Intn(len(allowedGeneratedPrivateKeyRunes))]
|
||||||
|
}
|
||||||
|
cfg.PrivateKey = string(pkeyRunes)
|
||||||
|
|
||||||
|
log.Warn("UDP private key was not provided, using generated key: ", cfg.PrivateKey)
|
||||||
|
}
|
||||||
|
|
||||||
return &Frontend{
|
return &Frontend{
|
||||||
closing: make(chan struct{}),
|
closing: make(chan struct{}),
|
||||||
logic: logic,
|
logic: logic,
|
||||||
|
|
Loading…
Add table
Reference in a new issue