Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/redis] Update labelling strategy #9332

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions stable/redis/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: redis
version: 4.2.10
version: 5.0.0
appVersion: 4.0.11
description: Open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
keywords:
- redis
- keyvalue
- database
home: http://redis.io/
home: https://redis.io/
icon: https://bitnami.com/assets/stacks/redis/img/redis-stack-220x234.png
sources:
- https://github.com/bitnami/bitnami-docker-redis
Expand Down
20 changes: 20 additions & 0 deletions stable/redis/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,23 @@ Create the name of the service account to use
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}


{{/*
Return instance and name labels.
*/}}
{{- define "redis.instance-name" -}}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/name: {{ include "redis.name" . | quote }}
{{- end -}}


{{/*
Return labels, including instance and name.
*/}}
{{- define "redis.labels" -}}
{{ include "redis.instance-name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
helm.sh/chart: {{ include "redis.chart" . | quote }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a neat method to avoid repeating the same things.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance this could be made the default?

{{- end -}}
5 changes: 1 addition & 4 deletions stable/redis/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "redis.labels" . | indent 4 }}
name: {{ template "redis.fullname" . }}
data:
redis.conf: |-
Expand Down
5 changes: 1 addition & 4 deletions stable/redis/templates/health-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{ include "redis.labels" . | indent 4 }}
name: {{ template "redis.fullname" . }}-health
data:
ping_local.sh: |-
Expand Down
16 changes: 5 additions & 11 deletions stable/redis/templates/metrics-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@ kind: Deployment
metadata:
name: {{ template "redis.fullname" . }}-metrics
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
spec:
selector:
matchLabels:
release: "{{ .Release.Name }}"
role: metrics
app: {{ template "redis.name" . }}
app.kubernetes.io/component: metrics
{{ include "redis.instance-name" . | indent 6 }}
template:
metadata:
labels:
release: "{{ .Release.Name }}"
chart: {{ template "redis.chart" . }}
role: metrics
app: {{ template "redis.name" . }}
app.kubernetes.io/component: metrics
{{ include "redis.labels" . | indent 8 }}
{{- if .Values.metrics.podLabels }}
{{ toYaml .Values.metrics.podLabels | indent 8 }}
{{- end }}
Expand Down
10 changes: 3 additions & 7 deletions stable/redis/templates/metrics-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: Service
metadata:
name: {{ template "redis.fullname" . }}-metrics
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
{{- if .Values.metrics.service.annotations }}
annotations:
{{ toYaml .Values.metrics.service.annotations | indent 4 }}
Expand All @@ -23,7 +20,6 @@ spec:
port: 9121
targetPort: metrics
selector:
app: {{ template "redis.name" . }}
release: {{ .Release.Name }}
role: metrics
app.kubernetes.io/component: metrics
{{ include "redis.instance-name" . | indent 4 }}
{{- end }}
8 changes: 2 additions & 6 deletions stable/redis/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ apiVersion: {{ template "networkPolicy.apiVersion" . }}
metadata:
name: "{{ template "redis.fullname" . }}"
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
spec:
podSelector:
matchLabels:
app: {{ template "redis.name" . }}
release: "{{ .Release.Name }}"
{{ include "redis.instance-name" . | indent 6 }}
ingress:
# Allow inbound connections
- ports:
Expand Down
22 changes: 7 additions & 15 deletions stable/redis/templates/redis-master-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@ kind: StatefulSet
metadata:
name: {{ template "redis.fullname" . }}-master
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
spec:
selector:
matchLabels:
release: "{{ .Release.Name }}"
role: master
app: {{ template "redis.name" . }}
redis.io/role: master
{{ include "redis.instance-name" . | indent 6 }}
serviceName: {{ template "redis.fullname" . }}-master
template:
metadata:
labels:
release: "{{ .Release.Name }}"
chart: {{ template "redis.chart" . }}
role: master
app: {{ template "redis.name" . }}
redis.io/role: master
{{ include "redis.labels" . | indent 8 }}
{{- if .Values.master.podLabels }}
{{ toYaml .Values.master.podLabels | indent 8 }}
{{- end }}
Expand Down Expand Up @@ -172,10 +166,8 @@ spec:
- metadata:
name: redis-data
labels:
app: "{{ template "redis.name" . }}"
component: "master"
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
app.kubernetes.io/component: server
{{ include "redis.instance-name" . | indent 10 }}
yurrriq marked this conversation as resolved.
Show resolved Hide resolved
spec:
accessModes:
{{- range .Values.master.persistence.accessModes }}
Expand Down
10 changes: 3 additions & 7 deletions stable/redis/templates/redis-master-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ kind: Service
metadata:
name: {{ template "redis.fullname" . }}-master
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
{{- with .Values.master.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
Expand All @@ -25,6 +22,5 @@ spec:
nodePort: {{ .Values.master.service.nodePort }}
{{- end }}
selector:
app: {{ template "redis.name" . }}
release: "{{ .Release.Name }}"
role: master
redis.io/role: master
{{ include "redis.instance-name" . | indent 4 }}
5 changes: 1 addition & 4 deletions stable/redis/templates/redis-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: Role
metadata:
name: {{ template "redis.fullname" . }}
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
rules:
{{ toYaml .Values.rbac.role.rules }}
{{- end -}}
5 changes: 1 addition & 4 deletions stable/redis/templates/redis-rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: RoleBinding
metadata:
name: {{ template "redis.fullname" . }}
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
5 changes: 1 addition & 4 deletions stable/redis/templates/redis-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@ kind: ServiceAccount
metadata:
name: {{ template "redis.serviceAccountName" . }}
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
{{- end -}}
16 changes: 5 additions & 11 deletions stable/redis/templates/redis-slave-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: Deployment
metadata:
name: {{ template "redis.fullname" . }}-slave
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
spec:
{{- if .Values.slave.updateStrategy }}
strategy:
Expand All @@ -18,16 +15,13 @@ spec:
{{- end }}
selector:
matchLabels:
release: "{{ .Release.Name }}"
role: slave
app: {{ template "redis.name" . }}
redis.io/role: slave
{{ include "redis.instance-name" . | indent 6 }}
template:
metadata:
labels:
release: "{{ .Release.Name }}"
chart: {{ template "redis.chart" . }}
role: slave
app: {{ template "redis.name" . }}
redis.io/role: slave
{{ include "redis.labels" . | indent 8 }}
{{- if (.Values.slave.podLabels | default .Values.master.podLabels) }}
{{ toYaml (.Values.slave.podLabels | default .Values.master.podLabels) | indent 8 }}
{{- end }}
Expand Down
10 changes: 3 additions & 7 deletions stable/redis/templates/redis-slave-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: Service
metadata:
name: {{ template "redis.fullname" . }}-slave
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
{{- if .Values.slave.service.annotations }}
annotations:
{{ toYaml .Values.slave.service.annotations | indent 4 }}
Expand All @@ -26,7 +23,6 @@ spec:
nodePort: {{ .Values.slave.service.nodePort }}
{{- end }}
selector:
app: {{ template "redis.name" . }}
release: "{{ .Release.Name }}"
role: slave
redis.io/role: slave
{{ include "redis.instance-name" . | indent 4 }}
{{- end}}
5 changes: 1 addition & 4 deletions stable/redis/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: Secret
metadata:
name: {{ template "redis.fullname" . }}
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{ include "redis.labels" . | indent 4 }}
type: Opaque
data:
{{- if .Values.password }}
Expand Down