Skip to content

Commit 94faff5

Browse files
Adopt Kubernetes label conventions (#4)
1 parent ed1ba61 commit 94faff5

21 files changed

Lines changed: 70 additions & 41 deletions

chart/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ apiVersion: v2
22
name: openops
33
description: A Helm chart for the OpenOps platform
44
type: application
5-
version: 0.1.1
5+
version: 0.2.0
66
appVersion: "latest"
77
icon: https://openops.com/favicon.ico

chart/templates/_helpers.tpl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,35 @@ app.kubernetes.io/name: {{ include "openops.name" . }}
4848
app.kubernetes.io/instance: {{ .Release.Name }}
4949
{{- end }}
5050

51+
{{/*
52+
Component-specific labels
53+
Expected dict: { "root": $, "component": "app" }
54+
*/}}
55+
{{- define "openops.componentLabels" -}}
56+
{{- $root := .root -}}
57+
{{- $component := .component -}}
58+
helm.sh/chart: {{ include "openops.chart" $root }}
59+
app.kubernetes.io/name: {{ include "openops.name" $root }}
60+
app.kubernetes.io/instance: {{ $root.Release.Name }}
61+
app.kubernetes.io/component: {{ $component }}
62+
{{- if $root.Chart.AppVersion }}
63+
app.kubernetes.io/version: {{ $root.Chart.AppVersion | quote }}
64+
{{- end }}
65+
app.kubernetes.io/managed-by: {{ $root.Release.Service }}
66+
{{- end }}
67+
68+
{{/*
69+
Component-specific selector labels
70+
Expected dict: { "root": $, "component": "app" }
71+
*/}}
72+
{{- define "openops.componentSelectorLabels" -}}
73+
{{- $root := .root -}}
74+
{{- $component := .component -}}
75+
app.kubernetes.io/name: {{ include "openops.name" $root }}
76+
app.kubernetes.io/instance: {{ $root.Release.Name }}
77+
app.kubernetes.io/component: {{ $component }}
78+
{{- end }}
79+
5180
{{/*
5281
Redis connection parameters
5382
*/}}

chart/templates/configmap-nginx.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: ConfigMap
33
metadata:
44
name: nginx-config
55
labels:
6-
app: {{ .Values.nginx.name }}
6+
{{- include "openops.componentLabels" (dict "root" . "component" "nginx") | nindent 4 }}
77
data:
88
nginx.gateway.conf: |
99
server {

chart/templates/configmap-postgres.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: ConfigMap
33
metadata:
44
name: postgres-init-script
55
labels:
6-
app: {{ .Values.postgres.name }}
6+
{{- include "openops.componentLabels" (dict "root" . "component" "postgres") | nindent 4 }}
77
data:
88
init-db.sh: |
99
#!/bin/bash

chart/templates/deployment-analytics.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ kind: Deployment
33
metadata:
44
name: {{ .Values.analytics.name }}
55
labels:
6-
app: {{ .Values.analytics.name }}
6+
{{- include "openops.componentLabels" (dict "root" . "component" "analytics") | nindent 4 }}
77
spec:
88
replicas: {{ .Values.analytics.replicas }}
99
selector:
1010
matchLabels:
11-
app: {{ .Values.analytics.name }}
11+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "analytics") | nindent 6 }}
1212
template:
1313
metadata:
1414
labels:
15-
app: {{ .Values.analytics.name }}
15+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "analytics") | nindent 8 }}
1616
spec:
1717
containers:
1818
- name: {{ .Values.analytics.name }}

chart/templates/deployment-app.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ kind: Deployment
33
metadata:
44
name: {{ .Values.app.name }}
55
labels:
6-
app: {{ .Values.app.name }}
6+
{{- include "openops.componentLabels" (dict "root" . "component" "app") | nindent 4 }}
77
spec:
88
replicas: {{ .Values.app.replicas }}
99
selector:
1010
matchLabels:
11-
app: {{ .Values.app.name }}
11+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "app") | nindent 6 }}
1212
template:
1313
metadata:
1414
labels:
15-
app: {{ .Values.app.name }}
15+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "app") | nindent 8 }}
1616
spec:
1717
containers:
1818
- name: {{ .Values.app.name }}

chart/templates/deployment-engine.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ kind: Deployment
33
metadata:
44
name: {{ .Values.engine.name }}
55
labels:
6-
app: {{ .Values.engine.name }}
6+
{{- include "openops.componentLabels" (dict "root" . "component" "engine") | nindent 4 }}
77
spec:
88
replicas: {{ .Values.engine.replicas }}
99
selector:
1010
matchLabels:
11-
app: {{ .Values.engine.name }}
11+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "engine") | nindent 6 }}
1212
template:
1313
metadata:
1414
labels:
15-
app: {{ .Values.engine.name }}
15+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "engine") | nindent 8 }}
1616
spec:
1717
containers:
1818
- name: {{ .Values.engine.name }}

chart/templates/deployment-nginx.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ kind: Deployment
33
metadata:
44
name: {{ .Values.nginx.name }}
55
labels:
6-
app: {{ .Values.nginx.name }}
6+
{{- include "openops.componentLabels" (dict "root" . "component" "nginx") | nindent 4 }}
77
spec:
88
replicas: {{ .Values.nginx.replicas }}
99
selector:
1010
matchLabels:
11-
app: {{ .Values.nginx.name }}
11+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "nginx") | nindent 6 }}
1212
template:
1313
metadata:
1414
labels:
15-
app: {{ .Values.nginx.name }}
15+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "nginx") | nindent 8 }}
1616
spec:
1717
containers:
1818
- name: {{ .Values.nginx.name }}

chart/templates/deployment-postgres.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ kind: Deployment
33
metadata:
44
name: {{ .Values.postgres.name }}
55
labels:
6-
app: {{ .Values.postgres.name }}
6+
{{- include "openops.componentLabels" (dict "root" . "component" "postgres") | nindent 4 }}
77
spec:
88
replicas: {{ .Values.postgres.replicas }}
99
selector:
1010
matchLabels:
11-
app: {{ .Values.postgres.name }}
11+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "postgres") | nindent 6 }}
1212
template:
1313
metadata:
1414
labels:
15-
app: {{ .Values.postgres.name }}
15+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "postgres") | nindent 8 }}
1616
spec:
1717
containers:
1818
- name: {{ .Values.postgres.name }}

chart/templates/deployment-redis.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ kind: Deployment
33
metadata:
44
name: {{ .Values.redis.name }}
55
labels:
6-
app: {{ .Values.redis.name }}
6+
{{- include "openops.componentLabels" (dict "root" . "component" "redis") | nindent 4 }}
77
spec:
88
replicas: {{ .Values.redis.replicas }}
99
selector:
1010
matchLabels:
11-
app: {{ .Values.redis.name }}
11+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "redis") | nindent 6 }}
1212
template:
1313
metadata:
1414
labels:
15-
app: {{ .Values.redis.name }}
15+
{{- include "openops.componentSelectorLabels" (dict "root" . "component" "redis") | nindent 8 }}
1616
spec:
1717
containers:
1818
- name: {{ .Values.redis.name }}

0 commit comments

Comments
 (0)