Skip to content

Commit 7112657

Browse files
authored
Merge pull request #4 from EamonZhang/main
feat(drycc-addons):add prometheus
2 parents 24e5df6 + b35e4ce commit 7112657

35 files changed

Lines changed: 5277 additions & 11 deletions

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/statefulset.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ spec:
172172
mountPath: /opt/drycc/mysql/conf
173173

174174
ports:
175-
- name: router
175+
- name: routerrw
176176
containerPort: 6446
177+
- name: routerro
178+
containerPort: 6447
177179
{{- if not .Values.diagnosticMode.enabled }}
178180
{{- if .Values.router.customLivenessProbe }}
179181
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.router.customLivenessProbe "context" $) | nindent 12 }}

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/svc.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,19 @@ spec:
4141
loadBalancerIP: {{ .Values.router.service.loadBalancerIP }}
4242
{{- end }}
4343
ports:
44-
- name: router
45-
port: {{ .Values.router.service.ports.router }}
44+
- name: routerrw
45+
port: {{ .Values.router.service.portrw }}
4646
protocol: TCP
47-
targetPort: router
47+
targetPort: routerrw
48+
{{- if (and (or (eq .Values.router.service.type "NodePort") (eq .Values.router.service.type "LoadBalancer")) .Values.router.service.nodePorts.mysql) }}
49+
nodePort: {{ .Values.router.service.nodePorts.mysql }}
50+
{{- else if eq .Values.router.service.type "ClusterIP" }}
51+
nodePort: null
52+
{{- end }}
53+
- name: routerro
54+
port: {{ .Values.router.service.portro}}
55+
protocol: TCP
56+
targetPort: routerro
4857
{{- if (and (or (eq .Values.router.service.type "NodePort") (eq .Values.router.service.type "LoadBalancer")) .Values.router.service.nodePorts.mysql) }}
4958
nodePort: {{ .Values.router.service.nodePorts.mysql }}
5059
{{- else if eq .Values.router.service.type "ClusterIP" }}

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/secrets.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ SPDX-License-Identifier: APACHE-2.0
44
*/}}
55

66
{{- $host := include "mysql.router.fullname" . }}
7-
{{- $port := print .Values.router.service.ports.router }}
7+
{{- $portrw := print .Values.router.service.portrw }}
8+
{{- $port := print .Values.router.service.portrw }}
9+
{{- $portro := print .Values.router.service.portro }}
810
{{- $rootPassword := include "common.secrets.passwords.manage" (dict "secret" (include "mysql.secretName" .) "key" "mysql-root-password" "length" 10 "providedValues" (list "auth.rootPassword") "context" $) | trimAll "\"" | b64dec }}
911
{{- $password := include "common.secrets.passwords.manage" (dict "secret" (include "mysql.secretName" .) "key" "mysql-password" "length" 10 "providedValues" (list "auth.password") "context" $) | trimAll "\"" | b64dec }}
1012
{{- if eq (include "mysql.createSecret" .) "true" }}
@@ -72,7 +74,8 @@ data:
7274
provider: {{ print "drycc" | b64enc | quote }}
7375
type: {{ print "mysql" | b64enc | quote }}
7476
host: {{ print $host | b64enc | quote }}
75-
port: {{ print $port | b64enc | quote }}
77+
portrw: {{ print $portrw | b64enc | quote }}
78+
portro: {{ print $portro | b64enc | quote }}
7679
username: {{ print .Values.auth.username | b64enc | quote }}
7780
{{- if $database }}
7881
database: {{ print $database | b64enc | quote }}

addons/mysql-cluster/8.0/chart/mysql-cluster/values.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ primary:
214214
configuration: |-
215215
[mysqld]
216216
# server
217-
#default_authentication_plugin=mysql_native_password
217+
max_connections=500
218218
default_authentication_plugin=caching_sha2_password
219219
skip-name-resolve
220220
relay-log=relay-log
@@ -857,8 +857,8 @@ router:
857857
type: LoadBalancer
858858
## @param secondary.service.ports.mysql MySQL secondary Kubernetes service port
859859
##
860-
ports:
861-
router: 6446
860+
portrw: 3306
861+
portro: 3307
862862
## @param secondary.service.nodePorts.mysql MySQL secondary Kubernetes service node port
863863
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
864864
##
@@ -1012,8 +1012,8 @@ volumePermissions:
10121012
##
10131013
image:
10141014
registry: registry.drycc.cc
1015-
repository: drycc/os-shell
1016-
tag: debian-12
1015+
repository: drycc/base
1016+
tag: bookworm
10171017
digest: ""
10181018
pullPolicy: IfNotPresent
10191019
## Optionally specify an array of imagePullSecrets.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright VMware, Inc.
2+
# SPDX-License-Identifier: APACHE-2.0
3+
4+
annotations:
5+
category: Analytics
6+
licenses: Apache-2.0
7+
apiVersion: v2
8+
appVersion: 2.47.0
9+
dependencies:
10+
- name: common
11+
repository: oci://registry.drycc.cc/charts
12+
tags:
13+
- drycc-common
14+
version: ~1.1.2
15+
description: Prometheus is an open source monitoring and alerting system. It enables sysadmins to monitor their infrastructures by collecting metrics from configured targets at given intervals.
16+
home: https://github.com/prometheus/prometheus
17+
icon: https://drycc.com/assets/stacks/prometheus/img/prometheus-stack-220x234.png
18+
keywords:
19+
- prometheus
20+
- monitoring
21+
maintainers:
22+
- name: Drycc
23+
url: https://github.com/drycc/charts
24+
name: prometheus
25+
sources:
26+
- https://github.com/drycc/containers/tree/main/drycc/prometheus
27+
- https://github.com/prometheus/prometheus
28+
- https://github.com/prometheus-community/helm-charts
29+
version: 0.2.3
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
CHART NAME: {{ .Chart.Name }}
2+
CHART VERSION: {{ .Chart.Version }}
3+
APP VERSION: {{ .Chart.AppVersion }}
4+
5+
** Please be patient while the chart is being deployed **
6+
7+
{{- if .Values.diagnosticMode.enabled }}
8+
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
9+
10+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
11+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
12+
13+
Get the list of pods by executing:
14+
15+
kubectl get pods --namespace {{ include "common.names.namespace" . | quote }} -l app.kubernetes.io/instance={{ .Release.Name }}
16+
17+
Access the pod you want to debug by executing
18+
19+
kubectl exec --namespace {{ include "common.names.namespace" . | quote }} -ti <NAME OF THE POD> -- bash
20+
21+
In order to replicate the container startup scripts execute this command:
22+
23+
/opt/drycc/prometheus/bin/prometheus --config.file=/opt/drycc/prometheus/conf/prometheus.yml --storage.tsdb.path=/opt/drycc/prometheus/data --web.console.libraries=/opt/drycc/prometheus/conf/console_libraries --web.console.templates=/opt/drycc/prometheus/conf/consoles
24+
25+
{{- else }}
26+
27+
Prometheus can be accessed via port "{{ .Values.server.service.ports.http }}" on the following DNS name from within your cluster:
28+
29+
{{ template "common.names.fullname" . }}.{{ include "common.names.namespace" . }}.svc.cluster.local
30+
31+
To access Prometheus from outside the cluster execute the following commands:
32+
33+
{{- if .Values.server.ingress.enabled }}
34+
35+
You should be able to access your new Prometheus installation through
36+
37+
{{ ternary "https" "http" .Values.server.ingress.tls }}://{{ .Values.server.ingress.hostname }}
38+
39+
{{- else if contains "LoadBalancer" .Values.server.service.type }}
40+
41+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
42+
Watch the status with: 'kubectl get svc --namespace {{ include "common.names.namespace" . }} -w {{ template "common.names.fullname" . }}'
43+
44+
{{- $port:=.Values.server.service.ports.http | toString }}
45+
46+
export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.names.namespace" . }} {{ template "common.names.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
47+
echo "Prometheus URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.server.service.ports.http }}{{ end }}/"
48+
49+
{{- else if contains "ClusterIP" .Values.server.service.type }}
50+
51+
echo "Prometheus URL: http://127.0.0.1:9090/"
52+
kubectl port-forward --namespace {{ include "common.names.namespace" . }} svc/{{ template "common.names.fullname" . }} 9090:{{ .Values.server.service.ports.http }}
53+
54+
{{- else if contains "NodePort" .Values.server.service.type }}
55+
56+
export NODE_PORT=$(kubectl get --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "common.names.fullname" . }})
57+
export NODE_IP=$(kubectl get nodes --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
58+
echo "Prometheus URL: http://$NODE_IP:$NODE_PORT/"
59+
60+
{{- end }}
61+
62+
{{- if and .Values.server.thanos.create }}
63+
64+
Thanos Sidecar can be accessed via port "{{ .Values.server.thanos.service.ports.grpc }}" on the following DNS name from within your cluster:
65+
66+
{{ template "prometheus.thanos-sidecar.fullname" . }}.{{ include "common.names.namespace" . }}.svc.cluster.local
67+
68+
{{- if .Values.server.thanos.ingress.enabled }}
69+
70+
You should be able to access your new Thanos Sidecar installation through
71+
72+
{{ ternary "https" "http" .Values.server.thanos.ingress.tls }}://{{ .Values.server.thanos.ingress.hostname }}
73+
74+
{{- end }}
75+
{{- end }}
76+
{{- end }}
77+
78+
{{- if .Values.alertmanager.enabled }}
79+
80+
Watch the Alertmanager StatefulSet status using the command:
81+
82+
kubectl get sts -w --namespace {{ include "common.names.namespace" . }} -l app.kubernetes.io/name={{ template "prometheus.alertmanager.fullname" . }},app.kubernetes.io/instance={{ .Release.Name }}
83+
84+
Alertmanager can be accessed via port "{{ .Values.alertmanager.service.ports.http }}" on the following DNS name from within your cluster:
85+
86+
{{ template "prometheus.alertmanager.fullname" . }}.{{ include "common.names.namespace" . }}.svc.cluster.local
87+
88+
To access Alertmanager from outside the cluster execute the following commands:
89+
90+
{{- if .Values.alertmanager.ingress.enabled }}
91+
92+
You should be able to access your new Prometheus installation through
93+
94+
{{ ternary "https" "http" .Values.alertmanager.ingress.tls }}://{{ .Values.alertmanager.ingress.hostname }}
95+
96+
{{- else if contains "LoadBalancer" .Values.alertmanager.service.type }}
97+
98+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
99+
Watch the status with: 'kubectl get svc --namespace {{ include "common.names.namespace" . }} -w {{ template "prometheus.alertmanager.fullname" . }}'
100+
101+
{{- $port:=.Values.alertmanager.service.ports.http | toString }}
102+
103+
export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.names.namespace" . }} {{ template "prometheus.alertmanager.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
104+
echo "Alertmanager URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.alertmanager.service.ports.http }}{{ end }}/"
105+
106+
{{- else if contains "ClusterIP" .Values.alertmanager.service.type }}
107+
108+
echo "Alertmanager URL: http://127.0.0.1:9093/"
109+
kubectl port-forward --namespace {{ include "common.names.namespace" . }} svc/{{ template "prometheus.alertmanager.fullname" . }} 9093:{{ .Values.alertmanager.service.ports.http }}
110+
111+
{{- else if contains "NodePort" .Values.alertmanager.service.type }}
112+
113+
export NODE_PORT=$(kubectl get --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "prometheus.alertmanager.fullname" . }})
114+
export NODE_IP=$(kubectl get nodes --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
115+
echo "Alertmanager URL: http://$NODE_IP:$NODE_PORT/"
116+
117+
{{- end }}
118+
{{- end }}
119+
120+
{{- include "common.warnings.rollingTag" .Values.server.image }}
121+
{{- include "common.warnings.rollingTag" .Values.server.thanos.image }}
122+
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
123+
{{- include "prometheus.server.validateValues" . }}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{{/*
2+
Copyright VMware, Inc.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
6+
{{/*
7+
Return the proper image name
8+
*/}}
9+
{{- define "prometheus.server.image" -}}
10+
{{ include "common.images.image" (dict "imageRoot" .Values.server.image "global" .Values.global) }}
11+
{{- end -}}
12+
13+
{{/*
14+
Return the proper image name
15+
*/}}
16+
{{- define "prometheus.alertmanager.image" -}}
17+
{{ include "common.images.image" (dict "imageRoot" .Values.alertmanager.image "global" .Values.global) }}
18+
{{- end -}}
19+
20+
{{/*
21+
Return the proper image name
22+
*/}}
23+
{{- define "prometheus.server.thanosImage" -}}
24+
{{ include "common.images.image" (dict "imageRoot" .Values.server.thanos.image "global" .Values.global) }}
25+
{{- end -}}
26+
27+
{{/*
28+
Return Prometheus server name
29+
*/}}
30+
{{- define "prometheus.server.fullname" -}}
31+
{{- printf "%s-server" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
32+
{{- end -}}
33+
34+
{{/*
35+
Return Prometheus server name
36+
*/}}
37+
{{- define "prometheus.server.fullname.namespace" -}}
38+
{{- printf "%s-server" (include "common.names.fullname.namespace" .) | trunc 63 | trimSuffix "-" }}
39+
{{- end -}}
40+
41+
{{/*
42+
Return the proper image name (for the init container volume-permissions image)
43+
*/}}
44+
{{- define "prometheus.volumePermissions.image" -}}
45+
{{- include "common.images.image" ( dict "imageRoot" .Values.volumePermissions.image "global" .Values.global ) -}}
46+
{{- end -}}
47+
48+
{{/*
49+
Return the proper Docker Image Registry Secret Names
50+
*/}}
51+
{{- define "prometheus.imagePullSecrets" -}}
52+
{{- include "common.images.pullSecrets" (dict "images" (list .Values.server.image .Values.volumePermissions.image .Values.server.thanos.image .Values.alertmanager.image) "global" .Values.global) -}}
53+
{{- end -}}
54+
55+
{{/*
56+
Create the name of the service account to use
57+
*/}}
58+
{{- define "prometheus.server.serviceAccountName" -}}
59+
{{- if .Values.server.serviceAccount.create -}}
60+
{{ default (include "prometheus.server.fullname" .) .Values.server.serviceAccount.name }}
61+
{{- else -}}
62+
{{ default "default" .Values.server.serviceAccount.name }}
63+
{{- end -}}
64+
{{- end -}}
65+
66+
{{/*
67+
Compile all warnings into a single message.
68+
*/}}
69+
{{- define "prometheus.server.validateValues" -}}
70+
{{- $messages := list -}}
71+
{{- $messages := append $messages (include "prometheus.server.validateValues.thanosObjectStorageConfig" .) -}}
72+
{{- $messages := without $messages "" -}}
73+
{{- $message := join "\n" $messages -}}
74+
75+
{{- if $message -}}
76+
{{- printf "\nVALUES VALIDATION:\n%s" $message -}}
77+
{{- end -}}
78+
{{- end -}}
79+
80+
{{/*
81+
Validate thanos objectStorageConfig.
82+
*/}}
83+
{{- define "prometheus.server.validateValues.thanosObjectStorageConfig" -}}
84+
{{- if (and .Values.server.thanos.objectStorageConfig (or (not (hasKey .Values.server.thanos.objectStorageConfig "secretKey")) (not (hasKey .Values.server.thanos.objectStorageConfig "secretName")) ))}}
85+
{{- printf "'server.thanos.objectStorageConfig.secretKey' and 'server.thanos.objectStorageConfi.secretName' are mandatory" }}
86+
{{- end }}
87+
{{- end }}
88+
89+
{{/*
90+
Get the Prometheus configuration configmap.
91+
*/}}
92+
{{- define "prometheus.server.configmapName" -}}
93+
{{- if .Values.server.existingConfigmap -}}
94+
{{- include "common.tplvalues.render" (dict "value" .Values.server.existingConfigmap "context" .) -}}
95+
{{- else }}
96+
{{- include "prometheus.server.fullname" . -}}
97+
{{- end -}}
98+
{{- end -}}
99+
100+
{{/*
101+
Get the Prometheus configuration configmap key.
102+
*/}}
103+
{{- define "prometheus.server.configmapKey" -}}
104+
{{- if .Values.server.existingConfigmapKey -}}
105+
{{- include "common.tplvalues.render" (dict "value" .Values.server.existingConfigmapKey "context" .) -}}
106+
{{- else }}
107+
{{- printf "prometheus.yaml" -}}
108+
{{- end -}}
109+
{{- end -}}
110+
111+
{{/*
112+
Get the Prometheus Alertmanager configuration configmap key.
113+
*/}}
114+
{{- define "prometheus.alertmanager.configmapKey" -}}
115+
{{- if .Values.alertmanager.existingConfigmapKey -}}
116+
{{- include "common.tplvalues.render" (dict "value" .Values.alertmanager.existingConfigmapKey "context" .) -}}
117+
{{- else }}
118+
{{- printf "alertmanager.yaml" -}}
119+
{{- end -}}
120+
{{- end -}}
121+
122+
{{/*
123+
Create the name of the service account to use in alertmanager
124+
*/}}
125+
{{- define "prometheus.alertmanager.serviceAccountName" -}}
126+
{{- if .Values.alertmanager.serviceAccount.create -}}
127+
{{ default (include "prometheus.alertmanager.fullname" .) .Values.alertmanager.serviceAccount.name }}
128+
{{- else -}}
129+
{{ default "default" .Values.alertmanager.serviceAccount.name }}
130+
{{- end -}}
131+
{{- end -}}
132+
133+
{{/*
134+
Return Thanos sidecar service/ingress name
135+
*/}}
136+
{{- define "prometheus.thanos-sidecar.fullname" -}}
137+
{{- printf "%s-thanos" (include "common.names.fullname" .) }}
138+
{{- end -}}
139+
140+
{{/*
141+
Return Alertmanager name
142+
*/}}
143+
{{- define "prometheus.alertmanager.fullname" -}}
144+
{{- printf "%s-alertmanager" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
145+
{{- end -}}
146+
147+
{{/*
148+
Get the Alertmanager configuration configmap.
149+
*/}}
150+
{{- define "prometheus.alertmanager.configmapName" -}}
151+
{{- if .Values.alertmanager.existingConfigmap -}}
152+
{{- include "common.tplvalues.render" (dict "value" .Values.alertmanager.existingConfigmap "context" .) -}}
153+
{{- else }}
154+
{{- include "prometheus.alertmanager.fullname" . -}}
155+
{{- end -}}
156+
{{- end -}}

0 commit comments

Comments
 (0)