Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Kubernetes recommanded labels and custom labels #1256

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion thanos/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords:
sources:
- https://github.com/thanos-io/thanos
- https://github.com/banzaicloud/banzai-charts/tree/master/thanos
version: 0.4.3
version: 0.4.4
icon: https://raw.githubusercontent.com/thanos-io/thanos/master/docs/img/Thanos-logo_fullmedium.png
maintainers:
- name: Banzai Cloud
Expand Down
15 changes: 14 additions & 1 deletion thanos/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,17 @@ Create a default name for service account if not provided.
{{- else -}}
{{- printf "%s" .Values.queryFrontend.serviceAccount -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/* Generate basic labels */}}
{{- define "thanos.labels" }}
app.kubernetes.io/name: {{ template "thanos.name" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
app.kubernetes.io/version: "{{ .Chart.AppVersion | replace "+" "_" }}"
app.kubernetes.io/part-of: {{ template "thanos.name" . }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels }}
{{- end }}
{{- end }}
9 changes: 2 additions & 7 deletions thanos/templates/bucket-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ kind: Deployment
metadata:
name: {{ include "thanos.componentname" (list $ "bucket") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: bucket
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.bucket.deploymentLabels }}{{ toYaml . | indent 4 }}{{ end -}}
{{- with .Values.bucket.deploymentAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
Expand All @@ -28,9 +24,8 @@ spec:
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: bucket
{{- include "thanos.labels" . | indent 8 }}
{{ with .Values.bucket.labels }}{{ toYaml . | indent 8 }}{{ end }}
{{- with .Values.bucket.annotations }}
annotations: {{ toYaml . | nindent 8 }}
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/bucket-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ metadata:
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: bucket
{{- include "thanos.labels" . | indent 4 }}
{{- if .Values.bucket.http.ingress.labels }}
{{ toYaml .Values.bucket.http.ingress.labels | indent 4 }}
{{- end }}
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/bucket-poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ kind: PodDisruptionBudget
metadata:
name: {{ include "thanos.componentname" (list $ "bucket") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: bucket
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.bucket.deploymentLabels }}{{ toYaml . | indent 4 }}{{ end }}
spec:
{{- if .Values.bucket.podDisruptionBudget.minAvailable }}
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/bucket-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ metadata:
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: bucket
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.bucket.http.service.labels }}{{ toYaml . | indent 4 }}{{ end }}
spec:
ports:
Expand Down
9 changes: 2 additions & 7 deletions thanos/templates/compact-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ kind: Deployment
metadata:
name: {{ include "thanos.componentname" (list $ "compact") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: compact
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.compact.deploymentLabels }}{{ toYaml . | indent 4 }}{{ end -}}
{{- with .Values.compact.deploymentAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
Expand All @@ -28,9 +24,8 @@ spec:
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: compact
{{- include "thanos.labels" . | indent 8 }}
{{ with .Values.compact.labels }}{{ toYaml . | indent 8 }}{{ end }}
{{- if or .Values.compact.annotations .Values.compact.metrics.annotations.enabled }}
annotations:
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/compact-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ kind: PersistentVolumeClaim
metadata:
name: {{ $pvc.name }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: compact
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.compact.deploymentLabels }}{{ toYaml . | indent 4 }}{{ end -}}
{{- with .Values.compact.deploymentAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/compact-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ metadata:
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: compact
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.compact.http.service.labels }}{{ toYaml . | indent 4 }}{{ end }}
spec:
ports:
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/compact-servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ kind: ServiceMonitor
metadata:
name: {{ include "thanos.componentname" (list $ "compact") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: compact
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.compact.metrics.serviceMonitor.labels }}{{ toYaml . | indent 4 }}{{ end }}
spec:
jobLabel: thanos-compact
Expand Down
9 changes: 2 additions & 7 deletions thanos/templates/query-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ kind: Deployment
metadata:
name: {{ include "thanos.componentname" (list $ "query") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.query.deploymentLabels }}{{ toYaml . | indent 4 }}{{ end }}
{{- with .Values.query.deploymentAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
Expand All @@ -30,9 +26,8 @@ spec:
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: query
{{- include "thanos.labels" . | indent 8 }}
{{ with .Values.query.labels }}{{ toYaml . | indent 8 }}{{ end }}
{{- if or .Values.query.annotations .Values.query.metrics.annotations.enabled }}
annotations:
Expand Down
9 changes: 2 additions & 7 deletions thanos/templates/query-frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ kind: Deployment
metadata:
name: {{ include "thanos.componentname" (list $ "query-frontend") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.queryFrontend.deploymentLabels }}{{ toYaml . | indent 4 }}{{ end }}
{{- with .Values.queryFrontend.deploymentAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
Expand All @@ -30,9 +26,8 @@ spec:
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.queryFrontend.labels }}{{ toYaml . | indent 8 }}{{ end }}
{{- if or .Values.queryFrontend.annotations .Values.queryFrontend.metrics.annotations.enabled }}
annotations:
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/query-frontend-horizontalpodautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ kind: HorizontalPodAutoscaler
metadata:
name: {{ include "thanos.componentname" (list $ "query-frontend") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
Expand Down
12 changes: 2 additions & 10 deletions thanos/templates/query-frontend-ingress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ kind: Ingress
metadata:
name: {{ include "thanos.componentname" (list $ "query-frontend") }}-http
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
{{- if .Values.queryFrontend.http.ingress.labels }}
{{ toYaml .Values.queryFrontend.http.ingress.labels | indent 4 }}
{{- end }}
Expand Down Expand Up @@ -54,12 +50,8 @@ kind: Ingress
metadata:
name: {{ include "thanos.componentname" (list $ "query-frontend") }}-grpc
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
{{- if .Values.queryFrontend.grpc.ingress.labels }}
{{ toYaml .Values.queryFrontend.grpc.ingress.labels | indent 4 }}
{{- end }}
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/query-frontend-poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ kind: PodDisruptionBudget
metadata:
name: {{ include "thanos.componentname" (list $ "query-frontend") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.queryFrontend.deploymentLabels }}{{ toYaml . | indent 4 }}{{ end }}
spec:
{{- if .Values.queryFrontend.podDisruptionBudget.minAvailable }}
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/query-frontend-psp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ kind: PodSecurityPolicy
metadata:
name: {{ include "thanos.componentname" (list $ "query-frontend") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
spec:
privileged: false
allowPrivilegeEscalation: false
Expand Down
18 changes: 3 additions & 15 deletions thanos/templates/query-frontend-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,16 @@ metadata:
{{- end }}
name: {{ include "thanos.componentname" (list $ "query-frontend") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "thanos.componentname" (list $ "query-frontend") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
rules:
- apiGroups: ['policy']
resources: ['podsecuritypolicies']
Expand All @@ -38,12 +30,8 @@ kind: RoleBinding
metadata:
name: {{ include "thanos.componentname" (list $ "query-frontend") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
roleRef:
kind: ClusterRole
name: {{ include "thanos.componentname" (list $ "query-frontend") }}
Expand Down
12 changes: 2 additions & 10 deletions thanos/templates/query-frontend-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ metadata:
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.queryFrontend.grpc.service.labels }}{{ toYaml . | indent 4 }}{{ end }}
spec:
type: ClusterIP
Expand All @@ -38,12 +34,8 @@ metadata:
annotations: {{ toYaml .| nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.queryFrontend.http.service.labels }}{{ toYaml . | indent 4 }}{{ end }}
spec:
type: {{ .Values.queryFrontend.http.service.type }}
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/query-frontend-servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ kind: ServiceMonitor
metadata:
name: {{ include "thanos.componentname" (list $ "query-frontend") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query-frontend
{{- include "thanos.labels" . | indent 4 }}
{{ with .Values.queryFrontend.metrics.serviceMonitor.labels }}{{ toYaml . | indent 4 }}{{ end }}
spec:
jobLabel: thanos-query-frontend
Expand Down
6 changes: 1 addition & 5 deletions thanos/templates/query-horizontalpodautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ kind: HorizontalPodAutoscaler
metadata:
name: {{ include "thanos.componentname" (list $ "query") }}
labels:
app.kubernetes.io/name: {{ include "thanos.name" . }}
helm.sh/chart: {{ include "thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: query
{{- include "thanos.labels" . | indent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
Expand Down
Loading