2018-06-05 19:23:47 +08:00
|
|
|
apiVersion: apps/v1beta2
|
|
|
|
kind: Deployment
|
|
|
|
metadata:
|
|
|
|
name: {{ template "grafana.fullname" . }}
|
|
|
|
labels:
|
|
|
|
app: {{ template "grafana.name" . }}
|
|
|
|
chart: {{ template "grafana.chart" . }}
|
|
|
|
release: {{ .Release.Name }}
|
|
|
|
heritage: {{ .Release.Service }}
|
|
|
|
{{- with .Values.annotations }}
|
|
|
|
annotations:
|
|
|
|
{{ toYaml . | indent 4 }}
|
|
|
|
{{- end }}
|
|
|
|
spec:
|
|
|
|
replicas: {{ .Values.replicas }}
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
app: {{ template "grafana.name" . }}
|
|
|
|
release: {{ .Release.Name }}
|
|
|
|
strategy:
|
|
|
|
type: {{ .Values.deploymentStrategy }}
|
2018-10-07 16:39:59 +08:00
|
|
|
{{- if ne .Values.deploymentStrategy "RollingUpdate" }}
|
|
|
|
rollingUpdate: null
|
|
|
|
{{- end }}
|
2018-06-05 19:23:47 +08:00
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: {{ template "grafana.name" . }}
|
|
|
|
release: {{ .Release.Name }}
|
|
|
|
{{- with .Values.podAnnotations }}
|
|
|
|
annotations:
|
|
|
|
{{ toYaml . | indent 8 }}
|
|
|
|
{{- end }}
|
|
|
|
spec:
|
|
|
|
serviceAccountName: {{ template "grafana.serviceAccountName" . }}
|
|
|
|
{{- if .Values.schedulerName }}
|
|
|
|
schedulerName: "{{ .Values.schedulerName }}"
|
|
|
|
{{- end }}
|
2018-10-07 16:39:59 +08:00
|
|
|
{{- if .Values.securityContext }}
|
|
|
|
securityContext:
|
|
|
|
{{ toYaml .Values.securityContext | indent 8 }}
|
|
|
|
{{- end }}
|
2018-06-05 19:23:47 +08:00
|
|
|
{{- if .Values.dashboards }}
|
|
|
|
initContainers:
|
|
|
|
- name: download-dashboards
|
|
|
|
image: "{{ .Values.downloadDashboardsImage.repository }}:{{ .Values.downloadDashboardsImage.tag }}"
|
|
|
|
imagePullPolicy: {{ .Values.downloadDashboardsImage.pullPolicy }}
|
|
|
|
command: ["sh", "/etc/grafana/download_dashboards.sh"]
|
|
|
|
volumeMounts:
|
|
|
|
- name: config
|
|
|
|
mountPath: "/etc/grafana/download_dashboards.sh"
|
|
|
|
subPath: download_dashboards.sh
|
|
|
|
- name: storage
|
|
|
|
mountPath: "/var/lib/grafana"
|
|
|
|
subPath: {{ .Values.persistence.subPath }}
|
|
|
|
{{- range .Values.extraSecretMounts }}
|
|
|
|
- name: {{ .name }}
|
|
|
|
mountPath: {{ .mountPath }}
|
|
|
|
readOnly: {{ .readOnly }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if .Values.image.pullSecrets }}
|
|
|
|
imagePullSecrets:
|
|
|
|
{{- range .Values.image.pullSecrets }}
|
|
|
|
- name: {{ . }}
|
|
|
|
{{- end}}
|
|
|
|
{{- end }}
|
|
|
|
containers:
|
2018-10-07 16:39:59 +08:00
|
|
|
{{- if .Values.sidecar.dashboards.enabled }}
|
|
|
|
- name: {{ template "grafana.name" . }}-sc-dashboard
|
|
|
|
image: "{{ .Values.sidecar.image }}"
|
|
|
|
imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
|
|
|
|
env:
|
|
|
|
- name: LABEL
|
|
|
|
value: "{{ .Values.sidecar.dashboards.label }}"
|
|
|
|
- name: FOLDER
|
|
|
|
value: "{{ .Values.sidecar.dashboards.folder }}"
|
|
|
|
resources:
|
|
|
|
{{ toYaml .Values.sidecar.resources | indent 12 }}
|
|
|
|
volumeMounts:
|
|
|
|
- name: sc-dashboard-volume
|
|
|
|
mountPath: {{ .Values.sidecar.dashboards.folder | quote }}
|
|
|
|
{{- end}}
|
|
|
|
{{- if .Values.sidecar.datasources.enabled }}
|
|
|
|
- name: {{ template "grafana.name" . }}-sc-datasources
|
|
|
|
image: "{{ .Values.sidecar.image }}"
|
|
|
|
imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
|
|
|
|
env:
|
|
|
|
- name: LABEL
|
|
|
|
value: "{{ .Values.sidecar.datasources.label }}"
|
|
|
|
- name: FOLDER
|
|
|
|
value: "/etc/grafana/provisioning/datasources"
|
|
|
|
resources:
|
|
|
|
{{ toYaml .Values.sidecar.resources | indent 12 }}
|
|
|
|
volumeMounts:
|
|
|
|
- name: sc-datasources-volume
|
|
|
|
mountPath: "/etc/grafana/provisioning/datasources"
|
|
|
|
{{- end}}
|
2018-06-05 19:23:47 +08:00
|
|
|
- name: {{ .Chart.Name }}
|
|
|
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
|
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
|
|
volumeMounts:
|
|
|
|
- name: config
|
|
|
|
mountPath: "/etc/grafana/grafana.ini"
|
|
|
|
subPath: grafana.ini
|
|
|
|
- name: ldap
|
|
|
|
mountPath: "/etc/grafana/ldap.toml"
|
|
|
|
subPath: ldap.toml
|
|
|
|
{{- if .Values.dashboards }}
|
2018-10-07 16:39:59 +08:00
|
|
|
{{- range $provider, $dashboards := .Values.dashboards }}
|
|
|
|
{{- range $key, $value := $dashboards }}
|
|
|
|
{{- if hasKey $value "json" }}
|
|
|
|
- name: dashboards-{{ $provider }}
|
|
|
|
mountPath: "/var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json"
|
|
|
|
subPath: "{{ $key }}.json"
|
|
|
|
{{- end }}
|
2018-06-05 19:23:47 +08:00
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
2018-10-07 16:39:59 +08:00
|
|
|
{{- if .Values.dashboardsConfigMaps }}
|
|
|
|
{{- range keys .Values.dashboardsConfigMaps }}
|
|
|
|
- name: dashboards-{{ . }}
|
|
|
|
mountPath: "/var/lib/grafana/dashboards/{{ . }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2018-06-05 19:23:47 +08:00
|
|
|
{{- if .Values.datasources }}
|
|
|
|
- name: config
|
|
|
|
mountPath: "/etc/grafana/provisioning/datasources/datasources.yaml"
|
|
|
|
subPath: datasources.yaml
|
|
|
|
{{- end }}
|
|
|
|
{{- if .Values.dashboardProviders }}
|
|
|
|
- name: config
|
|
|
|
mountPath: "/etc/grafana/provisioning/dashboards/dashboardproviders.yaml"
|
|
|
|
subPath: dashboardproviders.yaml
|
|
|
|
{{- end }}
|
2018-10-07 16:39:59 +08:00
|
|
|
{{- if .Values.sidecar.dashboards.enabled }}
|
|
|
|
- name: sc-dashboard-volume
|
|
|
|
mountPath: {{ .Values.sidecar.dashboards.folder | quote }}
|
|
|
|
- name: sc-dashboard-provider
|
|
|
|
mountPath: "/etc/grafana/provisioning/dashboards/sc-dashboardproviders.yaml"
|
|
|
|
subPath: provider.yaml
|
|
|
|
{{- end}}
|
|
|
|
{{- if .Values.sidecar.datasources.enabled }}
|
|
|
|
- name: sc-datasources-volume
|
|
|
|
mountPath: "/etc/grafana/provisioning/datasources"
|
|
|
|
{{- end}}
|
2018-06-05 19:23:47 +08:00
|
|
|
- name: storage
|
|
|
|
mountPath: "/var/lib/grafana"
|
|
|
|
subPath: {{ .Values.persistence.subPath }}
|
2018-10-07 16:39:59 +08:00
|
|
|
{{- range .Values.extraSecretMounts }}
|
|
|
|
- name: {{ .name }}
|
|
|
|
mountPath: {{ .mountPath }}
|
|
|
|
readOnly: {{ .readOnly }}
|
|
|
|
{{- end }}
|
2018-06-05 19:23:47 +08:00
|
|
|
ports:
|
|
|
|
- name: service
|
|
|
|
containerPort: {{ .Values.service.port }}
|
|
|
|
protocol: TCP
|
|
|
|
- name: grafana
|
|
|
|
containerPort: 3000
|
|
|
|
protocol: TCP
|
|
|
|
env:
|
|
|
|
- name: GF_SECURITY_ADMIN_USER
|
|
|
|
valueFrom:
|
|
|
|
secretKeyRef:
|
|
|
|
name: {{ template "grafana.fullname" . }}
|
|
|
|
key: admin-user
|
|
|
|
- name: GF_SECURITY_ADMIN_PASSWORD
|
|
|
|
valueFrom:
|
|
|
|
secretKeyRef:
|
|
|
|
name: {{ template "grafana.fullname" . }}
|
|
|
|
key: admin-password
|
|
|
|
{{- if .Values.plugins }}
|
|
|
|
- name: GF_INSTALL_PLUGINS
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: {{ template "grafana.fullname" . }}
|
|
|
|
key: plugins
|
|
|
|
{{- end }}
|
|
|
|
{{- if .Values.smtp.existingSecret }}
|
|
|
|
- name: GF_SMTP_USER
|
|
|
|
valueFrom:
|
|
|
|
secretKeyRef:
|
|
|
|
name: {{ .Values.smtp.existingSecret }}
|
|
|
|
key: user
|
|
|
|
- name: GF_SMTP_PASSWORD
|
|
|
|
valueFrom:
|
|
|
|
secretKeyRef:
|
|
|
|
name: {{ .Values.smtp.existingSecret }}
|
|
|
|
key: password
|
|
|
|
{{- end }}
|
|
|
|
{{- range $key, $value := .Values.env }}
|
|
|
|
- name: "{{ $key }}"
|
|
|
|
value: "{{ $value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- if .Values.envFromSecret }}
|
|
|
|
envFrom:
|
|
|
|
- secretRef:
|
|
|
|
name: {{ .Values.envFromSecret }}
|
|
|
|
{{- end }}
|
|
|
|
livenessProbe:
|
2018-10-07 16:39:59 +08:00
|
|
|
{{ toYaml .Values.livenessProbe | indent 12 }}
|
2018-06-05 19:23:47 +08:00
|
|
|
readinessProbe:
|
2018-10-07 16:39:59 +08:00
|
|
|
{{ toYaml .Values.readinessProbe | indent 12 }}
|
2018-06-05 19:23:47 +08:00
|
|
|
resources:
|
|
|
|
{{ toYaml .Values.resources | indent 12 }}
|
|
|
|
{{- with .Values.nodeSelector }}
|
|
|
|
nodeSelector:
|
|
|
|
{{ toYaml . | indent 8 }}
|
|
|
|
{{- end }}
|
|
|
|
{{- with .Values.affinity }}
|
|
|
|
affinity:
|
|
|
|
{{ toYaml . | indent 8 }}
|
|
|
|
{{- end }}
|
|
|
|
{{- with .Values.tolerations }}
|
|
|
|
tolerations:
|
|
|
|
{{ toYaml . | indent 8 }}
|
|
|
|
{{- end }}
|
|
|
|
volumes:
|
|
|
|
- name: config
|
|
|
|
configMap:
|
|
|
|
name: {{ template "grafana.fullname" . }}
|
2018-10-07 16:39:59 +08:00
|
|
|
{{- if .Values.dashboards }}
|
|
|
|
{{- range keys .Values.dashboards }}
|
|
|
|
- name: dashboards-{{ . }}
|
2018-06-05 19:23:47 +08:00
|
|
|
configMap:
|
2018-10-07 16:39:59 +08:00
|
|
|
name: {{ template "grafana.fullname" $ }}-dashboards-{{ . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if .Values.dashboardsConfigMaps }}
|
|
|
|
{{- range $provider, $name := .Values.dashboardsConfigMaps }}
|
|
|
|
- name: dashboards-{{ $provider }}
|
|
|
|
configMap:
|
|
|
|
name: {{ $name }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2018-06-05 19:23:47 +08:00
|
|
|
- name: ldap
|
|
|
|
secret:
|
|
|
|
{{- if .Values.ldap.existingSecret }}
|
|
|
|
secretName: {{ .Values.ldap.existingSecret }}
|
|
|
|
{{- else }}
|
|
|
|
secretName: {{ template "grafana.fullname" . }}
|
|
|
|
{{- end }}
|
|
|
|
items:
|
|
|
|
- key: ldap-toml
|
|
|
|
path: ldap.toml
|
|
|
|
- name: storage
|
|
|
|
{{- if .Values.persistence.enabled }}
|
|
|
|
persistentVolumeClaim:
|
|
|
|
claimName: {{ .Values.persistence.existingClaim | default (include "grafana.fullname" .) }}
|
|
|
|
{{- else }}
|
|
|
|
emptyDir: {}
|
|
|
|
{{- end -}}
|
2018-10-07 16:39:59 +08:00
|
|
|
{{- if .Values.sidecar.dashboards.enabled }}
|
|
|
|
- name: sc-dashboard-volume
|
|
|
|
emptyDir: {}
|
|
|
|
- name: sc-dashboard-provider
|
|
|
|
configMap:
|
|
|
|
name: {{ template "grafana.fullname" . }}-config-dashboards
|
|
|
|
{{- end }}
|
|
|
|
{{- if .Values.sidecar.datasources.enabled }}
|
|
|
|
- name: sc-datasources-volume
|
|
|
|
emptyDir: {}
|
|
|
|
{{- end -}}
|
2018-06-05 19:23:47 +08:00
|
|
|
{{- range .Values.extraSecretMounts }}
|
|
|
|
- name: {{ .name }}
|
|
|
|
secret:
|
|
|
|
secretName: {{ .secretName }}
|
2018-10-07 16:39:59 +08:00
|
|
|
defaultMode: {{ .defaultMode }}
|
2018-06-05 19:23:47 +08:00
|
|
|
{{- end }}
|