Skip to content

Commit a385696

Browse files
authored
Merge pull request #544 from wallrj/VC-34401-prometheus-metrics
[VC-34401] Add metrics settings to the Helm chart
2 parents 11df52b + de31f01 commit a385696

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ go run main.go echo
4646
The Jetstack-Secure agent exposes its metrics through a Prometheus server, on port 8081.
4747
The Prometheus server is disabled by default but can be enabled by passing the `--enable-metrics` flag to the agent binary.
4848

49+
If you deploy the agent with Helm, using the venafi-kubernetes-agent Helm chart, the metrics server will be enabled by default, on port 8081.
50+
If you use the Prometheus Operator, you can use `--set metrics.podmonitor.enabled=true` to deploy a `PodMonitor` resource,
51+
which will add the venafi-kubernetes-agent metrics to your Prometheus server.
52+
53+
The following metrics are collected:
54+
* Go collector: via the [default registry](https://github.com/prometheus/client_golang/blob/34e02e282dc4a3cb55ca6441b489ec182e654d59/prometheus/registry.go#L60-L63) in Prometheus client_golang.
55+
* Process collector: via the [default registry](https://github.com/prometheus/client_golang/blob/34e02e282dc4a3cb55ca6441b489ec182e654d59/prometheus/registry.go#L60-L63) in Prometheus client_golang.
56+
* Agent metrics:
57+
* `data_readings_upload_size`: Data readings upload size (in bytes) sent by the jscp in-cluster agent.
58+
4959
## Release Process
5060

5161
The release process is semi-automated.

deploy/charts/venafi-kubernetes-agent/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ You should see the following events for your service account:
159159
| image.repository | string | `"registry.venafi.cloud/venafi-agent/venafi-agent"` | Default to Open Source image repository |
160160
| image.tag | string | `"v0.1.48"` | Overrides the image tag whose default is the chart appVersion |
161161
| imagePullSecrets | list | `[]` | Specify image pull credentials if using a private registry example: - name: my-pull-secret |
162+
| metrics.enabled | bool | `true` | Enable the metrics server. If false, the metrics server will be disabled and the other metrics fields below will be ignored. |
163+
| metrics.podmonitor.annotations | object | `{}` | Additional annotations to add to the PodMonitor. |
164+
| metrics.podmonitor.enabled | bool | `false` | Create a PodMonitor to add the metrics to Prometheus, if you are using Prometheus Operator. See https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.PodMonitor |
165+
| metrics.podmonitor.endpointAdditionalProperties | object | `{}` | EndpointAdditionalProperties allows setting additional properties on the endpoint such as relabelings, metricRelabelings etc. For example: endpointAdditionalProperties: relabelings: - action: replace sourceLabels: - __meta_kubernetes_pod_node_name targetLabel: instance |
166+
| metrics.podmonitor.honorLabels | bool | `false` | Keep labels from scraped data, overriding server-side labels. |
167+
| metrics.podmonitor.interval | string | `"60s"` | The interval to scrape metrics. |
168+
| metrics.podmonitor.labels | object | `{}` | Additional labels to add to the PodMonitor. |
169+
| metrics.podmonitor.prometheusInstance | string | `"default"` | Specifies the `prometheus` label on the created PodMonitor. This is used when different Prometheus instances have label selectors matching different PodMonitors. |
170+
| metrics.podmonitor.scrapeTimeout | string | `"30s"` | The timeout before a metrics scrape fails. |
162171
| nameOverride | string | `""` | Helm default setting to override release name, usually leave blank. |
163172
| nodeSelector | object | `{}` | Embed YAML for nodeSelector settings, see https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/ |
164173
| podAnnotations | object | `{}` | Additional YAML annotations to add the the pod. |
@@ -172,4 +181,6 @@ You should see the following events for your service account:
172181
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
173182
| serviceAccount.name | string | `""` | The name of the service account to use. If blank and `serviceAccount.create` is true, a name is generated using the fullname template of the release. |
174183
| tolerations | list | `[]` | Embed YAML for toleration settings, see https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ |
184+
| volumeMounts | list | `[]` | Additional volume mounts to add to the Venafi Kubernetes Agent container. This is useful for mounting a custom CA bundle. Any PEM certificate mounted under /etc/ssl/certs will be loaded by the Venafi Kubernetes Agent. For example: volumeMounts: - name: cabundle mountPath: /etc/ssl/certs/cabundle subPath: cabundle readOnly: true |
185+
| volumes | list | `[]` | Additional volumes to add to the Venafi Kubernetes Agent container. This is useful for mounting a custom CA bundle. For example: volumes: - name: cabundle configMap: name: cabundle optional: false defaultMode: 0644 In order to create the ConfigMap, you can use the following command: kubectl create configmap cabundle \ --from-file=cabundle=./your/custom/ca/bundle.pem |
175186

deploy/charts/venafi-kubernetes-agent/templates/deployment.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ spec:
6262
- "-p"
6363
- "0h1m0s"
6464
- --venafi-cloud
65+
{{- if .Values.metrics.enabled }}
66+
- --enable-metrics
67+
{{- end }}
6568
{{- range .Values.extraArgs }}
6669
- {{ . | quote }}
6770
{{- end }}
@@ -77,6 +80,11 @@ spec:
7780
{{- with .Values.volumeMounts }}
7881
{{- toYaml . | nindent 12 }}
7982
{{- end }}
83+
{{- if .Values.metrics.enabled }}
84+
ports:
85+
- containerPort: 8081
86+
name: http-metrics
87+
{{- end }}
8088
{{- with .Values.nodeSelector }}
8189
nodeSelector:
8290
{{- toYaml . | nindent 8 }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{- if and .Values.metrics.enabled .Values.metrics.podmonitor.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: PodMonitor
4+
metadata:
5+
name: {{ include "venafi-kubernetes-agent.fullname" . }}
6+
{{- if .Values.metrics.podmonitor.namespace }}
7+
namespace: {{ .Values.metrics.podmonitor.namespace }}
8+
{{- else }}
9+
namespace: {{ .Release.Namespace | quote }}
10+
{{- end }}
11+
labels:
12+
{{- include "venafi-kubernetes-agent.labels" . | nindent 4 }}
13+
prometheus: {{ .Values.metrics.podmonitor.prometheusInstance }}
14+
{{- with .Values.metrics.podmonitor.labels }}
15+
{{- toYaml . | nindent 4 }}
16+
{{- end }}
17+
{{- with .Values.metrics.podmonitor.annotations }}
18+
annotations:
19+
{{- toYaml . | nindent 4 }}
20+
{{- end }}
21+
spec:
22+
jobLabel: {{ include "venafi-kubernetes-agent.fullname" . }}
23+
selector:
24+
matchLabels:
25+
{{- include "venafi-kubernetes-agent.selectorLabels" . | nindent 6 }}
26+
{{- if .Values.metrics.podmonitor.namespace }}
27+
namespaceSelector:
28+
matchNames:
29+
- {{ .Release.Namespace | quote }}
30+
{{- end }}
31+
podMetricsEndpoints:
32+
- port: http-metrics
33+
path: /metrics
34+
interval: {{ .Values.metrics.podmonitor.interval }}
35+
scrapeTimeout: {{ .Values.metrics.podmonitor.scrapeTimeout }}
36+
honorLabels: {{ .Values.metrics.podmonitor.honorLabels }}
37+
{{- with .Values.metrics.podmonitor.endpointAdditionalProperties }}
38+
{{- toYaml . | nindent 4 }}
39+
{{- end }}
40+
{{- end }}

deploy/charts/venafi-kubernetes-agent/values.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,52 @@
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
44

5+
metrics:
6+
# -- Enable the metrics server.
7+
# If false, the metrics server will be disabled and the other metrics fields below will be ignored.
8+
enabled: true
9+
podmonitor:
10+
# -- Create a PodMonitor to add the metrics to Prometheus, if you are using Prometheus Operator.
11+
# See https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.PodMonitor
12+
enabled: false
13+
14+
# -- The namespace that the pod monitor should live in.
15+
# Defaults to the venafi-kubernetes-agent namespace.
16+
# +docs:property
17+
# namespace: venafi
18+
19+
# -- Specifies the `prometheus` label on the created PodMonitor.
20+
# This is used when different Prometheus instances have label selectors
21+
# matching different PodMonitors.
22+
prometheusInstance: default
23+
24+
# -- The interval to scrape metrics.
25+
interval: 60s
26+
27+
# -- The timeout before a metrics scrape fails.
28+
scrapeTimeout: 30s
29+
30+
# -- Additional labels to add to the PodMonitor.
31+
labels: {}
32+
33+
# -- Additional annotations to add to the PodMonitor.
34+
annotations: {}
35+
36+
# -- Keep labels from scraped data, overriding server-side labels.
37+
honorLabels: false
38+
39+
# -- EndpointAdditionalProperties allows setting additional properties on the endpoint such as relabelings, metricRelabelings etc.
40+
#
41+
# For example:
42+
# endpointAdditionalProperties:
43+
# relabelings:
44+
# - action: replace
45+
# sourceLabels:
46+
# - __meta_kubernetes_pod_node_name
47+
# targetLabel: instance
48+
#
49+
endpointAdditionalProperties: {}
50+
551
# -- default replicas, do not scale up
652
replicaCount: 1
753

0 commit comments

Comments
 (0)