Skip to content

Commit

Permalink
feat: standardize labelling in Helm chart to facilitate log consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
gmega committed Jan 8, 2025
1 parent a05640b commit 2c670f2
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 27 deletions.
20 changes: 14 additions & 6 deletions k8s/charts/deluge/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ Expand the name of the chart.
{{- end -}}

{{- define "deluge.pvc" }}
{{- default (printf "deluge-%s-pvc" .Release.Name) .Values.deployment.pvcName }}
{{- default (printf "deluge-%s-pvc" (include "experiment.fullId" .)) .Values.deployment.pvcName }}
{{- end -}}

{{- define "tracker.service.name" }}
{{- printf "bittorrent-tracker-%s" .Release.Name -}}
{{- end -}}
{{- define "experiment.groupId" -}}
{{- required "A valid .Values.experiment.groupId is required!" .Values.experiment.groupId }}
{{- end }}

{{- define "experiment.id" -}}
{{- default .Release.Name .Values.experiment.id }}
{{- end }}

{{- define "experiment.fullId" -}}
{{- printf "%s-%s" (include "experiment.id" .) (include "experiment.groupId" .) }}
{{- end }}

{{/*
Common and selector labels.
Expand All @@ -40,9 +48,9 @@ helm.sh/chart: {{ include "deluge-benchmarks.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "deluge-benchmarks.selectorLabels" -}}
app.kubernetes.io/name: {{ include "app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/part-of: {{ include "experiment.fullId" . }}
{{- end }}
9 changes: 5 additions & 4 deletions k8s/charts/deluge/templates/deluge-service.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: deluge-nodes-{{ .Release.Name }}-service
name: deluge-nodes-service-{{ include "experiment.fullId" . }}
namespace: {{ .Release.Namespace }}
labels:
app: deluge-nodes-{{ .Release.Name }}
{{- include "deluge-benchmarks.labels" . | nindent 4 }}
app.kubernetes.io/name: deluge-nodes-service
{{- include "deluge-benchmarks.labels" | nindent 4 -}}
spec:
clusterIP: None
selector:
app: deluge-nodes-{{ .Release.Name }}
app.kubernetes.io/name: deluge-nodes
{{- include "deluge-benchmarks.selectorLabels" | nindent 4 -}}
ports:
- port: 6890
name: rpc
Expand Down
10 changes: 5 additions & 5 deletions k8s/charts/deluge/templates/deluge-statefulset.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: deluge-nodes-{{ .Release.Name }}
name: deluge-nodes
namespace: {{ .Release.Namespace }}

spec:
replicas: {{ .Values.experiment.networkSize }}
serviceName: deluge-nodes-{{ .Release.Name }}-service
serviceName: deluge-nodes-service-{{ include "experiment.fullId" . }}
podManagementPolicy: Parallel
selector:
matchLabels:
app: deluge-nodes-{{ .Release.Name }}
app.kubernetes.io/name: deluge-node
{{- include "deluge-benchmarks.selectorLabels" . | nindent 6 }}

template:
metadata:
labels:
app: deluge-nodes-{{ .Release.Name }}
app.kubernetes.io/name: deluge-node
{{- include "deluge-benchmarks.labels" . | nindent 8 }}

spec:
containers:
- name: deluge-{{ .Release.Name }}
- name: deluge-node
image: codexstorage/deluge
imagePullPolicy: Always
ports:
Expand Down
8 changes: 4 additions & 4 deletions k8s/charts/deluge/templates/testrunner-job.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
apiVersion: batch/v1
kind: Job
metadata:
name: deluge-{{ .Release.Name }}-testrunner
name: deluge-experiment-runner-{{ include "experiment.fullId" . }}
namespace: {{ .Release.Namespace }}
labels:
app: deluge-{{ .Release.Name }}-testrunner
app.kubernetes.io/name: deluge-experiment-runner
{{- include "deluge-benchmarks.labels" . | nindent 4 }}

spec:
template:
metadata:
labels:
app: deluge-{{ .Release.Name }}-testrunner
app.kubernetes.io/name: deluge-experiment-runner
{{- include "deluge-benchmarks.labels" . | nindent 8 }}

spec:
containers:
- name: deluge-{{ .Release.Name }}-testrunner
- name: deluge-experiment-runner
image: codexstorage/bittorrent-benchmarks:latest
imagePullPolicy: Always
args: [ "run", "deluge_experiment" ]
Expand Down
10 changes: 5 additions & 5 deletions k8s/charts/deluge/templates/tracker-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: bittorrent-tracker-{{ .Release.Name }}
name: bittorrent-tracker-{{ include "experiment.fullId" . }}
namespace: {{ .Release.Namespace }}
labels:
app: bittorrent-tracker-{{ .Release.Name }}
app.kubernetes.io/name: bittorrent-tracker
{{- include "deluge-benchmarks.labels" . | nindent 4 }}

spec:
replicas: 1
selector:
matchLabels:
app: bittorrent-tracker-{{ .Release.Name }}
app.kubernetes.io/name: bittorrent-tracker
{{- include "deluge-benchmarks.selectorLabels" . | nindent 6 }}

template:
metadata:
labels:
app: bittorrent-tracker-{{ .Release.Name }}
app.kubernetes.io/name: bittorrent-tracker
{{- include "deluge-benchmarks.labels" . | nindent 8 }}

spec:
containers:
- name: bittorrent-tracker-{{ .Release.Name }}
- name: bittorrent-tracker
image: codexstorage/bittorrent-tracker
ports:
- containerPort: 8000
6 changes: 3 additions & 3 deletions k8s/charts/deluge/templates/tracker-service.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "tracker.service.name" . }}
name: bittorrent-tracker-service-{{ include "experiment.fullId" . }}
namespace: {{ .Release.Namespace }}
labels:
app: tracker-{{ .Release.Name }}
app.kubernetes.io/name: bittorrent-tracker-service
{{- include "deluge-benchmarks.labels" . | nindent 4 }}

spec:
Expand All @@ -14,5 +14,5 @@ spec:
targetPort: 8000
protocol: TCP
selector:
app: bittorrent-tracker-{{ .Release.Name }}
app.kubernetes.io/name: bittorrent-tracker
{{- include "deluge-benchmarks.selectorLabels" . | nindent 4 }}
8 changes: 8 additions & 0 deletions k8s/charts/deluge/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ experiment:
seederSets: 4
repetitions: 10

# Experiments are ran as part of groups which may entail several invocations for this Helm chart.
# We therefore identify both the experiment within a group, and the group itself.

# Identifies the experiment within the group. If left empty, defaults to the release name.
id: ""
# Identifies the experiment group. Needs to be defined by the user..
groupId: ""

deployment:
pvcName: ""
appName: ""

0 comments on commit 2c670f2

Please sign in to comment.