Skip to content

Commit

Permalink
cosigned: add scripts to expose metrics to prometheus (#15)
Browse files Browse the repository at this point in the history
* chore: add service monitor

Signed-off-by: hectorj2f <[email protected]>

* chore: bump chart version

Signed-off-by: hectorj2f <[email protected]>
  • Loading branch information
hectorj2f authored Oct 3, 2021
1 parent 04b343a commit 6d3305c
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/cosigned/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sources:
- https://github.com/sigstore/cosign
name: cosigned
type: application
version: v0.0.3-dev
version: v0.0.4
appVersion: v1.2.0
maintainers:
- name: dlorenc
Expand Down
14 changes: 14 additions & 0 deletions charts/cosigned/templates/webhook/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,17 @@ data:
# Changes are be picked up immediately.
loglevel.controller: "info"
loglevel.webhook: "info"
{{- if .Values.serviceMonitor.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
labels:
{{- include "cosigned.labels" . | nindent 4 }}
control-plane: {{ template "cosigned.fullname" . }}-webhook
name: {{ template "cosigned.fullname" . }}-webhook-observability
namespace: {{ .Release.Namespace }}
data:
metrics.backend-destination: prometheus
metrics.request-metrics-backend-destination: prometheus
{{- end }}
2 changes: 2 additions & 0 deletions charts/cosigned/templates/webhook/deployment_webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
fieldPath: metadata.namespace
- name: CONFIG_LOGGING_NAME
value: {{ template "cosigned.fullname" . }}-webhook-logging
- name: CONFIG_OBSERVABILITY_NAME
value: {{ template "cosigned.fullname" . }}-webhook-observability
- name: METRICS_DOMAIN
value: sigstore.dev/cosigned
- name: WEBHOOK_NAME
Expand Down
17 changes: 17 additions & 0 deletions charts/cosigned/templates/webhook/service_monitor_webhook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cosigned.fullname" . }}-webhook-monitor
namespace: {{ .Release.Namespace }}
labels:
{{- include "cosigned.labels" . | nindent 4 }}
control-plane: {{ template "cosigned.fullname" . }}-webhook
spec:
endpoints:
- path: /metrics
port: metrics
selector:
matchLabels:
control-plane: {{ template "cosigned.fullname" . }}-webhook
{{- end }}
23 changes: 23 additions & 0 deletions charts/cosigned/templates/webhook/service_webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,26 @@ spec:
selector:
{{- include "cosigned.selectorLabels" . | nindent 4 }}
control-plane: {{ template "cosigned.fullname" . }}-webhook
---
apiVersion: v1
kind: Service
metadata:
annotations:
{{- if .Values.webhook.service.annotations }}
{{ toYaml .Values.webhook.service.annotations | nindent 4 }}
{{- end }}
labels:
{{- include "cosigned.labels" . | nindent 4 }}
control-plane: {{ template "cosigned.fullname" . }}-webhook
name: {{ template "cosigned.fullname" . }}-webhook-metrics
namespace: {{ .Release.Namespace }}
spec:
type: ClusterIP
ports:
- name: metrics
port: 9090
protocol: TCP
targetPort: metrics
selector:
{{- include "cosigned.selectorLabels" . | nindent 4 }}
control-plane: {{ template "cosigned.fullname" . }}-webhook
4 changes: 4 additions & 0 deletions charts/cosigned/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ commonTolerations: []
# operator: "Equal"
# value: "value"
# effect: "NoSchedule"

## serviceMonitor makes cosigned metrics discoverable to prometheus
serviceMonitor:
enabled: false

0 comments on commit 6d3305c

Please sign in to comment.