Skip to content

Commit

Permalink
feat: expose kratos-courier metrics by default (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
Demonsthere authored May 15, 2024
1 parent 5e3b1c7 commit 3cc807b
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 13 deletions.
6 changes: 0 additions & 6 deletions hacks/values/kratos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ deployment:
environmentSecretsName: env-secrets

statefulSet:
extraArgs:
- --expose-metrics-port
- "8080"
extraEnv:
- name: DSN
valueFrom:
Expand Down Expand Up @@ -361,6 +358,3 @@ test:
busybox:
repository: docker.io/library/busybox
tag: 1.36
service:
admin:
metricsPath: "/admin/metrics/different-prometheus-path"
8 changes: 8 additions & 0 deletions helm/charts/kratos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ A ORY Kratos Helm chart for Kubernetes
| service.admin.nodePort | string | `""` | |
| service.admin.port | int | `80` | |
| service.admin.type | string | `"ClusterIP"` | |
| service.courier.annotations | object | `{}` | Provide custom annotations. |
| service.courier.containerPort | int | `4434` | Container Port |
| service.courier.enabled | bool | `true` | |
| service.courier.labels | object | `{}` | Provide custom labels. Use the same syntax as for annotations. |
| service.courier.metricsPath | string | `"/metrics/prometheus"` | Path to the metrics endpoint |
| service.courier.name | string | `"http-metrics"` | The service port name. Useful to set a custom service port name if it must follow a scheme (e.g. Istio) |
| service.courier.port | int | `80` | Service Port |
| service.courier.type | string | `"ClusterIP"` | |
| service.public.annotations | object | `{}` | If you do want to specify annotations, uncomment the following lines, adjust them as necessary, and remove the curly braces after 'annotations:'. |
| service.public.enabled | bool | `true` | |
| service.public.labels | object | `{}` | Provide custom labels. Use the same syntax as for annotations. |
Expand Down
2 changes: 1 addition & 1 deletion helm/charts/kratos/templates/service-public.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
app.kubernetes.io/component: public
{{ include "kratos.labels" . | indent 4 }}
{{- include "kratos.labels" . | nindent 4 }}
{{- with .Values.service.public.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
8 changes: 8 additions & 0 deletions helm/charts/kratos/templates/statefulset-mail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ metadata:
namespace: {{ .Release.Namespace }}
{{- end }}
labels:
app.kubernetes.io/component: courier
{{- include "kratos.labels" . | nindent 4 }}
{{- with $labels }}
{{- toYaml . | nindent 4 }}
Expand All @@ -38,6 +39,7 @@ spec:
labels:
app.kubernetes.io/name: {{ include "kratos.fullname" . }}-courier
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: courier
{{- with $labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand All @@ -62,6 +64,8 @@ spec:
- watch
- --config
- /etc/config/kratos.yaml
- --expose-metrics-port
- {{ .Values.service.courier.containerPort | quote }}
{{- if .Values.statefulSet.extraArgs }}
{{- toYaml .Values.statefulSet.extraArgs | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -125,6 +129,10 @@ spec:
- secretRef:
name: {{ $environmentSecretsName }}
{{- end}}
ports:
- name: http-metrics
containerPort: {{ .Values.service.courier.containerPort }}
protocol: TCP
resources:
{{- toYaml $resources | nindent 12 }}
{{- if .Values.securityContext }}
Expand Down
58 changes: 52 additions & 6 deletions helm/charts/kratos/templates/statefulset-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,68 @@ metadata:
{{- end }}
labels:
app.kubernetes.io/component: courier
{{ include "kratos.labels" . | indent 4 }}
{{- with .Values.deployment.labels }}
{{- include "kratos.labels" . | nindent 4 }}
{{- with .Values.statefulSet.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.service.courier.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- with .Values.deployment.annotations }}
{{- with .Values.statefulSet.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.service.courier.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.courier.type }}
clusterIP: None
ports:
- port: {{ .Values.service.public.port }}
targetPort: http-public
- port: {{ .Values.service.courier.port }}
targetPort: http-metrics
protocol: TCP
name: http
name: {{ .Values.service.courier.name }}
selector:
app.kubernetes.io/name: {{ include "kratos.fullname" . }}-courier
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.serviceMonitor.enabled }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "kratos.fullname" . }}-courier
{{- if .Release.Namespace }}
namespace: {{ .Release.Namespace }}
{{- end }}
labels:
app.kubernetes.io/component: courier
{{- include "kratos.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.statefulSet.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.statefulSet.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- path: {{ .Values.service.courier.metricsPath }}
port: {{ .Values.service.courier.name }}
scheme: {{ .Values.serviceMonitor.scheme }}
interval: {{ .Values.serviceMonitor.scrapeInterval }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- with .Values.serviceMonitor.tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 6 }}
{{- end }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "kratos.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: courier
{{- end -}}
{{- end }}
15 changes: 15 additions & 0 deletions helm/charts/kratos/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ service:
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
courier:
enabled: true
type: ClusterIP
# -- Service Port
port: 80
# -- Container Port
containerPort: 4434
# -- The service port name. Useful to set a custom service port name if it must follow a scheme (e.g. Istio)
name: http-metrics
# -- Provide custom labels. Use the same syntax as for annotations.
labels: {}
# -- Provide custom annotations.
annotations: {}
# -- Path to the metrics endpoint
metricsPath: /metrics/prometheus

## -- Secret management
secret:
Expand Down

0 comments on commit 3cc807b

Please sign in to comment.