Skip to content

Commit

Permalink
Better labels
Browse files Browse the repository at this point in the history
  • Loading branch information
jastBytes committed Dec 10, 2020
1 parent d791155 commit 48b6dee
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 31 deletions.
2 changes: 1 addition & 1 deletion charts/dex/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: dex
version: 1.0.10
version: 1.0.11
appVersion: 2.25.0
description: A federated OpenID Connect provider
keywords:
Expand Down
45 changes: 26 additions & 19 deletions charts/dex/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "dex.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "dex.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "dex.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "dex.labels" -}}
app.kubernetes.io/name: {{ include "dex.name" . }}
helm.sh/chart: {{ include "dex.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{ include "dex.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
app.kubernetes.io/component: dex
{{- end }}

{{/*
Selector labels
*/}}
{{- define "dex.selectorLabels" -}}
app.kubernetes.io/name: {{ (include "dex.name" .) }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
Expand Down
17 changes: 9 additions & 8 deletions charts/dex/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ kind: Deployment
metadata:
name: {{ template "dex.fullname" . }}
labels:
{{ include "dex.labels" . | indent 4 }}
app.kubernetes.io/component: dex
{{- include "dex.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicas }}
strategy:
Expand All @@ -22,15 +24,14 @@ spec:
type: RollingUpdate
selector:
matchLabels:
app.kubernetes.io/name: {{ include "dex.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: dex
{{- include "dex.selectorLabels" . | nindent 8 }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "dex.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: dex
{{- include "dex.labels" . | nindent 8 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- if .Values.podAnnotations }}
Expand Down
8 changes: 5 additions & 3 deletions charts/dex/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ kind: Service
metadata:
name: {{ template "dex.fullname" . }}
labels:
{{ include "dex.labels" . | indent 4 }}
{{- include "dex.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
Expand Down Expand Up @@ -34,5 +37,4 @@ spec:
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "dex.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "dex.selectorLabels" . | nindent 6 }}
3 changes: 3 additions & 0 deletions charts/dex/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,6 @@ config:
# hash: "$2a$10$2b2cU8CPhOTaGrs1HRQuAueS7JTT5ZHsHSzYiFPm1leZck7Mc8T4W"
# username: "admin"
# userID: "08a8684b-db88-4b73-90a9-3cd1661f5466"

labels: {}
# app.kubernetes.io/part-of: my-app

0 comments on commit 48b6dee

Please sign in to comment.