Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Prometheus as an Add-On #4362

Merged
merged 54 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
913ca77
move prometheus templates as a add-on
Pothulapati May 6, 2020
0d675af
remove prom flags and fix fiields
Pothulapati May 6, 2020
751d236
prometheus charts linting
Pothulapati May 8, 2020
04bbcae
use common fix
Pothulapati May 8, 2020
6947cd0
add prometheus sub-chart dep to linkerd2
Pothulapati May 8, 2020
48cc206
update golden files
Pothulapati May 8, 2020
79e15b3
update install metaValues test
Pothulapati May 8, 2020
3fe342e
Merge branch 'master' into tarun/prom-addon
Pothulapati May 8, 2020
be3d3ea
fix template correctly
Pothulapati May 10, 2020
ab854df
remove linkerd-prometheus healthchecks
Pothulapati May 10, 2020
d54ad31
add more fields for configuration
Pothulapati May 11, 2020
92a72cb
add extra prometheus config tests
Pothulapati May 11, 2020
f8152de
fix prom example config
Pothulapati May 11, 2020
2ee0ead
Merge branch 'master' into tarun/prom-addon
Pothulapati May 11, 2020
4fb9c38
update golden files
Pothulapati May 11, 2020
d801768
remove grafana.enabled check in prometheus
Pothulapati May 11, 2020
bfd5b24
rename to prometheus test
Pothulapati May 12, 2020
ec245e1
full config with examples
Pothulapati May 13, 2020
e3d58c6
add args documentation in charts/README.md
Pothulapati May 13, 2020
e5dbbd4
fix name in docs
Pothulapati May 13, 2020
c8ba283
fix ruleConfigMapMounts
Pothulapati May 13, 2020
72f9ade
Merge branch 'master' into tarun/prom-addon
Pothulapati Jun 15, 2020
49be09b
update go tests golden files
Pothulapati Jun 15, 2020
347354c
remove unfixed changes
Pothulapati Jun 15, 2020
79f7a78
remove .Prometheus.name variable
Pothulapati Jun 16, 2020
9643504
Merge branch 'master' into tarun/prom-addon
Pothulapati Jun 16, 2020
95c3ae2
update golden files
Pothulapati Jun 16, 2020
4921b86
move defaults out of prometheus.
Pothulapati Jun 16, 2020
339f032
move controllerLogLevel to global
Pothulapati Jun 19, 2020
7ed92da
Merge branch 'master' into tarun/prom-addon
Pothulapati Jun 19, 2020
3be8cf3
update golden files
Pothulapati Jun 19, 2020
2fd46b9
remove unnecessar functions related promLog
Pothulapati Jun 19, 2020
1a0a212
use global.controllerLogLevel
Pothulapati Jun 19, 2020
0484125
update golden files
Pothulapati Jun 19, 2020
2edea90
move default values to add-ons/values.yaml
Pothulapati Jun 22, 2020
d318efe
nits around readme, requirements ordering and prom log default
Pothulapati Jun 23, 2020
d03b3b3
update golden files
Pothulapati Jun 23, 2020
f5fc848
move scrapeconfigs to templates
Pothulapati Jun 24, 2020
946f7f8
add correct scrape config indentation
Pothulapati Jun 24, 2020
c4792cd
Merge branch 'main' into tarun/prom-addon
Pothulapati Jun 25, 2020
f663373
update prometheus add-on to include proxy resources along with tests
Pothulapati Jun 25, 2020
725dc2e
add instructions in prometheus/values.yaml
Pothulapati Jun 29, 2020
1952bbf
Merge branch 'main' into tarun/prom-addon
Pothulapati Jun 30, 2020
b6c3aa9
Merge branch 'main' into tarun/prom-addon
Pothulapati Jul 4, 2020
a1650ee
update golden files
Pothulapati Jul 4, 2020
97ecefa
make prometheus urls optional and based on add-on
Pothulapati Jul 6, 2020
2c65d13
Merge branch 'main' into tarun/prom-addon
Pothulapati Jul 7, 2020
05057cd
update golden files
Pothulapati Jul 7, 2020
5ad5cad
Merge branch 'main' into tarun/prom-addon
Pothulapati Jul 8, 2020
81030d1
Merge branch 'main' into tarun/prom-addon
Pothulapati Jul 8, 2020
2ab6472
updates golden files now that add-on level values
Pothulapati Jul 8, 2020
3769341
update prom template to not have default value
Pothulapati Jul 8, 2020
4232b61
Merge branch 'main' into tarun/prom-addon
Pothulapati Jul 9, 2020
af63998
update golden files
Pothulapati Jul 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions charts/add-ons/prometheus/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions charts/add-ons/prometheus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for the prometheus add-on in Linkerd
name: prometheus
version: 0.1.0
maintainers:
- name: Linkerd authors
email: cncf-linkerd-dev@lists.cncf.io
url: https://linkerd.io/
4 changes: 4 additions & 0 deletions charts/add-ons/prometheus/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies:
- name: partials
version: 0.1.0
repository: file://../../partials
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ metadata:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
data:
prometheus.yml: |-
{{- if .Values.prometheusAlertmanagers }}
alerting:
alertmanagers:
{{- toYaml .Values.prometheusAlertmanagers | trim | nindent 8 }}
{{- end }}
global:
scrape_interval: 10s
scrape_timeout: 10s
evaluation_interval: 10s
{{- if .Values.globalConfig -}}
{{- toYaml .Values.globalConfig | trim | nindent 6 }}
{{- end}}

rule_files:
- /etc/prometheus/*_rules.yml
Expand All @@ -34,7 +29,6 @@ data:
static_configs:
- targets: ['localhost:9090']

{{ if .Values.grafana.enabled -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the removal of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alpeb As grafana is a separate add-on, and those fields are only propagated into their sub-chart. We can't get this value in Prometheus add-on.

I don't think prometheus would have any problem regarding the scrape-config even when there is no grafana, but I will test this out!

For other fields that would need to be accessed across multiple add-ons, we can use the global and have that in linkerd-config-addons!

- job_name: 'grafana'
kubernetes_sd_configs:
- role: pod
Expand All @@ -45,7 +39,6 @@ data:
- __meta_kubernetes_pod_container_name
action: keep
regex: ^grafana$
{{- end}}

# Required for: https://grafana.com/grafana/dashboards/315
- job_name: 'kubernetes-nodes-cadvisor'
Expand All @@ -54,7 +47,6 @@ data:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token

kubernetes_sd_configs:
- role: node
relabel_configs:
Expand Down Expand Up @@ -153,6 +145,27 @@ data:
# Copy tmp labels into real labels
- action: labelmap
regex: __tmp_pod_label_(.+)

{{- if .Values.scrapeConfigs }}
{{- toYaml .Values.scrapeConfigs | trim | nindent 4 }}
{{- end }}

{{- if (or .Values.alertManagers .Values.alertRelabelConfigs) }}
alerting:
alert_relabel_configs:
{{- if .Values.alertRelabelConfigs }}
{{- toYaml .Values.alertRelabelConfigs | trim | nindent 6 }}
{{- end }}
alertmanagers:
{{- if .Values.alertManagers }}
{{- toYaml .Values.alertManagers | trim | nindent 6 }}
{{- end }}
{{- end }}

{{- if .Values.remoteWrite }}
remote_write:
{{- toYaml .Values.remoteWrite | trim | nindent 4 }}
{{- end }}
---
kind: Service
apiVersion: v1
Expand Down Expand Up @@ -210,14 +223,10 @@ spec:
{{- include "linkerd.node-selector" . | nindent 6 }}
containers:
- args:
- --storage.tsdb.path=/data
- --storage.tsdb.retention.time=6h
- --config.file=/etc/prometheus/prometheus.yml
- --log.level={{lower .Values.prometheusLogLevel}}
{{- range $key, $value := .Values.prometheusExtraArgs}}
{{- range $key, $value := .Values.args}}
- --{{ $key }}{{ if $value }}={{ $value }}{{ end }}
{{- end }}
image: {{.Values.prometheusImage}}
image: {{ default "prom/prometheus:v2.15.2" .Values.image }}
imagePullPolicy: {{.Values.global.imagePullPolicy}}
livenessProbe:
httpGet:
Expand All @@ -235,13 +244,13 @@ spec:
port: 9090
initialDelaySeconds: 30
timeoutSeconds: 30
{{- if .Values.prometheusResources -}}
{{- include "partials.resources" .Values.prometheusResources | nindent 8 }}
{{- if .Values.resources -}}
{{- include "partials.resources" .Values.resources | nindent 8 }}
{{- end }}
securityContext:
runAsUser: 65534
volumeMounts:
{{- range .Values.prometheusRuleConfigMapMounts }}
{{- range .Values.ruleConfigMapMounts }}
- name: {{ .name }}
mountPath: /etc/prometheus/{{ .subPath }}
subPath: {{ .subPath }}
Expand All @@ -260,7 +269,7 @@ spec:
{{ end -}}
serviceAccountName: linkerd-prometheus
volumes:
{{- range .Values.prometheusRuleConfigMapMounts }}
{{- range .Values.ruleConfigMapMounts }}
- name: {{ .name }}
configMap:
name: {{ .configMap }}
Expand Down
10 changes: 10 additions & 0 deletions charts/add-ons/prometheus/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
image: prom/prometheus:v2.15.2
args:
storage.tsdb.path: /data
storage.tsdb.retention.time: 6h
config.file: /etc/prometheus/prometheus.yml
log.level: info
globalConfig:
scrape_interval: 10s
scrape_timeout: 10s
evaluation_interval: 10s
27 changes: 22 additions & 5 deletions charts/linkerd2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ their default values.
| `identity.issuer.tls.keyPEM` | Key for the issuer certificate (ECDSA). It must be provided during install. | |
| `installNamespace` | Set to false when installing Linkerd in a custom namespace. See the [Linkerd documentation](https://linkerd.io/2/tasks/install-helm/#customizing-the-namespace) for more information. | `true` |
| `omitWebhookSideEffects` | Omit the `sideEffects` flag in the webhook manifests | `false` |
| `prometheusAlertmanagers` | Alertmanager instances the Prometheus server sends alerts to configured via the static_configs parameter. | `[]` |
| `prometheusExtraArgs` | Extra command line options for Prometheus | `{}` |
| `prometheusImage` | Docker image for the Prometheus container | `prom/prometheus:v2.15.2` |
| `prometheusLogLevel` | Log level for Prometheus | `info` |
| `prometheusRuleConfigMapMounts` | Alerting/recording rule ConfigMap mounts (sub-path names must end in `_rules.yml` or `_rules.yaml`) | `[]` |
| `proxyInjector.externalSecret` | Do not create a secret resource for the profileValidator webhook. If this is set to `true`, the value `proxyInjector.caBundle` must be set (see below). | false |
| `proxyInjector.crtPEM` | Certificate for the proxy injector. If not provided then Helm will generate one. | |
| `proxyInjector.keyPEM` | Certificate key for the proxy injector. If not provided then Helm will generate one. | |
Expand Down Expand Up @@ -191,6 +186,28 @@ The following table lists the configurable parameters for the Grafana Add-On.
| `grafana.resources.memory.limit` | Maximum amount of memory that grafana container can use ||
| `grafana.resources.memory.request` | Amount of memory that the grafana container requests ||

### Prometheus Add-On

The following table lists the configurable parameters for the Prometheus Add-On.

| Parameter | Description | Default |
|:--------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------|
| `prometheus.enabled` | Flag to enable prometheus instance to be installed | `true` |
| `prometheus.alert_relabel_configs` | Alert relabeling is applied to alerts before they are sent to the Alertmanager. | `[]` |
| `prometheus.alertManagers` | Alertmanager instances the Prometheus server sends alerts to configured via the static_configs parameter. | `[]` |
| `prometheus.args` | Command line options for Prometheus binary | `storage.tsdb.path: /data, storage.tsdb.retention.time: 6h, config.file: /etc/prometheus/prometheus.yml, log.level: *controller_log_level` |
| `prometheus.globalConfig` | The global configuration specifies parameters that are valid in all other configuration contexts. | `scrape_interval: 10s, scrape_timeout: 10s, evaluation_interval: 10s` |
| `prometheus.image` | Docker image for the prometheus instance | `prom/prometheus:v2.15.2` |
| `prometheus.resources.cpu.limit` | Maximum amount of CPU units that the prometheus container can use ||
| `prometheus.resources.cpu.request` | Amount of CPU units that the prometheus container requests ||
| `prometheus.resources.memory.limit` | Maximum amount of memory that prometheus container can use ||
| `prometheus.resources.memory.request` | Amount of memory that the prometheus container requests ||
| `prometheus.ruleConfigMapMounts` | Alerting/recording rule ConfigMap mounts (sub-path names must end in `_rules.yml` or `_rules.yaml`) | `[]` |
| `prometheus.scrapeConfigs` | A scrape_config section specifies a set of targets and parameters describing how to scrape them. | `[]` |

Most of the above configuration match directly with the official Prometheus
configuration which can be found [here](https://prometheus.io/docs/prometheus/latest/configuration/configuration)

### Tracing Add-On

The following table lists the configurable parameters for the Tracing Add-On.
Expand Down
7 changes: 5 additions & 2 deletions charts/linkerd2/requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ dependencies:
- name: partials
repository: file://../partials
version: 0.1.0
- name: prometheus
repository: file://../add-ons/prometheus
version: 0.1.0
- name: grafana
repository: file://../add-ons/grafana
version: 0.1.0
- name: tracing
repository: file://../add-ons/tracing
version: 0.1.0
digest: sha256:f92907b6d243e3b57b4288603ba76eced7c2f4ef913e76505c314971bb4afa21
generated: "2020-05-11T14:13:54.306010536-05:00"
digest: sha256:d2428770ae7d5134c5af6521c78a4c5f95da4c75f21bdea0f74fad6ab6e2e044
generated: "2020-06-24T11:07:53.924602129Z"
4 changes: 4 additions & 0 deletions charts/linkerd2/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ dependencies:
- name: partials
version: 0.1.0
repository: file://../partials
- name: prometheus
version: 0.1.0
repository: file://../add-ons/prometheus
condition: prometheus.enabled
Pothulapati marked this conversation as resolved.
Show resolved Hide resolved
- name: grafana
version: 0.1.0
repository: file://../add-ons/grafana
Expand Down
2 changes: 1 addition & 1 deletion charts/linkerd2/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
- -prometheus-url=http://linkerd-prometheus.{{.Values.global.namespace}}.svc.{{.Values.global.clusterDomain}}:9090
- -destination-addr=linkerd-dst.{{.Values.global.namespace}}.svc.{{.Values.global.clusterDomain}}:8086
- -controller-namespace={{.Values.global.namespace}}
- -log-level={{.Values.controllerLogLevel}}
- -log-level={{.Values.global.controllerLogLevel}}
{{- include "partials.linkerd.trace" . | nindent 8 -}}
image: {{.Values.controllerImage}}:{{default .Values.global.linkerdVersion .Values.global.controllerImageVersion}}
imagePullPolicy: {{.Values.global.imagePullPolicy}}
Expand Down
2 changes: 1 addition & 1 deletion charts/linkerd2/templates/destination.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
- -addr=:8086
- -controller-namespace={{.Values.global.namespace}}
- -enable-h2-upgrade={{.Values.enableH2Upgrade}}
- -log-level={{.Values.controllerLogLevel}}
- -log-level={{.Values.global.controllerLogLevel}}
{{- include "partials.linkerd.trace" . | nindent 8 -}}
image: {{.Values.controllerImage}}:{{default .Values.global.linkerdVersion .Values.global.controllerImageVersion}}
imagePullPolicy: {{.Values.global.imagePullPolicy}}
Expand Down
2 changes: 1 addition & 1 deletion charts/linkerd2/templates/heartbeat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
- "heartbeat"
- "-prometheus-url=http://linkerd-prometheus.{{.Values.global.namespace}}.svc.{{.Values.global.clusterDomain}}:9090"
- "-controller-namespace={{.Values.global.namespace}}"
- "-log-level={{.Values.controllerLogLevel}}"
- "-log-level={{.Values.global.controllerLogLevel}}"
{{- if .Values.heartbeatResources -}}
{{- include "partials.resources" .Values.heartbeatResources | nindent 12 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/linkerd2/templates/identity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ spec:
containers:
- args:
- identity
- -log-level={{.Values.controllerLogLevel}}
- -log-level={{.Values.global.controllerLogLevel}}
{{- include "partials.linkerd.trace" . | nindent 8 -}}
image: {{.Values.controllerImage}}:{{default .Values.global.linkerdVersion .Values.global.controllerImageVersion}}
imagePullPolicy: {{.Values.global.imagePullPolicy}}
Expand Down
2 changes: 2 additions & 0 deletions charts/linkerd2/templates/linkerd-config-addons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ data:
grafanaUrl: "{{.Values.global.grafanaUrl}}"
grafana:
{{- include "linkerd.addons.sanitize-config" .Values.grafana}}
prometheus:
{{- include "linkerd.addons.sanitize-config" .Values.prometheus}}
tracing:
{{- include "linkerd.addons.sanitize-config" .Values.tracing}}
2 changes: 1 addition & 1 deletion charts/linkerd2/templates/proxy-injector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec:
containers:
- args:
- proxy-injector
- -log-level={{.Values.controllerLogLevel}}
- -log-level={{.Values.global.controllerLogLevel}}
image: {{.Values.controllerImage}}:{{default .Values.global.linkerdVersion .Values.global.controllerImageVersion}}
imagePullPolicy: {{.Values.global.imagePullPolicy}}
livenessProbe:
Expand Down
2 changes: 1 addition & 1 deletion charts/linkerd2/templates/sp-validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spec:
containers:
- args:
- sp-validator
- -log-level={{.Values.controllerLogLevel}}
- -log-level={{.Values.global.controllerLogLevel}}
image: {{.Values.controllerImage}}:{{default .Values.global.linkerdVersion .Values.global.controllerImageVersion}}
imagePullPolicy: {{.Values.global.imagePullPolicy}}
livenessProbe:
Expand Down
2 changes: 1 addition & 1 deletion charts/linkerd2/templates/tap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ spec:
- args:
- tap
- -controller-namespace={{.Values.global.namespace}}
- -log-level={{.Values.controllerLogLevel}}
- -log-level={{.Values.global.controllerLogLevel}}
{{- include "partials.linkerd.trace" . | nindent 8 -}}
image: {{.Values.controllerImage}}:{{default .Values.global.linkerdVersion .Values.global.controllerImageVersion}}
imagePullPolicy: {{.Values.global.imagePullPolicy}}
Expand Down
2 changes: 1 addition & 1 deletion charts/linkerd2/templates/web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
- -jaeger-addr={{.Values.tracing.jaeger.name}}.{{.Values.global.namespace}}.svc.{{.Values.global.clusterDomain}}:16686
{{- end}}
- -controller-namespace={{.Values.global.namespace}}
- -log-level={{.Values.controllerLogLevel}}
- -log-level={{.Values.global.controllerLogLevel}}
{{- if .Values.enforcedHostRegexp }}
- -enforced-host={{.Values.enforcedHostRegexp}}
{{- else -}}
Expand Down
15 changes: 8 additions & 7 deletions charts/linkerd2/values-ha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ grafana:
heartbeatResources: *controller_resources

# prometheus configuration
prometheusResources:
cpu:
limit: "4"
request: 300m
memory:
limit: 8192Mi
request: 300Mi
prometheus:
resources:
cpu:
limit: "4"
request: 300m
memory:
limit: 8192Mi
request: 300Mi

# proxy injector configuration
proxyInjectorResources: *controller_resources
Expand Down
Loading