From 79ed927f3cbe10a3373e5efbf3b2aaa785c7aecf Mon Sep 17 00:00:00 2001 From: timpel301 <117385556+timpel301@users.noreply.github.com> Date: Fri, 6 Oct 2023 15:24:09 +0200 Subject: [PATCH] =?UTF-8?q?feat(v3-operator):=20Add=20option=20to=20set=20?= =?UTF-8?q?remote=20signer=20url=20in=20configmap=20a=E2=80=A6=20(#457)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(v3-operator): Add option to set remote signer url in configmap as well as enabling metrics and writing custom prometheusrules * chore(v3-operator): Update Chart version --- charts/v3-operator/Chart.yaml | 2 +- charts/v3-operator/templates/configmap.yaml | 5 ++ .../templates/prometheusrules.yaml | 22 +++++++++ charts/v3-operator/templates/service.yaml | 6 +++ charts/v3-operator/templates/statefulset.yaml | 5 ++ charts/v3-operator/values.yaml | 48 +++++++++++++++++++ 6 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 charts/v3-operator/templates/prometheusrules.yaml diff --git a/charts/v3-operator/Chart.yaml b/charts/v3-operator/Chart.yaml index b11479746..428f1c4c8 100644 --- a/charts/v3-operator/Chart.yaml +++ b/charts/v3-operator/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: v3-operator -version: 3.1.2 +version: 3.2.2 appVersion: master kubeVersion: "^1.20.0-0" description: Operator hosted service for Stakewise V3 protocol. diff --git a/charts/v3-operator/templates/configmap.yaml b/charts/v3-operator/templates/configmap.yaml index bd59dfb99..04fd0cefd 100644 --- a/charts/v3-operator/templates/configmap.yaml +++ b/charts/v3-operator/templates/configmap.yaml @@ -14,5 +14,10 @@ data: HARVEST_VAULT: {{ .Values.settings.harvestVault | quote }} EXECUTION_ENDPOINTS: {{ .Values.settings.executionEndpoints | quote }} CONSENSUS_ENDPOINTS: {{ .Values.settings.consensusEndpoints | quote }} + ENABLE_METRICS: {{ .Values.metrics.enabled | quote }} METRICS_HOST: {{ .Values.serviceMonitor.host | quote }} + METRICS_PORT: {{ .Values.metrics.port | quote }} MAX_FEE_PER_GAS_GWEI: {{ .Values.settings.maxFeePerGasGwei | quote }} + {{- if .Values.settings.remoteSigner.enabled }} + REMOTE_SIGNER_URL: {{ .Values.settings.remoteSigner.url | quote }} + {{- end }} diff --git a/charts/v3-operator/templates/prometheusrules.yaml b/charts/v3-operator/templates/prometheusrules.yaml new file mode 100644 index 000000000..590834ac7 --- /dev/null +++ b/charts/v3-operator/templates/prometheusrules.yaml @@ -0,0 +1,22 @@ +{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ template "common.names.fullname" . }} + {{- if .Values.metrics.prometheusRule.namespace }} + namespace: {{ .Values.metrics.prometheusRule.namespace }} + {{- else }} + namespace: {{ .Release.Namespace | quote }} + {{- end }} + labels: + {{- include "common.labels.standard" . | nindent 4 }} + {{- if .Values.metrics.prometheusRule.additionalLabels }} + {{- toYaml .Values.metrics.prometheusRule.additionalLabels | nindent 4 }} + {{- end }} +spec: + groups: + {{- with .Values.metrics.prometheusRule.rules }} + - name: {{ template "vommon.fullname" $ }} + rules: {{- tpl (toYaml .) $ | nindent 8 }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/v3-operator/templates/service.yaml b/charts/v3-operator/templates/service.yaml index 0a2c48f47..298c3effc 100644 --- a/charts/v3-operator/templates/service.yaml +++ b/charts/v3-operator/templates/service.yaml @@ -11,5 +11,11 @@ spec: targetPort: http protocol: TCP name: http + {{- if .Values.metrics.enabled }} + - port: {{ .Values.metrics.port }} + targetPort: metrics + protocol: TCP + name: metrics + {{- end }} selector: {{- include "common.labels.matchLabels" . | nindent 4 }} diff --git a/charts/v3-operator/templates/statefulset.yaml b/charts/v3-operator/templates/statefulset.yaml index 66f6266c3..cf4bf4696 100644 --- a/charts/v3-operator/templates/statefulset.yaml +++ b/charts/v3-operator/templates/statefulset.yaml @@ -74,6 +74,11 @@ spec: - name: http containerPort: {{ .Values.service.ports.http }} protocol: TCP + {{- if .Values.metrics.enabled }} + - name: metrics + containerPort: {{ .Values.metrics.port }} + protocol: TCP + {{- end }} volumeMounts: - name: deposit-data mountPath: /data/{{ .Values.settings.vault }}/deposit diff --git a/charts/v3-operator/values.yaml b/charts/v3-operator/values.yaml index aba09ac97..27bcf88f4 100644 --- a/charts/v3-operator/values.yaml +++ b/charts/v3-operator/values.yaml @@ -96,6 +96,10 @@ settings: executionEndpoints: "" # Comma separated list of endpoints for the consensus node consensusEndpoints: "" + # endpoint of the remote signer + remoteSigner: + enabled: false + url: "" depositDataSecretName: "" keystoresSecretName: "" @@ -116,6 +120,50 @@ persistence: - ReadWriteOnce size: 1Gi +## Monitoring +## +metrics: + # Whether to enable metrics collection or not + enabled: false + # Prometheus exporter port + port: 9090 + ## Custom PrometheusRule to be defined + ## ref: https://github.com/coreos/prometheus-operator#customresourcedefinitions + ## + prometheusRule: + ## @param metrics.prometheusRule.enabled Create a custom prometheusRule Resource for scraping metrics using PrometheusOperator + ## + enabled: false + ## @param metrics.prometheusRule.default Create a default set of Alerts + ## + default: false + ## @param metrics.prometheusRule.namespace The namespace in which the prometheusRule will be created + ## + namespace: "" + ## @param metrics.prometheusRule.additionalLabels Additional labels for the prometheusRule + ## + additionalLabels: {} + ## @param metrics.prometheusRule.rules Custom Prometheus rules + ## e.g: + ## rules: + ## - alert: PrysmValidatorHourlyEarningLessOrEqual0 + ## expr: sum(validator_balance) - sum(validator_balance offset 1h) - count(validator_balance > 16)*32 + count(validator_balance offset 1h > 0)*32 + ## for: 5m + ## labels: + ## severity: critical + ## annotations: + ## summary: Prysm validator hourly earning <= 0 + ## description: Check validators immediately. Pod - {{ printf "{{ $labels.pod }}" }}. Namespace - {{ printf "{{ $labels.namespace }}" }} + ## - alert: PrysmValidatorAlotOfErrorsLastHour + ## expr: sum(delta(log_entries_total{job='{{ include "operator.fullname" . }}-validator', level="error"}[1h]) > 0) + ## for: 5m + ## labels: + ## severity: warning + ## annotations: + ## summary: Many validator errors or warnings last hour + ## description: Check validator {{ printf "{{ $labels.pod }}" }}. Namespace - {{ printf "{{ $labels.namespace }}" }} + ## + rules: {} ## Prometheus Service Monitor ## ref: https://github.com/coreos/prometheus-operator ## https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint