|
| 1 | +{{/* |
| 2 | +Standard Helm helpers — name + fullname trimmed to k8s's 63-char |
| 3 | +limit, common labels block, headless-service name + per-pod DNS |
| 4 | +helper used by the seed-list template in the StatefulSet. |
| 5 | +*/}} |
| 6 | + |
| 7 | +{{- define "hypercache.name" -}} |
| 8 | +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} |
| 9 | +{{- end -}} |
| 10 | + |
| 11 | +{{- define "hypercache.fullname" -}} |
| 12 | +{{- if .Values.fullnameOverride -}} |
| 13 | +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} |
| 14 | +{{- else -}} |
| 15 | +{{- $name := default .Chart.Name .Values.nameOverride -}} |
| 16 | +{{- if contains $name .Release.Name -}} |
| 17 | +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} |
| 18 | +{{- else -}} |
| 19 | +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} |
| 20 | +{{- end -}} |
| 21 | +{{- end -}} |
| 22 | +{{- end -}} |
| 23 | + |
| 24 | +{{- define "hypercache.headlessServiceName" -}} |
| 25 | +{{- printf "%s-headless" (include "hypercache.fullname" .) | trunc 63 | trimSuffix "-" -}} |
| 26 | +{{- end -}} |
| 27 | + |
| 28 | +{{- define "hypercache.serviceAccountName" -}} |
| 29 | +{{- if .Values.serviceAccount.create -}} |
| 30 | +{{- default (include "hypercache.fullname" .) .Values.serviceAccount.name -}} |
| 31 | +{{- else -}} |
| 32 | +{{- default "default" .Values.serviceAccount.name -}} |
| 33 | +{{- end -}} |
| 34 | +{{- end -}} |
| 35 | + |
| 36 | +{{- define "hypercache.labels" -}} |
| 37 | +helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} |
| 38 | +app.kubernetes.io/name: {{ include "hypercache.name" . }} |
| 39 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 40 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 41 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 42 | +app.kubernetes.io/component: cache |
| 43 | +{{- end -}} |
| 44 | + |
| 45 | +{{- define "hypercache.selectorLabels" -}} |
| 46 | +app.kubernetes.io/name: {{ include "hypercache.name" . }} |
| 47 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 48 | +{{- end -}} |
| 49 | + |
| 50 | +{{/* |
| 51 | +hypercache.seedList builds the comma-separated `id@addr` value |
| 52 | +the dist backend needs to bootstrap a multi-process ring. Every |
| 53 | +pod gets the FULL list (including itself); the dist code's |
| 54 | +parseSeedSpec drops the self-entry by ID match. This means the |
| 55 | +SAME env value applies to every replica, so a StatefulSet (which |
| 56 | +only supports a single pod template) can express it. |
| 57 | +
|
| 58 | +Format: `<podname>@<podname>.<headless>.<ns>.svc.cluster.local:<port>` |
| 59 | +*/}} |
| 60 | +{{- define "hypercache.seedList" -}} |
| 61 | +{{- $fullname := include "hypercache.fullname" . -}} |
| 62 | +{{- $svc := include "hypercache.headlessServiceName" . -}} |
| 63 | +{{- $ns := .Release.Namespace -}} |
| 64 | +{{- $port := .Values.ports.dist | int -}} |
| 65 | +{{- $count := .Values.replicaCount | int -}} |
| 66 | +{{- $entries := list -}} |
| 67 | +{{- range $i, $_ := until $count -}} |
| 68 | +{{- $entry := printf "%s-%d@%s-%d.%s.%s.svc.cluster.local:%d" $fullname $i $fullname $i $svc $ns $port -}} |
| 69 | +{{- $entries = append $entries $entry -}} |
| 70 | +{{- end -}} |
| 71 | +{{- join "," $entries -}} |
| 72 | +{{- end -}} |
0 commit comments