Skip to content

Commit

Permalink
feat: update apollo chart.
Browse files Browse the repository at this point in the history
  • Loading branch information
dellnoantechnp committed Jul 15, 2024
1 parent a4f58ff commit 96e97bf
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 13 deletions.
2 changes: 1 addition & 1 deletion charts/apollo/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ maintainers:
name: apollo
type: application
kubeVersion: ">=1.18.0"
version: 0.8.6
version: 0.8.7
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
Expand Down
29 changes: 29 additions & 0 deletions charts/apollo/templates/admin-service/prometheusrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if and .Values.adminService.serviceMonitor.enabled .Values.adminService.prometheusRule.enabled .Values.adminService.prometheusRule.rules }}
{{- with .Values.adminService }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "apollo.adminService.fullName" $ }}
{{- if .prometheusRule.namespace }}
namespace: {{ .prometheusRule.namespace }}
{{- else }}
namespace: {{ $.Release.Namespace }}
{{- end }}
labels: {{- include "common.labels.standard" $ | nindent 4 }}
app.kubernetes.io/component: adminService
{{- if $.Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .prometheusRule.additionalLabels }}
{{- include "common.tplvalues.render" ( dict "value" .prometheusRule.additionalLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if $.Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
groups:
- name: {{ include "apollo.adminService.fullName" $ }}
rules: {{- toYaml .prometheusRule.rules | nindent 8 }}
{{- end }}
{{- end }}

Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ spec:
if mysql --defaults-file=/tmp/.my.cnf -E --connect-timeout=30 -w -e 'SHOW TABLES FROM {{ .Values.db.configdb.dbName }}' | grep -q : ; then
echo "INFO: {{ .Values.db.configdb.dbName }} was exists. skipping to initial SQL table."
else
#if [[ $? -eq 1 ]]; then
echo "INFO: {{ .Values.db.configdb.dbName }} is not exists. creating and init SQL file ..."
echo "INFO: CREATE DATABASE"
mysql --defaults-file=/tmp/.my.cnf -E --connect-timeout=30 -w -e 'CREATE DATABASE "{{ .Values.db.configdb.dbName }}" DEFAULT CHARSET utf8mb4'
echo "INFO: CREATE TABLES"
echo "INFO: Creating TABLES ..."
mysql --defaults-file=/tmp/.my.cnf -E --connect-timeout=30 -w {{ .Values.db.configdb.dbName }} < /docker-entrypoint-initdb.d/init-database.sql
fi
echo "INFO: starting app container ..."
Expand Down
29 changes: 29 additions & 0 deletions charts/apollo/templates/config-service/prometheusrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if and .Values.configService.serviceMonitor.enabled .Values.configService.prometheusRule.enabled .Values.configService.prometheusRule.rules }}
{{- with .Values.configService }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "apollo.configService.fullName" $ }}
{{- if .prometheusRule.namespace }}
namespace: {{ .prometheusRule.namespace }}
{{- else }}
namespace: {{ $.Release.Namespace }}
{{- end }}
labels: {{- include "common.labels.standard" $ | nindent 4 }}
app.kubernetes.io/component: configService
{{- if $.Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .prometheusRule.additionalLabels }}
{{- include "common.tplvalues.render" ( dict "value" .prometheusRule.additionalLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if $.Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
groups:
- name: {{ include "apollo.configService.fullName" $ }}
rules: {{- toYaml .prometheusRule.rules | nindent 8 }}
{{- end }}
{{- end }}

5 changes: 1 addition & 4 deletions charts/apollo/templates/portal/deployment-portal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ spec:
if mysql --defaults-file=/tmp/.my.cnf -E --connect-timeout=30 -w -e 'SHOW TABLES FROM {{ .Values.db.portaldb.dbName }}' | grep -q : ; then
echo "INFO: {{ .Values.db.portaldb.dbName }} was exists. skipping to initial SQL table."
else
#if [[ $? -eq 1 ]]; then
echo "INFO: {{ .Values.db.portaldb.dbName }} is not exists. creating and init SQL file ..."
echo "INFO: CREATE DATABASE"
mysql --defaults-file=/tmp/.my.cnf -E --connect-timeout=30 -w -e 'CREATE DATABASE "{{ .Values.db.portaldb.dbName }}" DEFAULT CHARSET utf8mb4'
echo "INFO: CREATE TABLES"
echo "INFO: Creating TABLES ..."
mysql --defaults-file=/tmp/.my.cnf -E --connect-timeout=30 -w {{ .Values.db.portaldb.dbName }} < /docker-entrypoint-initdb.d/init-database.sql
fi
echo "INFO: starting app container ..."
Expand Down
29 changes: 29 additions & 0 deletions charts/apollo/templates/portal/prometheusrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if and .Values.portal.serviceMonitor.enabled .Values.portal.prometheusRule.enabled .Values.portal.prometheusRule.rules }}
{{- with .Values.portal }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "apollo.portal.fullName" $ }}
{{- if .prometheusRule.namespace }}
namespace: {{ .prometheusRule.namespace }}
{{- else }}
namespace: {{ $.Release.Namespace }}
{{- end }}
labels: {{- include "common.labels.standard" $ | nindent 4 }}
app.kubernetes.io/component: apollo-portal
{{- if $.Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .prometheusRule.additionalLabels }}
{{- include "common.tplvalues.render" ( dict "value" .prometheusRule.additionalLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if $.Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
groups:
- name: {{ include "apollo.portal.fullName" $ }}
rules: {{- toYaml .prometheusRule.rules | nindent 8 }}
{{- end }}
{{- end }}

105 changes: 101 additions & 4 deletions charts/apollo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,43 @@ configService:
relabelings: [ ]
## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion
##
metricRelabelings: [ ]
metricRelabelings:
- action: replace
sourceLabels:
- __meta_kubernetes_pod_label_app.kubernetes.io_component
separator: ";"
replacement: ".*"
targetLabel: component
## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint
##
honorLabels: false
## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.
##
jobLabel: ""

## Prometheus Operator PrometheusRule configuration
##
prometheusRule:
## @param metrics.prometheusRule.enabled Create a PrometheusRule for Prometheus Operator
##
enabled: false
## @param metrics.prometheusRule.namespace Namespace for the PrometheusRule Resource (defaults to the Release Namespace)
##
namespace: ""
## @param metrics.prometheusRule.additionalLabels Additional labels that can be used so PrometheusRule will be discovered by Prometheus
##
additionalLabels: { }
## @param metrics.prometheusRule.rules PrometheusRule definitions
## - alert: RequestExceptionTooMany
## annotations:
## subject: Apollo adminService too many exceptions on http request.
## message: The metric http_server_requests_seconds_count has too many code 5xx exception, firing exception is {{ $labels.exception }} to {{ $labels.uri }}.
## expr: sum(increase(http_server_requests_seconds_count{component="configService", status="500"}[5m])) by (exception, uri) > 10
## for: 5m
## labels:
## severity: warning


adminService:
name: apollo-adminservice
fullNameOverride: ""
Expand Down Expand Up @@ -269,14 +298,53 @@ adminService:
relabelings: [ ]
## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion
##
metricRelabelings: [ ]
metricRelabelings:
- action: replace
sourceLabels:
- __meta_kubernetes_pod_label_app.kubernetes.io_component
separator: ";"
replacement: ".*"
targetLabel: component
## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint
##
honorLabels: false
## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.
##
jobLabel: ""

## Prometheus Operator PrometheusRule configuration
##
prometheusRule:
## @param metrics.prometheusRule.enabled Create a PrometheusRule for Prometheus Operator
##
enabled: false
## @param metrics.prometheusRule.namespace Namespace for the PrometheusRule Resource (defaults to the Release Namespace)
##
namespace: ""
## @param metrics.prometheusRule.additionalLabels Additional labels that can be used so PrometheusRule will be discovered by Prometheus
##
additionalLabels: { }
## @param metrics.prometheusRule.rules PrometheusRule definitions
## - alert: RequestExceptionTooMany
## annotations:
## subject: Apollo adminService too many exceptions on http request.
## message: The metric http_server_requests_seconds_count has too many code 5xx exception, firing exception is {{ $labels.exception }} to {{ $labels.uri }}.
## expr: sum(increase(http_server_requests_seconds_count{component="adminService", status="500"}[5m])) by (exception, uri) > 10
## for: 5m
## labels:
## severity: warning
##
rules:
- alert: RequestExceptionTooMany
annotations:
subject: Apollo adminService too many exceptions on http request.
message: The metric http_server_requests_seconds_count has too many code 5xx exception, firing exception is {{ $labels.exception }} to {{ $labels.uri }}.
expr: sum(increase(http_server_requests_seconds_count{component="adminService", status="500"}[5m])) by (exception, uri) > 10
for: 5m
labels:
severity: warning


portal:
## @param enabled: boolean value for install portal web-ui.
##
Expand Down Expand Up @@ -375,10 +443,39 @@ portal:
relabelings: [ ]
## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion
##
metricRelabelings: [ ]
metricRelabelings:
- action: replace
sourceLabels:
- __meta_kubernetes_pod_label_app.kubernetes.io_component
separator: ";"
replacement: ".*"
targetLabel: component
## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint
##
honorLabels: false
## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.
##
jobLabel: ""
jobLabel: ""

## Prometheus Operator PrometheusRule configuration
##
prometheusRule:
## @param metrics.prometheusRule.enabled Create a PrometheusRule for Prometheus Operator
##
enabled: false
## @param metrics.prometheusRule.namespace Namespace for the PrometheusRule Resource (defaults to the Release Namespace)
##
namespace: ""
## @param metrics.prometheusRule.additionalLabels Additional labels that can be used so PrometheusRule will be discovered by Prometheus
##
additionalLabels: { }
## @param metrics.prometheusRule.rules PrometheusRule definitions
## - alert: RequestExceptionTooMany
## annotations:
## subject: Apollo adminService too many exceptions on http request.
## message: The metric http_server_requests_seconds_count has too many code 5xx exception, firing exception is {{ $labels.exception }} to {{ $labels.uri }}.
## expr: sum(increase(http_server_requests_seconds_count{component="apollo-portal", status="500"}[5m])) by (exception, uri) > 10
## for: 5m
## labels:
## severity: warning
##

0 comments on commit 96e97bf

Please sign in to comment.