Skip to content

Commit b798fec

Browse files
committed
chore(prometheus): add scrape namespace
1 parent b50a867 commit b798fec

4 files changed

Lines changed: 92 additions & 3 deletions

File tree

addons/prometheus/2/chart/prometheus/templates/_scrape_config.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,12 @@ kubernetes_sd_configs:
9292
- role: endpoints
9393
namespaces:
9494
own_namespace: true
95-
names:
95+
names:
9696
- {{ include "common.names.namespace" .context }}
97+
{{- range .value }}
98+
- {{ include "common.tplvalues.render" (dict "value" . "context" $) }}
99+
{{- end }}
100+
97101
relabel_configs:
98102
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
99103
action: keep

addons/prometheus/2/chart/prometheus/templates/server/deployment.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,41 @@ spec:
9595
{{- include "common.tplvalues.render" (dict "value" .Values.server.initContainers "context" $) | nindent 8 }}
9696
{{- end }}
9797
containers:
98+
{{- if .Values.configmapReload.prometheus.enabled }}
99+
- name: prometheus-reload
100+
image: "{{ .Values.configmapReload.prometheus.image.repository }}:{{ .Values.configmapReload.prometheus.image.tag }}"
101+
imagePullPolicy: "{{ .Values.configmapReload.prometheus.image.pullPolicy }}"
102+
{{- with .Values.configmapReload.prometheus.containerSecurityContext }}
103+
securityContext:
104+
{{- toYaml . | nindent 12 }}
105+
{{- end }}
106+
args:
107+
- --volume-dir=/opt/drycc/prometheus/conf/
108+
- --webhook-url=http://{{ .Values.server.username }}:{{ .Values.server.password}}@127.0.0.1:9090{{ .Values.server.prefixURL }}/-/reload
109+
{{- range $key, $value := .Values.configmapReload.prometheus.extraArgs }}
110+
- --{{ $key }}={{ $value }}
111+
{{- end }}
112+
{{- range .Values.configmapReload.prometheus.extraVolumeDirs }}
113+
- --volume-dir={{ . }}
114+
{{- end }}
115+
{{- if .Values.configmapReload.prometheus.containerPort }}
116+
ports:
117+
- containerPort: {{ .Values.configmapReload.prometheus.containerPort }}
118+
{{- end }}
119+
resources:
120+
{{ toYaml .Values.configmapReload.prometheus.resources | indent 12 }}
121+
volumeMounts:
122+
- name: config
123+
mountPath: /opt/drycc/prometheus/conf/
124+
readOnly: true
125+
{{- range .Values.configmapReload.prometheus.extraConfigmapMounts }}
126+
- name: {{ $.Values.configmapReload.prometheus.name }}-{{ .name }}
127+
mountPath: {{ .mountPath }}
128+
subPath: {{ .subPath }}
129+
readOnly: {{ .readOnly }}
130+
{{- end }}
131+
{{- end }}
132+
98133
- name: prometheus
99134
image: {{ template "prometheus.server.image" . }}
100135
imagePullPolicy: {{ .Values.server.image.pullPolicy }}

addons/prometheus/2/chart/prometheus/values.yaml

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ alertmanager:
578578
##
579579
server:
580580
username: admin
581-
password: To6EJBHPUo
581+
password: Sx3EIELCA
582582
image:
583583
registry: registry.drycc.cc
584584
repository: drycc-addons/prometheus
@@ -636,7 +636,7 @@ server:
636636
{{- end }}
637637
{{- if .Values.scrapeAddons.enabled }}
638638
- job_name: addons
639-
{{- include "addons.ds_scrape_config" (dict "context" $) | nindent 4 }}
639+
{{- include "addons.ds_scrape_config" (dict "value" .Values.scrapeNamespaces "context" $) | nindent 4 }}
640640
{{- end }}
641641
{{- if .Values.server.extraScrapeConfigs}}
642642
{{- include "common.tplvalues.render" (dict "value" .Values.server.extraScrapeConfigs "context" $) | nindent 2 }}
@@ -1558,3 +1558,51 @@ volumePermissions:
15581558

15591559
scrapeAddons:
15601560
enabled: true
1561+
1562+
scrapeNamespaces:
1563+
- xx1
1564+
- xx2
1565+
1566+
configmapReload:
1567+
prometheus:
1568+
## If false, the configmap-reload container will not be deployed
1569+
##
1570+
enabled: true
1571+
1572+
## configmap-reload container name
1573+
##
1574+
name: configmap-reload
1575+
1576+
## configmap-reload container image
1577+
##
1578+
image:
1579+
repository: jimmidyson/configmap-reload
1580+
tag: v0.5.0
1581+
pullPolicy: IfNotPresent
1582+
1583+
# containerPort: 9533
1584+
1585+
## Additional configmap-reload container arguments
1586+
##
1587+
extraArgs: {}
1588+
## Additional configmap-reload volume directories
1589+
##
1590+
extraVolumeDirs: []
1591+
1592+
1593+
## Additional configmap-reload mounts
1594+
##
1595+
extraConfigmapMounts: []
1596+
# - name: prometheus-alerts
1597+
# mountPath: /etc/alerts.d
1598+
# subPath: ""
1599+
# configMap: prometheus-alerts
1600+
# readOnly: true
1601+
1602+
## Security context to be added to configmap-reload container
1603+
containerSecurityContext: {}
1604+
1605+
## configmap-reload resource requests and limits
1606+
## Ref: http://kubernetes.io/docs/user-guide/compute-resources/
1607+
##
1608+
resources: {}

addons/prometheus/2/meta.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ allow_parameters:
3333
- name: "server.rules"
3434
required: false
3535
description: "rules config for values.yaml"
36+
- name: "scrapeNamespaces"
37+
required: false
3638
archive: false

0 commit comments

Comments
 (0)