-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helm: Add servicemonitor support (#4094)
* Add servicemonitor support * Add prometheus operator crd to helm test Signed-off-by: QuentinBisson <[email protected]> --------- Signed-off-by: QuentinBisson <[email protected]>
- Loading branch information
1 parent
0b0b4a5
commit 6d9ae6b
Showing
13 changed files
with
341 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,5 +74,13 @@ jobs: | |
uses: helm/[email protected] | ||
if: steps.list-changed.outputs.changed == 'true' | ||
|
||
- name: Add dependency chart repos | ||
run: | | ||
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | ||
- name: Install Prometheus Operator CRDs | ||
run: | | ||
helm install my-prometheus-operator-crds prometheus-community/prometheus-operator-crds --version 6.0.0 | ||
- name: Test charts | ||
run: ct install --config ./operations/helm/ct.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
operations/helm/charts/grafana-agent/ci/enable-servicemonitor-values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Test rendering of the chart with the service monitor enabled | ||
service: | ||
enabled: true | ||
serviceMonitor: | ||
enabled: true |
29 changes: 29 additions & 0 deletions
29
operations/helm/charts/grafana-agent/templates/servicemonitor.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{{- if and .Values.service.enabled .Values.serviceMonitor.enabled -}} | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
name: {{ include "grafana-agent.fullname" . }} | ||
labels: | ||
{{- include "grafana-agent.labels" . | nindent 4 }} | ||
{{- with .Values.serviceMonitor.additionalLabels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
endpoints: | ||
- port: http-metrics | ||
honorLabels: true | ||
{{- if .Values.serviceMonitor.interval }} | ||
interval: {{ .Values.serviceMonitor.interval }} | ||
{{- end }} | ||
{{- if .Values.serviceMonitor.metricRelabelings }} | ||
metricRelabelings: | ||
{{ tpl (toYaml .Values.serviceMonitor.metricRelabelings | nindent 6) . }} | ||
{{- end }} | ||
{{- if .Values.serviceMonitor.relabelings }} | ||
relabelings: | ||
{{ tpl (toYaml .Values.serviceMonitor.relabelings | nindent 6) . }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "grafana-agent.selectorLabels" . | nindent 6 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
operations/helm/tests/enable-servicemonitor/grafana-agent/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
# Source: grafana-agent/templates/configmap.yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
data: | ||
config.river: |- | ||
logging { | ||
level = "info" | ||
format = "logfmt" | ||
} | ||
discovery.kubernetes "pods" { | ||
role = "pod" | ||
} | ||
discovery.kubernetes "nodes" { | ||
role = "node" | ||
} | ||
discovery.kubernetes "services" { | ||
role = "service" | ||
} | ||
discovery.kubernetes "endpoints" { | ||
role = "endpoints" | ||
} | ||
discovery.kubernetes "endpointslices" { | ||
role = "endpointslice" | ||
} | ||
discovery.kubernetes "ingresses" { | ||
role = "ingress" | ||
} |
70 changes: 70 additions & 0 deletions
70
...tions/helm/tests/enable-servicemonitor/grafana-agent/templates/controllers/daemonset.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
# Source: grafana-agent/templates/controllers/daemonset.yaml | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
spec: | ||
minReadySeconds: 10 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
spec: | ||
serviceAccountName: grafana-agent | ||
containers: | ||
- name: grafana-agent | ||
image: docker.io/grafana/agent:v0.36.1 | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- run | ||
- /etc/agent/config.river | ||
- --storage.path=/tmp/agent | ||
- --server.http.listen-addr=0.0.0.0:80 | ||
env: | ||
- name: AGENT_MODE | ||
value: flow | ||
- name: HOSTNAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
ports: | ||
- containerPort: 80 | ||
name: http-metrics | ||
readinessProbe: | ||
httpGet: | ||
path: /-/ready | ||
port: 80 | ||
initialDelaySeconds: 10 | ||
timeoutSeconds: 1 | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/agent | ||
- name: config-reloader | ||
image: docker.io/jimmidyson/configmap-reload:v0.8.0 | ||
args: | ||
- --volume-dir=/etc/agent | ||
- --webhook-url=http://localhost:80/-/reload | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/agent | ||
resources: | ||
requests: | ||
cpu: 1m | ||
memory: 5Mi | ||
dnsPolicy: ClusterFirst | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: grafana-agent |
101 changes: 101 additions & 0 deletions
101
operations/helm/tests/enable-servicemonitor/grafana-agent/templates/rbac.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
# Source: grafana-agent/templates/rbac.yaml | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
rules: | ||
# Rules which allow discovery.kubernetes to function. | ||
- apiGroups: | ||
- "" | ||
- "discovery.k8s.io" | ||
- "networking.k8s.io" | ||
resources: | ||
- endpoints | ||
- endpointslices | ||
- ingresses | ||
- nodes | ||
- nodes/proxy | ||
- nodes/metrics | ||
- pods | ||
- services | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# Rules which allow loki.source.kubernetes and loki.source.podlogs to work. | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
- pods/log | ||
- namespaces | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "monitoring.grafana.com" | ||
resources: | ||
- podlogs | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# Rules which allow mimir.rules.kubernetes to work. | ||
- apiGroups: ["monitoring.coreos.com"] | ||
resources: | ||
- prometheusrules | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- nonResourceURLs: | ||
- /metrics | ||
verbs: | ||
- get | ||
# Rules for prometheus.kubernetes.* | ||
- apiGroups: ["monitoring.coreos.com"] | ||
resources: | ||
- podmonitors | ||
- servicemonitors | ||
- probes | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# Rules which allow eventhandler to work. | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
--- | ||
# Source: grafana-agent/templates/rbac.yaml | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: grafana-agent | ||
subjects: | ||
- kind: ServiceAccount | ||
name: grafana-agent | ||
namespace: default |
22 changes: 22 additions & 0 deletions
22
operations/helm/tests/enable-servicemonitor/grafana-agent/templates/service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
# Source: grafana-agent/templates/service.yaml | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
ports: | ||
- name: http-metrics | ||
port: 80 | ||
targetPort: 80 | ||
protocol: "TCP" |
12 changes: 12 additions & 0 deletions
12
operations/helm/tests/enable-servicemonitor/grafana-agent/templates/serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
# Source: grafana-agent/templates/serviceaccount.yaml | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm |
20 changes: 20 additions & 0 deletions
20
operations/helm/tests/enable-servicemonitor/grafana-agent/templates/servicemonitor.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
# Source: grafana-agent/templates/servicemonitor.yaml | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
spec: | ||
endpoints: | ||
- port: http-metrics | ||
honorLabels: true | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent |