diff --git a/hacks/values/kratos.yaml b/hacks/values/kratos.yaml index 15d811f0e..8c275dbc2 100644 --- a/hacks/values/kratos.yaml +++ b/hacks/values/kratos.yaml @@ -263,9 +263,6 @@ deployment: environmentSecretsName: env-secrets statefulSet: - extraArgs: - - --expose-metrics-port - - "8080" extraEnv: - name: DSN valueFrom: @@ -361,6 +358,3 @@ test: busybox: repository: docker.io/library/busybox tag: 1.36 -service: - admin: - metricsPath: "/admin/metrics/different-prometheus-path" diff --git a/helm/charts/kratos/README.md b/helm/charts/kratos/README.md index 5f156fd85..1bb115e5a 100644 --- a/helm/charts/kratos/README.md +++ b/helm/charts/kratos/README.md @@ -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. | diff --git a/helm/charts/kratos/templates/service-public.yaml b/helm/charts/kratos/templates/service-public.yaml index 26abb5d84..6e2d2b073 100644 --- a/helm/charts/kratos/templates/service-public.yaml +++ b/helm/charts/kratos/templates/service-public.yaml @@ -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 }} diff --git a/helm/charts/kratos/templates/statefulset-mail.yaml b/helm/charts/kratos/templates/statefulset-mail.yaml index b62c5e749..10ca85c92 100644 --- a/helm/charts/kratos/templates/statefulset-mail.yaml +++ b/helm/charts/kratos/templates/statefulset-mail.yaml @@ -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 }} @@ -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 }} @@ -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 }} @@ -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 }} diff --git a/helm/charts/kratos/templates/statefulset-svc.yaml b/helm/charts/kratos/templates/statefulset-svc.yaml index 58de6c69a..2dd4d108c 100644 --- a/helm/charts/kratos/templates/statefulset-svc.yaml +++ b/helm/charts/kratos/templates/statefulset-svc.yaml @@ -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 }} diff --git a/helm/charts/kratos/values.yaml b/helm/charts/kratos/values.yaml index 0f6347cc2..8ae576fc3 100644 --- a/helm/charts/kratos/values.yaml +++ b/helm/charts/kratos/values.yaml @@ -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: