diff options
author | Patrick Spek <p.spek@tyil.nl> | 2022-09-23 11:45:27 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2022-09-23 11:45:27 +0200 |
commit | dbc36835a16f3c4f7e813a8a536c0922ef1f6bbd (patch) | |
tree | abc402875944ec48a76bd62e1c35eddc9a469407 | |
parent | 258ae0c022e0c57e9e87c61e9ca5890ef0480da1 (diff) | |
download | invidious-dbc36835a16f3c4f7e813a8a536c0922ef1f6bbd.tar.gz invidious-dbc36835a16f3c4f7e813a8a536c0922ef1f6bbd.tar.bz2 |
Add labels template
-rw-r--r-- | Chart.yaml | 2 | ||||
-rw-r--r-- | templates/_helpers.tpl | 27 | ||||
-rw-r--r-- | templates/configmap.yaml | 6 | ||||
-rw-r--r-- | templates/deployment.yaml | 11 | ||||
-rw-r--r-- | templates/hpa.yaml | 6 | ||||
-rw-r--r-- | templates/service.yaml | 7 |
6 files changed, 39 insertions, 20 deletions
@@ -1,7 +1,7 @@ apiVersion: v2 name: invidious description: Invidious is an alternative front-end to YouTube -version: 2.0.0 +version: 2.0.1 appVersion: 0.20.1 keywords: - youtube diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 52158b7..638fade 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -14,3 +14,30 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "invidious.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "invidious.labels" -}} +helm.sh/chart: {{ include "invidious.chart" . }} +{{ include "invidious.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "invidious.selectorLabels" -}} +app.kubernetes.io/name: {{ include "invidious.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/templates/configmap.yaml b/templates/configmap.yaml index 58542a3..74d6603 100644 --- a/templates/configmap.yaml +++ b/templates/configmap.yaml @@ -1,11 +1,11 @@ +--- apiVersion: v1 kind: ConfigMap metadata: name: {{ template "invidious.fullname" . }} labels: - app: {{ template "invidious.name" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: {{ .Release.Name }} + {{- include "invidious.labels" . | nindent 4 }} data: INVIDIOUS_CONFIG: | {{ toYaml .Values.config | indent 4 }} +... diff --git a/templates/deployment.yaml b/templates/deployment.yaml index ea1bab5..f0ac30f 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -4,21 +4,16 @@ kind: Deployment metadata: name: {{ template "invidious.fullname" . }} labels: - app: {{ template "invidious.name" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: {{ .Release.Name }} + {{- include "invidious.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - app: {{ template "invidious.name" . }} - release: {{ .Release.Name }} + {{- include "invidious.selectorLabels" . | nindent 6 }} template: metadata: labels: - app: {{ template "invidious.name" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: {{ .Release.Name }} + {{- include "invidious.selectorLabels" . | nindent 8 }} spec: securityContext: runAsUser: {{ .Values.securityContext.runAsUser }} diff --git a/templates/hpa.yaml b/templates/hpa.yaml index c6fbefe..fe1f4e4 100644 --- a/templates/hpa.yaml +++ b/templates/hpa.yaml @@ -1,12 +1,11 @@ +--- {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: name: {{ template "invidious.fullname" . }} labels: - app: {{ template "invidious.name" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: {{ .Release.Name }} + {{- include "invidious.labels" . | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 @@ -16,3 +15,4 @@ spec: maxReplicas: {{ .Values.autoscaling.maxReplicas }} targetCPUUtilizationPercentage: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} {{- end }} +... diff --git a/templates/service.yaml b/templates/service.yaml index f1dc7ea..0513f51 100644 --- a/templates/service.yaml +++ b/templates/service.yaml @@ -4,9 +4,7 @@ kind: Service metadata: name: {{ template "invidious.fullname" . }} labels: - app: {{ template "invidious.name" . }} - chart: {{ .Chart.Name }} - release: {{ .Release.Name }} + {{- include "invidious.labels" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: @@ -14,8 +12,7 @@ spec: port: {{ .Values.service.port }} targetPort: 3000 selector: - app: {{ template "invidious.name" . }} - release: {{ .Release.Name }} + {{- include "invidious.selectorLabels" . | nindent 4 }} {{- if .Values.service.loadBalancerIP }} loadBalancerIP: {{ .Values.service.loadBalancerIP }} {{- end }} |