Skip to content

Commit 2249e59

Browse files
authored
feat(helm): adds common label support to the helm chart (#6042)
feat: adds common label support to the helm chart Signed-off-by: Gagan H R <[email protected]>
1 parent a99f1dd commit 2249e59

File tree

7 files changed

+126
-0
lines changed

7 files changed

+126
-0
lines changed

contrib/charts/dragonfly/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ helm upgrade --install dragonfly oci://ghcr.io/dragonflydb/dragonfly/helm/dragon
3232
|-----|------|---------|-------------|
3333
| affinity | object | `{}` | Affinity for pod assignment |
3434
| command | list | `[]` | Allow overriding the container's command |
35+
| commonLabels | object | `{}` | Common labels to add to all K8s resources |
3536
| extraArgs | list | `[]` | Extra arguments to pass to the dragonfly binary |
3637
| extraContainers | list | `[]` | Additional sidecar containers |
3738
| extraObjects | list | `[]` | extra K8s manifests to deploy |
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
# Source: dragonfly/templates/serviceaccount.yaml
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: test-dragonfly
7+
namespace: default
8+
labels:
9+
app.kubernetes.io/name: dragonfly
10+
app.kubernetes.io/instance: test
11+
app.kubernetes.io/version: "v1.34.2"
12+
app.kubernetes.io/managed-by: Helm
13+
project: cache-infrastructure
14+
team: platform
15+
---
16+
# Source: dragonfly/templates/service.yaml
17+
apiVersion: v1
18+
kind: Service
19+
metadata:
20+
name: test-dragonfly
21+
namespace: default
22+
labels:
23+
app.kubernetes.io/name: dragonfly
24+
app.kubernetes.io/instance: test
25+
app.kubernetes.io/version: "v1.34.2"
26+
app.kubernetes.io/managed-by: Helm
27+
project: cache-infrastructure
28+
team: platform
29+
spec:
30+
type: ClusterIP
31+
ports:
32+
- port: 6379
33+
targetPort: dragonfly
34+
protocol: TCP
35+
name: dragonfly
36+
selector:
37+
app.kubernetes.io/name: dragonfly
38+
app.kubernetes.io/instance: test
39+
---
40+
# Source: dragonfly/templates/deployment.yaml
41+
apiVersion: apps/v1
42+
kind: Deployment
43+
metadata:
44+
name: test-dragonfly
45+
namespace: default
46+
labels:
47+
app.kubernetes.io/name: dragonfly
48+
app.kubernetes.io/instance: test
49+
app.kubernetes.io/version: "v1.34.2"
50+
app.kubernetes.io/managed-by: Helm
51+
project: cache-infrastructure
52+
team: platform
53+
spec:
54+
replicas: 1
55+
selector:
56+
matchLabels:
57+
app.kubernetes.io/name: dragonfly
58+
app.kubernetes.io/instance: test
59+
template:
60+
metadata:
61+
annotations:
62+
labels:
63+
app.kubernetes.io/name: dragonfly
64+
app.kubernetes.io/instance: test
65+
project: cache-infrastructure
66+
team: platform
67+
spec:
68+
serviceAccountName: test-dragonfly
69+
containers:
70+
- name: dragonfly
71+
image: "docker.dragonflydb.io/dragonflydb/dragonfly:v1.34.2"
72+
imagePullPolicy: IfNotPresent
73+
ports:
74+
- name: dragonfly
75+
containerPort: 6379
76+
protocol: TCP
77+
livenessProbe:
78+
exec:
79+
command:
80+
- /bin/sh
81+
- /usr/local/bin/healthcheck.sh
82+
failureThreshold: 3
83+
initialDelaySeconds: 10
84+
periodSeconds: 10
85+
successThreshold: 1
86+
timeoutSeconds: 5
87+
readinessProbe:
88+
exec:
89+
command:
90+
- /bin/sh
91+
- /usr/local/bin/healthcheck.sh
92+
failureThreshold: 3
93+
initialDelaySeconds: 10
94+
periodSeconds: 10
95+
successThreshold: 1
96+
timeoutSeconds: 5
97+
args:
98+
- "--alsologtostderr"
99+
resources:
100+
limits: {}
101+
requests: {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
commonLabels:
2+
team: platform
3+
project: cache-infrastructure

contrib/charts/dragonfly/templates/_helpers.tpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ helm.sh/chart: {{ include "dragonfly.chart" . }}
4040
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4141
{{- end }}
4242
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- include "dragonfly.commonLabels" . }}
44+
{{- end }}
45+
46+
{{/*
47+
User-defined common labels
48+
*/}}
49+
{{- define "dragonfly.commonLabels" -}}
50+
{{- if .Values.commonLabels }}
51+
{{- range $key, $value := .Values.commonLabels }}
52+
{{ $key }}: {{ $value }}
53+
{{- end }}
54+
{{- end }}
4355
{{- end }}
4456

4557
{{/*

contrib/charts/dragonfly/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ spec:
2222
{{- end }}
2323
labels:
2424
{{- include "dragonfly.selectorLabels" . | nindent 8 }}
25+
{{- if .Values.commonLabels }}
26+
{{- include "dragonfly.commonLabels" . | trim | nindent 8 }}
27+
{{- end }}
2528
spec:
2629
{{- include "dragonfly.pod" . | trim | nindent 6 }}
2730
{{- end }}

contrib/charts/dragonfly/templates/statefulset.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ spec:
2323
{{- end }}
2424
labels:
2525
{{- include "dragonfly.selectorLabels" . | nindent 8 }}
26+
{{- if .Values.commonLabels }}
27+
{{- include "dragonfly.commonLabels" . | trim | nindent 8 }}
28+
{{- end }}
2629
spec:
2730
{{- include "dragonfly.pod" . | trim | nindent 6 }}
2831
volumeClaimTemplates:

contrib/charts/dragonfly/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ nameOverride: ""
2222
# -- String to fully override dragonfly.fullname
2323
fullnameOverride: ""
2424

25+
# -- Common labels to add to all resources
26+
commonLabels: {}
27+
2528
serviceAccount:
2629
# -- Specifies whether a service account should be created
2730
create: true

0 commit comments

Comments
 (0)