Skip to content

Commit

Permalink
added template helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ironoa committed Mar 10, 2023
1 parent e100a01 commit 68a0356
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
4 changes: 4 additions & 0 deletions charts/polkadot-watcher/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{/* Returns the app name */}}
{{- define "app.name" -}}
{{- default .Release.Name .Values.nameOverride -}}
{{- end }}
4 changes: 2 additions & 2 deletions charts/polkadot-watcher/templates/alertrules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ kind: PrometheusRule
metadata:
labels:
{{ toYaml .Values.prometheusRules.labels | indent 4 }}
name: {{ .Release.Name }}
name: {{ include "app.name" . }}
spec:
groups:
- name: {{ .Release.Name }}.rules
- name: {{ include "app.name" . }}-{{ .Values.config.environment }}.rules
rules:
- alert: ValidatorOutOfActiveSet
annotations:
Expand Down
2 changes: 1 addition & 1 deletion charts/polkadot-watcher/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}
name: {{ include "app.name" . }}
data:
main.yaml: |-
{{ toYaml .Values.config | indent 4 }}
12 changes: 6 additions & 6 deletions charts/polkadot-watcher/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
name: {{ include "app.name" . }}
labels:
app: {{ .Release.Name }}
app: {{ include "app.name" . }}
spec:
replicas: 1
revisionHistoryLimit: 3
strategy:
type: RollingUpdate
selector:
matchLabels:
app: {{ .Release.Name }}
app: {{ include "app.name" . }}
template:
metadata:
labels:
app: {{ .Release.Name }}
app: {{ include "app.name" . }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
containers:
- name: {{ .Release.Name }}
- name: {{ include "app.name" . }}
image: {{ .Values.image.repo }}:{{ .Values.image.tag | default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.image.pullPolicy | default "Always" }}
args:
Expand All @@ -45,4 +45,4 @@ spec:
volumes:
- name: config
configMap:
name: {{ .Release.Name }}
name: {{ include "app.name" . }}
6 changes: 3 additions & 3 deletions charts/polkadot-watcher/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}
name: {{ include "app.name" . }}
labels:
app: {{ .Release.Name }}
app: {{ include "app.name" . }}
spec:
ports:
- name: metrics
port: {{ .Values.config.port }}
selector:
app: {{ .Release.Name }}
app: {{ include "app.name" . }}
4 changes: 2 additions & 2 deletions charts/polkadot-watcher/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ .Release.Name }}
name: {{ include "app.name" . }}
labels:
{{ toYaml .Values.serviceMonitor.labels | indent 4 }}
spec:
selector:
matchLabels:
app: {{ .Release.Name }}
app: {{ include "app.name" . }}
endpoints:
- port: metrics
{{ end }}

0 comments on commit 68a0356

Please sign in to comment.