Skip to content

Commit

Permalink
[Insights Agent] Prometheus Collector (FairwindsOps#396)
Browse files Browse the repository at this point in the history
* Add prometheus collector

* Add subchart

* Add prometheus address

* Fix prometheus

* Add RBAC

* Add prometheus to list of repos

* Fix prometheus version

* Install prometheus on e2e tests

* Fix URL for prometheus

* Fix prometheus server name override

* Fix hostname

* Make prometheus run every 10 minutes

* Fixup default valueS

* Rename prometheus

* remove dash

* update helm dependencies

* fixed condition

* Update prometheus version

* Fix lint
  • Loading branch information
baderbuddy committed Dec 9, 2020
1 parent 537fc90 commit 28957ff
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 7 deletions.
1 change: 1 addition & 0 deletions scripts/ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ chart-repos:
- "jetstack=https://charts.jetstack.io"
- "fairwinds-stable=https://charts.fairwinds.com/stable"
- "fairwinds-incubator=https://charts.fairwinds.com/incubator"
- "prometheus-community=https://prometheus-community.github.io/helm-charts"
2 changes: 1 addition & 1 deletion stable/insights-agent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: A Helm chart to run the Fairwinds Insights agent
name: insights-agent
version: 1.2.0
version: 1.3.0
appVersion: 2.2.0
maintainers:
- name: rbren
Expand Down
1 change: 1 addition & 0 deletions stable/insights-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ There are several different report types which can be enabled and configured:
* `kubebench`
* `pluto`
* `opa`
* `prometheus`

See below for configuration details.

Expand Down
Binary file modified stable/insights-agent/charts/goldilocks-2.3.1.tgz
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions stable/insights-agent/ci/test-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ kubehunter:
trivy:
enabled: true
maxScansPerRun: 2

resourcemetrics:
enabled: true
installPrometheus: true
7 changes: 5 additions & 2 deletions stable/insights-agent/requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ dependencies:
- name: goldilocks
repository: https://charts.fairwinds.com/stable
version: 2.3.1
digest: sha256:0734b3efb9017569a001b9ac11749e2927c8284a8ca3e38e734617e262164abe
generated: "2020-05-01T09:29:55.491445-06:00"
- name: prometheus
repository: https://prometheus-community.github.io/helm-charts
version: 11.16.9
digest: sha256:5b9fe030149e681dd8ab9292854524d2fd01d8536351f98899f0cb1519a78f94
generated: "2020-12-07T11:10:53.373862-05:00"
12 changes: 8 additions & 4 deletions stable/insights-agent/requirements.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
dependencies:
- name: goldilocks
repository: https://charts.fairwinds.com/stable
version: 2.3.1
condition: goldilocks.enabled
- name: goldilocks
repository: https://charts.fairwinds.com/stable
version: 2.3.1
condition: goldilocks.enabled
- name: prometheus
repository: https://prometheus-community.github.io/helm-charts
version: 11.16.9
condition: resourcemetrics.installPrometheus
5 changes: 5 additions & 0 deletions stable/insights-agent/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ subjects:
name: {{ include "insights-agent.fullname" . }}-opa
namespace: {{ .Release.Namespace }}
{{- end }}
{{- if .Values.resourcemetrics.enabled }}
- kind: ServiceAccount
name: {{ include "insights-agent.fullname" . }}-resource-metrics
namespace: {{ .Release.Namespace }}
{{- end }}
{{- if .Values.goldilocks.enabled }}
- kind: ServiceAccount
name: {{ include "insights-agent.fullname" . }}-goldilocks
Expand Down
25 changes: 25 additions & 0 deletions stable/insights-agent/templates/resource-metrics/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.resourcemetrics.enabled -}}
{{- $_ := set . "Label" "resource-metrics" }}
{{- $_ := set . "Config" .Values.resourcemetrics }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
{{- include "metadata" . }}
spec:
{{ include "cronjob-spec" . | nindent 2 | trim }}
jobTemplate:
spec:
{{ include "job-spec" . | nindent 6 | trim }}
template:
spec:
{{ include "job-template-spec" . | indent 10 | trim }}
containers:
- {{ include "container-spec" . | indent 12 | trim }}
command:
- prometheus-collector
env:
- name: PROMETHEUS_ADDRESS
value: {{ .Values.resourcemetrics.address | quote }}
{{ include "security-context" . | indent 12 | trim }}
{{ include "uploaderContainer" . | indent 10 | trim }}
{{- end -}}
24 changes: 24 additions & 0 deletions stable/insights-agent/templates/resource-metrics/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.resourcemetrics.enabled -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "insights-agent.fullname" . }}-resource-metrics
labels:
app: insights-agent
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: {{ include "insights-agent.fullname" . }}-resource-metrics-view
labels:
app: insights-agent
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
subjects:
- kind: ServiceAccount
name: {{ include "insights-agent.fullname" . }}-resource-metrics
namespace: {{ .Release.Namespace }}
{{- end -}}

29 changes: 29 additions & 0 deletions stable/insights-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,35 @@ pluto:
cpu: 10m
memory: 64Mi

resourcemetrics:
enabled: false
installPrometheus: false
schedule: "0/10 * * * *"
timeout: 300
address: "http://prometheus-server"
image:
repository: quay.io/fairwinds/prometheus-collector
tag: "0.2"
resources:
limits:
cpu: 250m
memory: 512Mi
requests:
cpu: 10m
memory: 64Mi

prometheus:
alertmanager:
enabled: false
kubeStateMetrics:
enabled: false
nodeExporter:
enabled: false
pushgateway:
enabled: false
server:
fullnameOverride: "prometheus-server"

# test -- Used for chart CI only - deploys a test deployment
test:
enabled: false
Expand Down

0 comments on commit 28957ff

Please sign in to comment.