Skip to content

Commit 13ce605

Browse files
committed
move labels and selectorLabels into helper templates
1 parent 5060b0f commit 13ce605

21 files changed

+115
-489
lines changed

templates/_helpers.tpl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,40 @@ Expand the name of the chart.
55
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
66
{{- end -}}
77

8+
{{/*
9+
Create chart name and version as used by the chart label.
10+
*/}}
11+
{{- define "stackstorm-ha.chart" -}}
12+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
13+
{{- end -}}
14+
15+
{{/*
16+
Common labels
17+
Usage: "{{ include "stackstorm-ha.labels" "st2servicename" }}"
18+
*/}}
19+
{{- define "stackstorm-ha.labels" -}}
20+
{{ include "stackstorm-ha.selectorLabels" . }}
21+
{{- if list "st2web" "ingress" | has . }}
22+
tier: frontend
23+
{{- else if eq . "st2tests" }}
24+
tier: tests
25+
{{- else }}
26+
tier: backend
27+
{{- end }}
28+
vendor: stackstorm
29+
chart: {{ include "stackstorm-ha.chart" $ }}
30+
heritage: {{ $.Release.Service }}
31+
{{- end -}}
32+
33+
{{/*
34+
Selector labels
35+
Usage: "{{ include "stackstorm-ha.selectorLabels" "st2servicename" }}"
36+
*/}}
37+
{{- define "stackstorm-ha.selectorLabels" -}}
38+
app: {{ . }}
39+
release: {{ $.Release.Name }}
40+
{{- end -}}
41+
842
{{/*
943
Generate Docker image repository: Public Docker Hub 'stackstorm' for FOSS version
1044
*/}}

templates/configmaps_packs.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ metadata:
55
name: {{ .Release.Name }}-st2-pack-configs
66
annotations:
77
description: StackStorm pack configs defined in helm values, shipped in (or copied to) '/opt/stackstorm/configs/'
8-
labels:
9-
app: st2
10-
tier: backend
11-
vendor: stackstorm
12-
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
13-
release: {{ .Release.Name }}
14-
heritage: {{ .Release.Service }}
8+
labels: {{- include "stackstorm-ha.labels" "st2" | nindent 4 }}
159
data:
1610
{{ toYaml .Values.st2.packs.configs | indent 2 }}

templates/configmaps_post-start-script.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ metadata:
77
name: {{ $.Release.Name }}-{{ . }}-post-start-script
88
annotations:
99
description: Custom postStart lifecycle event handler script for {{ . }}
10-
labels:
11-
app: st2
12-
tier: backend
13-
vendor: stackstorm
14-
chart: {{ $.Chart.Name }}-{{ $.Chart.Version }}
15-
release: {{ $.Release.Name }}
16-
heritage: {{ $.Release.Service }}
10+
labels: {{- include "stackstorm-ha.labels" "st2" | nindent 4 }}
1711
data:
1812
# k8s calls this script in parallel with starting {{ . }} (ie the same time as ENTRYPOINT)
1913
# The pod will not be marked as "running" until this script completes successfully.

templates/configmaps_rbac.yaml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ metadata:
66
name: {{ .Release.Name }}-st2-rbac-roles
77
annotations:
88
description: Custom StackStorm RBAC roles, shipped in '/opt/stackstorm/rbac/roles/'
9-
labels:
10-
app: st2
11-
tier: backend
12-
vendor: stackstorm
13-
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
14-
release: {{ .Release.Name }}
15-
heritage: {{ .Release.Service }}
9+
labels: {{- include "stackstorm-ha.labels" "st2" | nindent 4 }}
1610
data:
1711
{{- range $filename, $contents := .Values.st2.rbac.roles }}
1812
{{/* to support removing default files, skip files with empty contents */}}
@@ -29,13 +23,7 @@ metadata:
2923
name: {{ .Release.Name }}-st2-rbac-assignments
3024
annotations:
3125
description: Custom StackStorm RBAC role assignments, shipped in '/opt/stackstorm/rbac/assignments/'
32-
labels:
33-
app: st2
34-
tier: backend
35-
vendor: stackstorm
36-
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
37-
release: {{ .Release.Name }}
38-
heritage: {{ .Release.Service }}
26+
labels: {{- include "stackstorm-ha.labels" "st2" | nindent 4 }}
3927
data:
4028
{{- range $filename, $contents := .Values.st2.rbac.assignments }}
4129
{{/* to support removing default files, skip files with empty contents */}}
@@ -52,13 +40,7 @@ metadata:
5240
name: {{ .Release.Name }}-st2-rbac-mappings
5341
annotations:
5442
description: StackStorm RBAC LDAP groups-to-roles mapping rules, shipped in '/opt/stackstorm/rbac/mappings/'
55-
labels:
56-
app: st2
57-
tier: backend
58-
vendor: stackstorm
59-
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
60-
release: {{ .Release.Name }}
61-
heritage: {{ .Release.Service }}
43+
labels: {{- include "stackstorm-ha.labels" "st2" | nindent 4 }}
6244
data:
6345
{{- if .Values.st2.rbac.mappings }}
6446
{{ toYaml .Values.st2.rbac.mappings | indent 2 }}

templates/configmaps_st2-conf.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ metadata:
55
name: {{ .Release.Name }}-st2-config
66
annotations:
77
description: Custom StackStorm config which will apply settings on top of default st2.conf
8-
labels:
9-
app: st2
10-
tier: backend
11-
vendor: stackstorm
12-
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
13-
release: {{ .Release.Name }}
14-
heritage: {{ .Release.Service }}
8+
labels: {{- include "stackstorm-ha.labels" "st2" | nindent 4 }}
159
data:
1610
# TODO: Bundle DB/MQ login secrets in dynamic ENV-based st2.secrets.conf, leave custom user-defined settings for st2.user.conf (?)
1711
# Docker/K8s-based st2 config file used for templating service names and common overrides on top of original st2.conf.

templates/configmaps_st2-urls.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ metadata:
55
name: {{ .Release.Name }}-st2-urls
66
annotations:
77
description: StackStorm service URLs, used across entire st2 cluster
8-
labels:
9-
app: st2
10-
tier: backend
11-
vendor: stackstorm
12-
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
13-
release: {{ .Release.Name }}
14-
heritage: {{ .Release.Service }}
8+
labels: {{- include "stackstorm-ha.labels" "st2" | nindent 4 }}
159
data:
1610
ST2_AUTH_URL: http://{{ .Release.Name }}-st2auth:9100/
1711
ST2_API_URL: http://{{ .Release.Name }}-st2api:9101/

templates/configmaps_st2web.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ metadata:
66
name: {{ .Release.Name }}-st2web-config
77
annotations:
88
description: Custom StackStorm Web config which will override defaults
9-
labels:
10-
app: st2
11-
tier: backend
12-
vendor: stackstorm
13-
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
14-
release: {{ .Release.Name }}
15-
heritage: {{ .Release.Service }}
9+
labels: {{- include "stackstorm-ha.labels" "st2" | nindent 4 }}
1610
data:
1711
# User-defined st2web config with custom settings to replace default config.js
1812
# See https://github.com/StackStorm/st2web#connecting-to-st2-server for more info

0 commit comments

Comments
 (0)