Skip to content

Commit

Permalink
Merge pull request #516 from rstudio/new-prometheus
Browse files Browse the repository at this point in the history
enable the new prometheus endpoint for Connect
  • Loading branch information
colearendt authored May 24, 2024
2 parents 9f9d77c + c43be78 commit 6a36868
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 18 deletions.
2 changes: 1 addition & 1 deletion charts/rstudio-connect/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: rstudio-connect
description: Official Helm chart for Posit Connect
version: 0.6.7
version: 0.7.0
apiVersion: v2
appVersion: 2024.04.1
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
Expand Down
9 changes: 9 additions & 0 deletions charts/rstudio-connect/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.7.0

- BREAKING: the prometheus endpoint has changed from port `9108` to `3232` by default
- We are now using an internal prometheus endpoint with all new metrics
- As a result, the `graphiteExporter` sidecar has been removed
- Some metrics from the `graphiteExporter` will no longer be present
- The parent / main "off-switch" for prometheus is at `prometheus.enabled`
- To revert to the old exporter, set `prometheus.legacy=true` (and please reach out to let us know why!)

## 0.6.7

- Documentation site updates
Expand Down
11 changes: 7 additions & 4 deletions charts/rstudio-connect/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Posit Connect

![Version: 0.6.7](https://img.shields.io/badge/Version-0.6.7-informational?style=flat-square) ![AppVersion: 2024.04.1](https://img.shields.io/badge/AppVersion-2024.04.1-informational?style=flat-square)
![Version: 0.7.0](https://img.shields.io/badge/Version-0.7.0-informational?style=flat-square) ![AppVersion: 2024.04.1](https://img.shields.io/badge/AppVersion-2024.04.1-informational?style=flat-square)

#### _Official Helm chart for Posit Connect_

Expand Down Expand Up @@ -30,11 +30,11 @@ To ensure reproducibility in your environment and insulate yourself from future

## Installing the chart

To install the chart with the release name `my-release` at version 0.6.7:
To install the chart with the release name `my-release` at version 0.7.0:

```{.bash}
helm repo add rstudio https://helm.rstudio.com
helm upgrade --install my-release rstudio/rstudio-connect --version=0.6.7
helm upgrade --install my-release rstudio/rstudio-connect --version=0.7.0
```

To explore other chart versions, look at:
Expand Down Expand Up @@ -166,7 +166,10 @@ The Helm `config` values are converted into the `rstudio-connect.gcfg` service c
| pod.volumes | list | `[]` | An array of maps that is injected as-is into the "volumes:" component of the pod spec |
| podDisruptionBudget | object | `{}` | Pod disruption budget |
| priorityClassName | string | `""` | The pod's priorityClassName |
| prometheusExporter.enabled | bool | `true` | Whether the prometheus exporter sidecar should be enabled |
| prometheus.enabled | bool | `true` | The parent setting for whether to enable prometheus metrics. Default is to use the built-in product exporter |
| prometheus.legacy | bool | `false` | Whether to enable the legacy prometheusExporter INSTEAD OF the built-in product exporter. If you change this to `true`, please let us know why! Requires prometheusExporter.enabled=true too |
| prometheus.port | int | `3232` | The port that prometheus will listen on. If legacy=true, then this will be hard-coded to 9108 |
| prometheusExporter.enabled | bool | `true` | DEPRECATED. Whether the prometheus exporter sidecar should be enabled. See prometheus.enabled instead. |
| prometheusExporter.image.imagePullPolicy | string | `"IfNotPresent"` | |
| prometheusExporter.image.repository | string | `"prom/graphite-exporter"` | |
| prometheusExporter.image.tag | string | `"v0.9.0"` | |
Expand Down
6 changes: 6 additions & 0 deletions charts/rstudio-connect/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ Please consider removing this configuration value.
{{- fail "\n\n`pod.nodeSelector` is no longer used. Use `nodeSelector` instead!\nThis is more consistent with other charts and the community." }}

{{- end }}

{{- if and (hasKey .Values.config.Metrics "GraphiteEnabled") (not .Values.prometheus.legacy) }}

{{- print "\n\n`config.Metrics.GraphiteEnabled` is overwritten by `prometheus.legacy=false`. Internal Connect Prometheus will be used instead." }}

{{- end }}
22 changes: 21 additions & 1 deletion charts/rstudio-connect/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ app.kubernetes.io/instance: {{ .Release.Name }}
- set launcher parameters if applicable
*/}}
{{- define "rstudio-connect.config" -}}
{{- $configCopy := deepCopy .Values.config }}
{{- $defaultConfig := dict }}
{{- /* default launcher configuration */}}
{{- if .Values.launcher.enabled }}
Expand All @@ -80,7 +81,26 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- $licenseDict := dict "Licensing" ( dict "LicenseType" ("Remote") ) }}
{{- $defaultConfig = merge $defaultConfig $licenseDict }}
{{- end }}
{{- include "rstudio-library.config.gcfg" ( mergeOverwrite $defaultConfig .Values.config ) }}
{{- /* default metrics / prometheus configuration */}}
{{- if .Values.prometheus.enabled }}
{{- if .Values.prometheus.legacy }}
{{- /* we set the graphite values as a default, to hide from values.yaml */ -}}
{{- $graphiteDict := dict "Metrics" (dict "Enabled" true "GraphiteClientId" "rsconnect" "GraphiteEnabled" true) }}
{{- $graphiteDict = merge $graphiteDict (dict "Metrics" (dict "GraphiteHost" "127.0.0.1" "GraphitePort" "9109")) }}
{{- $defaultConfig = merge $defaultConfig $graphiteDict }}
{{- else }}
{{- if hasKey $configCopy "Metrics" }}
{{- if hasKey (get $configCopy "Metrics") "GraphiteEnabled" }}
{{- /* we explicitly overwrite the graphite endpoint */ -}}
{{- mergeOverwrite $configCopy (dict "Metrics" (dict "GraphiteEnabled" false))}}
{{- end }}
{{- end }}

{{- /* and set a default for the prometheus listener */ -}}
{{- $defaultConfig = merge $defaultConfig (dict "Metrics" ( dict "PrometheusListen" (print ":" .Values.prometheus.port )))}}
{{- end }}
{{- end }}
{{- include "rstudio-library.config.gcfg" ( mergeOverwrite $defaultConfig $configCopy ) }}
{{- end -}}

{{/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.prometheusExporter.enabled }}
{{- if and .Values.prometheus.legacy .Values.prometheusExporter.enabled }}
---
apiVersion: v1
kind: ConfigMap
Expand Down
17 changes: 14 additions & 3 deletions charts/rstudio-connect/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ spec:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- if and .Values.prometheus.legacy .Values.prometheusExporter.enabled }}
checksum/config-graphite: {{ include (print $.Template.BasePath "/configmap-graphite-exporter.yaml") . | sha256sum }}
{{- end }}
{{- if .Values.launcher.enabled }}
checksum/config-prestart: {{ include (print $.Template.BasePath "/configmap-prestart.yaml") . | sha256sum }}
{{- end }}
{{- if .Values.prometheusExporter.enabled }}
{{- if .Values.prometheus }}
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
{{- if and .Values.prometheus.legacy .Values.prometheusExporter.enabled }}
prometheus.io/port: "9108"
{{- else }}
prometheus.io/port: {{ .Values.prometheus.port | quote }}
{{- end }}
{{- end }}
{{ include "rstudio-connect.pod.annotations" . | indent 8 }}
labels:
Expand Down Expand Up @@ -118,6 +124,11 @@ spec:
imagePullPolicy: "{{ .Values.image.imagePullPolicy }}"
ports:
- containerPort: {{ .Values.pod.port }}
name: http
{{- if and .Values.prometheus.enabled (not .Values.prometheus.legacy) }}
- containerPort: {{ .Values.prometheus.port }}
name: metrics
{{- end}}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
Expand Down Expand Up @@ -187,7 +198,7 @@ spec:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
{{- if .Values.prometheusExporter.enabled }}
{{- if and .Values.prometheus.legacy .Values.prometheusExporter.enabled }}
- name: exporter
image: "{{ .Values.prometheusExporter.image.repository }}:{{ .Values.prometheusExporter.image.tag }}"
imagePullPolicy: "{{ .Values.prometheusExporter.image.imagePullPolicy }}"
Expand Down Expand Up @@ -220,7 +231,7 @@ spec:
claimName: {{default (print (include "rstudio-connect.fullname" .) "-shared-storage" ) .Values.sharedStorage.name }}
{{- end }}
{{ include "rstudio-library.license-volume" (dict "license" ( .Values.license ) "fullName" (include "rstudio-connect.fullname" .)) | indent 6 }}
{{- if .Values.prometheusExporter.enabled }}
{{- if and .Values.prometheus.legacy .Values.prometheusExporter.enabled }}
- name: graphite-exporter-config
configMap:
name: {{ include "rstudio-connect.fullname" . }}-graphite
Expand Down
2 changes: 1 addition & 1 deletion charts/rstudio-connect/templates/service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.prometheusExporter.enabled .Values.serviceMonitor.enabled -}}
{{- if and .Values.prometheus.enabled .Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Expand Down
9 changes: 7 additions & 2 deletions charts/rstudio-connect/templates/svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
{{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- end }}
selector:
{{- include "rstudio-connect.selectorLabels" . | nindent 4 }}
ports:
Expand All @@ -28,8 +28,13 @@ spec:
nodePort: {{ .Values.service.nodePort }}
{{- end }}
targetPort: {{ .Values.service.targetPort }}
{{- if .Values.prometheusExporter.enabled }}
{{- if .Values.prometheus.enabled }}
- name: metrics
targetPort: metrics
{{- if .Values.prometheus.legacy }}
port: 9108
{{- else }}
port: {{ .Values.prometheus.port }}
{{- end }}
{{- end }}
---
15 changes: 10 additions & 5 deletions charts/rstudio-connect/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,17 @@ license:
securityContext:
privileged: true

prometheus:
# -- The parent setting for whether to enable prometheus metrics. Default is to use the built-in product exporter
enabled: true
# -- The port that prometheus will listen on. If legacy=true, then this will be hard-coded to 9108
port: 3232
# -- Whether to enable the legacy prometheusExporter INSTEAD OF the built-in product exporter. If you change this to
# `true`, please let us know why! Requires prometheusExporter.enabled=true too
legacy: false

prometheusExporter:
# -- Whether the prometheus exporter sidecar should be enabled
# -- DEPRECATED. Whether the prometheus exporter sidecar should be enabled. See prometheus.enabled instead.
enabled: true
# -- Yaml that defines the graphite exporter mapping. null by default, which uses the embedded / default mapping yaml file
mappingYaml: null
Expand Down Expand Up @@ -357,7 +366,3 @@ config:
AccessLogFormat: COMMON # COMMON, COMBINED, or JSON
Metrics:
Enabled: true
GraphiteEnabled: true
GraphiteHost: 127.0.0.1
GraphitePort: 9109
GraphiteClientId: rsconnect

0 comments on commit 6a36868

Please sign in to comment.