From 9d14ba73b40b299c0d15c26ba7314bf1a15e8ff6 Mon Sep 17 00:00:00 2001 From: lyy <2424809934@qq.com> Date: Fri, 29 Sep 2023 11:01:37 +0800 Subject: [PATCH] Add deployment of Prometheus with Grafana for K8s --- installer/k8s/README.md | 38 +++++- .../templates/core/backend-deployment.yaml | 2 + .../core/extensions-all-iiot-deployment.yaml | 2 + .../monitor/grafana/grafana-deployment.yml | 69 +++++++++++ .../templates/monitor/grafana/grafana-pv.yml | 30 +++++ .../templates/monitor/grafana/grafana-pvc.yml | 30 +++++ .../monitor/grafana/grafana-service.yml | 22 ++-- .../prometheus/prometheus-configmap.yaml | 49 ++++++++ .../prometheus/prometheus-deployment.yml | 108 ++++++++++++++++++ .../monitor/prometheus/prometheus-pv.yml | 30 +++++ .../monitor/prometheus/prometheus-pvc.yml | 30 +++++ .../monitor/prometheus/prometheus-service.yml | 30 +++++ .../monitor/prometheus/token-pvc.yml | 28 +++++ installer/k8s/values.yaml | 38 +++++- 14 files changed, 496 insertions(+), 10 deletions(-) create mode 100644 installer/k8s/templates/monitor/grafana/grafana-deployment.yml create mode 100644 installer/k8s/templates/monitor/grafana/grafana-pv.yml create mode 100644 installer/k8s/templates/monitor/grafana/grafana-pvc.yml rename streampipes-extensions/streampipes-extensions-all-jvm/Dockerfile => installer/k8s/templates/monitor/grafana/grafana-service.yml (68%) create mode 100644 installer/k8s/templates/monitor/prometheus/prometheus-configmap.yaml create mode 100644 installer/k8s/templates/monitor/prometheus/prometheus-deployment.yml create mode 100644 installer/k8s/templates/monitor/prometheus/prometheus-pv.yml create mode 100644 installer/k8s/templates/monitor/prometheus/prometheus-pvc.yml create mode 100644 installer/k8s/templates/monitor/prometheus/prometheus-service.yml create mode 100644 installer/k8s/templates/monitor/prometheus/token-pvc.yml diff --git a/installer/k8s/README.md b/installer/k8s/README.md index c61f9889df..9bb5d4867c 100644 --- a/installer/k8s/README.md +++ b/installer/k8s/README.md @@ -89,6 +89,7 @@ rm -rf ${HOME}/streampipes-k8s |--------------------------------------------------|---------------------------------------------------------|-----------------------------------------| | deployment | Deployment type (lite or full) | lite | | preferredBroker | Preferred broker for deployment | "nats" | +| monitoringSystem | Enable monitoring system (true/false) | false | | pullPolicy | Image pull policy | "Always" | | restartPolicy | Restart policy for the container | Always | | persistentVolumeReclaimPolicy | Reclaim policy for persistent volumes | "Delete" | @@ -168,7 +169,7 @@ rm -rf ${HOME}/streampipes-k8s | external.couchdb.appName | CouchDB application name | "couchdb" | | external.couchdb.version | CouchDB version | 3.3.1 | | external.couchdb.user | CouchDB admin username | "admin" | -| external.couchdb.password | CouchDB admin password | empty (auto-generated) | +| external.couchdb.password | CouchDB admin password | "admin" | | external.couchdb.port | Port for the CouchDB service | 5984 | | external.couchdb.service.name | Name of the CouchDB service | "couchdb" | | external.couchdb.service.port | TargetPort of the CouchDB service | 5984 | @@ -257,6 +258,41 @@ rm -rf ${HOME}/streampipes-k8s | external.pulsar.persistence.claimName | Name of the pulsar PersistentVolumeClaim | "pulsar-pvc" | | external.pulsar.persistence.pvName | Name of the pulsar PersistentVolume | "pulsar-pv" | +###Monitoring common parameters + +#### Monitoring - Prometheus +| Parameter Name | Description | Value | +|-------------------------------------------------|----------------------------------------------------------|------------------------------------------| +| prometheus.appName | Prometheus application name | "prometheus" | +| prometheus.version | Prometheus version | 2.45.0 | +| prometheus.port | Prometheus port | 9090 | +| prometheus.service.name | Prometheus service name | "prometheus" | +| prometheus.service.port | Prometheus service port | 9090 | +| prometheus.persistence.storageClassName | Prometheus storage class name | "hostpath" | +| prometheus.persistence.storageSize | Prometheus storage size | "2Gi" | +| prometheus.persistence.claimName | Prometheus PVC claim name | "prometheus-pvc" | +| prometheus.persistence.pvName | Prometheus PV name | "prometheus-pv" | +| prometheus.persistence.tokenStorageSize | Prometheus token storage size | "16Ki" | +| prometheus.config.scrapeInterval | Prometheus scrape interval | 10s | +| prometheus.config.evaluationInterval | Prometheus evaluation interval | 15s | +| prometheus.config.backendJobName | Prometheus backend job name | "backend" | +| prometheus.config.extensionsName | Prometheus extensions job name | "extensions-all-iiot" | +| prometheus.config.tokenFileName | Prometheus token file name | "token" | +| prometheus.config.tokenFileDir | Prometheus token file directory | "/opt/data/" + +#### Monitoring - Grafana +| Parameter Name | Description | Value | +|-------------------------------------------------|----------------------------------------------------------|------------------------------------------| +| grafana.appName | Grafana application name | "grafana" | +| grafana.version | Grafana version | 10.1.2 | +| grafana.port | Grafana port | 3000 | +| grafana.service.name | Grafana service name | "grafana" | +| grafana.service.port | Grafana service port | 3000 | +| grafana.persistence.storageClassName | Grafana storage class name | "hostpath" | +| grafana.persistence.storageSize | Grafana storage size | "1Gi" | +| grafana.persistence.claimName | Grafana PVC claim name | "grafana-pvc" | +| grafana.persistence.pvName | Grafana PV name | "grafana-pv" | + ## Bugs and Feature Requests If you've found a bug or have a feature that you'd love to see in StreamPipes, feel free to create an issue on [GitHub](https://github.com/apache/streampipes/issues). diff --git a/installer/k8s/templates/core/backend-deployment.yaml b/installer/k8s/templates/core/backend-deployment.yaml index 59bb2f57d0..a8d4e8e26d 100644 --- a/installer/k8s/templates/core/backend-deployment.yaml +++ b/installer/k8s/templates/core/backend-deployment.yaml @@ -45,6 +45,8 @@ spec: image: {{ .Values.streampipes.registry }}/backend:{{ .Values.streampipes.version }} imagePullPolicy: {{ .Values.pullPolicy }} env: + - name: SP_SETUP_PROMETHEUS_ENDPOINT + value: "{{ .Values.monitoringSystem }}" - name: SP_PRIORITIZED_PROTOCOL {{- if eq .Values.preferredBroker "pulsar" }} value: "pulsar" diff --git a/installer/k8s/templates/core/extensions-all-iiot-deployment.yaml b/installer/k8s/templates/core/extensions-all-iiot-deployment.yaml index f48d5512f7..16a1e88bf0 100644 --- a/installer/k8s/templates/core/extensions-all-iiot-deployment.yaml +++ b/installer/k8s/templates/core/extensions-all-iiot-deployment.yaml @@ -39,6 +39,8 @@ spec: ports: - containerPort: {{ .Values.extensions.iiot.port }} env: + - name: SP_SETUP_PROMETHEUS_ENDPOINT + value: "{{ .Values.monitoringSystem }}" - name: SP_CLIENT_USER value: "{{ .Values.streampipes.auth.users.service.user }}" - name: SP_CLIENT_SECRET diff --git a/installer/k8s/templates/monitor/grafana/grafana-deployment.yml b/installer/k8s/templates/monitor/grafana/grafana-deployment.yml new file mode 100644 index 0000000000..11743fed41 --- /dev/null +++ b/installer/k8s/templates/monitor/grafana/grafana-deployment.yml @@ -0,0 +1,69 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if eq .Values.monitoringSystem true }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.monitoring.grafana.appName }} + labels: + app: {{ .Values.monitoring.grafana.appName }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Values.monitoring.grafana.appName }} + template: + metadata: + labels: + app: {{ .Values.monitoring.grafana.appName }} + spec: + volumes: + - name: {{ .Values.monitoring.grafana.persistence.pvName }} + persistentVolumeClaim: + claimName: {{ .Values.monitoring.grafana.persistence.claimName }} + restartPolicy: {{ .Values.restartPolicy }} + initContainers: + - name: init-wait-consul-couchdb-core + image: alpine + command: ["sh", "-c", "for i in $(seq 1 300); do nc -zvw1 {{ .Values.streampipes.core.service.name }} {{ .Values.streampipes.core.service.port }} && nc -zvw1 {{ .Values.extensions.iiot.service.name }} {{ .Values.extensions.iiot.service.port }} && exit 0 || sleep 3; done; exit 1"] + containers: + - name: {{ .Values.monitoring.grafana.appName }} + image: grafana/grafana:{{ .Values.monitoring.grafana.version }} + imagePullPolicy: {{ .Values.pullPolicy }} + ports: + - containerPort: {{ .Values.monitoring.grafana.port }} + volumeMounts: + - name: {{ .Values.monitoring.grafana.persistence.pvName }} + mountPath: /var/lib/grafana + livenessProbe: + tcpSocket: + port: {{ .Values.monitoring.grafana.port }} + initialDelaySeconds: {{ .Values.initialDelaySeconds }} + periodSeconds: {{ .Values.periodSeconds }} + failureThreshold: {{ .Values.failureThreshold }} + readinessProbe: + tcpSocket: + port: {{ .Values.monitoring.grafana.port }} + initialDelaySeconds: {{ .Values.initialDelaySeconds }} + periodSeconds: {{ .Values.periodSeconds }} + failureThreshold: {{ .Values.failureThreshold }} + startupProbe: + tcpSocket: + port: {{ .Values.monitoring.grafana.port }} + initialDelaySeconds: {{ .Values.initialDelaySeconds }} + periodSeconds: {{ .Values.periodSeconds }} + failureThreshold: {{ .Values.failureThreshold }} +{{- end }} \ No newline at end of file diff --git a/installer/k8s/templates/monitor/grafana/grafana-pv.yml b/installer/k8s/templates/monitor/grafana/grafana-pv.yml new file mode 100644 index 0000000000..773bad1602 --- /dev/null +++ b/installer/k8s/templates/monitor/grafana/grafana-pv.yml @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if eq .Values.monitoringSystem true }} +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ .Values.monitoring.grafana.persistence.pvName }} +spec: + storageClassName: {{ .Values.monitoring.grafana.persistence.storageClassName }} + capacity: + storage: {{ .Values.monitoring.grafana.persistence.storageSize }} + accessModes: + - {{ .Values.persistentVolumeAccessModes }} + persistentVolumeReclaimPolicy: {{ .Values.persistentVolumeReclaimPolicy }} + hostPath: + path: {{ .Values.hostPath }}/grafana +{{- end }} \ No newline at end of file diff --git a/installer/k8s/templates/monitor/grafana/grafana-pvc.yml b/installer/k8s/templates/monitor/grafana/grafana-pvc.yml new file mode 100644 index 0000000000..a5ed886702 --- /dev/null +++ b/installer/k8s/templates/monitor/grafana/grafana-pvc.yml @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if eq .Values.monitoringSystem true }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + app: {{ .Values.monitoring.grafana.appName }} + name: {{ .Values.monitoring.grafana.persistence.claimName }} +spec: + storageClassName: {{ .Values.monitoring.grafana.persistence.storageClassName }} + accessModes: + - {{ .Values.persistentVolumeAccessModes }} + resources: + requests: + storage: {{ .Values.monitoring.grafana.persistence.storageSize }} +{{- end }} \ No newline at end of file diff --git a/streampipes-extensions/streampipes-extensions-all-jvm/Dockerfile b/installer/k8s/templates/monitor/grafana/grafana-service.yml similarity index 68% rename from streampipes-extensions/streampipes-extensions-all-jvm/Dockerfile rename to installer/k8s/templates/monitor/grafana/grafana-service.yml index d84e5bcea2..7c4dac3097 100644 --- a/streampipes-extensions/streampipes-extensions-all-jvm/Dockerfile +++ b/installer/k8s/templates/monitor/grafana/grafana-service.yml @@ -13,11 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM eclipse-temurin:17-jre-focal - -# needed pkgs processors-image-processing-jvm -RUN apt-get update && apt-get install ttf-dejavu-core && apt-get install fontconfig - -COPY target/streampipes-extensions-all-jvm.jar /streampipes-extensions-all-jvm.jar - -ENTRYPOINT ["java", "-jar", "/streampipes-extensions-all-jvm.jar"] +{{- if eq .Values.monitoringSystem true }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.monitoring.grafana.service.name }} +spec: + selector: + app: {{ .Values.monitoring.grafana.appName }} + ports: + - name: main + protocol: TCP + port: {{ .Values.monitoring.grafana.port }} + targetPort: {{ .Values.monitoring.grafana.port }} +{{- end }} \ No newline at end of file diff --git a/installer/k8s/templates/monitor/prometheus/prometheus-configmap.yaml b/installer/k8s/templates/monitor/prometheus/prometheus-configmap.yaml new file mode 100644 index 0000000000..dbb2e92468 --- /dev/null +++ b/installer/k8s/templates/monitor/prometheus/prometheus-configmap.yaml @@ -0,0 +1,49 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if eq .Values.monitoringSystem true }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: prometheus-conf + +data: + prometheus.yml: | + global: + scrape_interval: {{ .Values.monitoring.prometheus.config.scrapeInterval }} + evaluation_interval: {{ .Values.monitoring.prometheus.config.evaluationInterval }} + alerting: + alertmanagers: + - static_configs: + - targets: + rule_files: + + scrape_configs: + - job_name: "{{ .Values.monitoring.prometheus.appName }}" + static_configs: + - targets: ["{{ .Values.monitoring.prometheus.service.name }}:{{ .Values.monitoring.prometheus.service.port }}"] + + - job_name: "{{ .Values.monitoring.prometheus.config.backendJobName }}" + metrics_path: "/streampipes-backend/actuator/prometheus" + bearer_token_file: "{{ .Values.monitoring.prometheus.config.tokenFileDir }}{{ .Values.monitoring.prometheus.config.tokenFileName }}{{ .Values.monitoring.prometheus.config.tokenFileName }}" + static_configs: + - targets: [ "{{ .Values.streampipes.core.service.name }}:{{ .Values.streampipes.core.service.port }}" ] + + + - job_name: "{{ .Values.monitoring.prometheus.config.extensionsName }}" + metrics_path: "/actuator/prometheus" + static_configs: + - targets: ["{{ .Values.extensions.iiot.service.name }}:{{ .Values.extensions.iiot.service.port }}"] +{{- end }} \ No newline at end of file diff --git a/installer/k8s/templates/monitor/prometheus/prometheus-deployment.yml b/installer/k8s/templates/monitor/prometheus/prometheus-deployment.yml new file mode 100644 index 0000000000..260de082af --- /dev/null +++ b/installer/k8s/templates/monitor/prometheus/prometheus-deployment.yml @@ -0,0 +1,108 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if eq .Values.monitoringSystem true }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.monitoring.prometheus.appName }} + labels: + app: {{ .Values.monitoring.prometheus.appName }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Values.monitoring.prometheus.appName }} + template: + metadata: + labels: + app: {{ .Values.monitoring.prometheus.appName }} + spec: + volumes: + - name: shared-token + persistentVolumeClaim: + claimName: token + - name: {{ .Values.monitoring.prometheus.persistence.pvName }} + persistentVolumeClaim: + claimName: {{ .Values.monitoring.prometheus.persistence.claimName }} + - name: prometheus-conf + configMap: + name: prometheus-conf + restartPolicy: {{ .Values.restartPolicy }} + initContainers: + - name: init-wait-consul-couchdb-core + image: alpine + command: ["sh", "-c", "for i in $(seq 1 300); do nc -zvw1 {{ .Values.streampipes.core.service.name }} {{ .Values.streampipes.core.service.port }} && nc -zvw1 {{ .Values.extensions.iiot.service.name }} {{ .Values.extensions.iiot.service.port }} && exit 0 || sleep 3; done; exit 1"] + containers: + - name: prometheus-token-refresher + image: luoluoyuyu/prometheus-token-refresher:1.0.0 + imagePullPolicy: "IfNotPresent" + env: + - name: SP_HOST + value: "backend" + - name: SP_PORT + value: "{{ .Values.streampipes.core.service.port }}" + - name: SP_USERNAME + value: "{{ .Values.streampipes.auth.users.admin.user }}" + - name: SP_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.streampipes.auth.secretName}} + key: sp-encryption-passcode + - name: PROMETHEUS_HOST + value: "{{ .Values.monitoring.prometheus.service.name }}" + - name: PROMETHEUS_PORT + value: "{{ .Values.monitoring.prometheus.service.port }}" + - name: TOKEN_FILE + value: "{{ .Values.monitoring.prometheus.config.tokenFileDir }}{{ .Values.monitoring.prometheus.config.tokenFileName }}" + volumeMounts: + - name: shared-token + mountPath: {{ .Values.monitoring.prometheus.config.tokenFileDir }} + readOnly: false + - name: {{ .Values.monitoring.prometheus.appName }} + image: bitnami/prometheus:{{ .Values.monitoring.prometheus.version }} + imagePullPolicy: {{ .Values.pullPolicy }} + args: + - --web.enable-lifecycle + ports: + - containerPort: {{ .Values.monitoring.prometheus.port }} + volumeMounts: + - name: prometheus-conf + mountPath: /opt/bitnami/prometheus/prometheus.yml + subPath: prometheus.yml + - name: {{ .Values.monitoring.prometheus.persistence.pvName }} + mountPath: /opt/bitnami/prometheus/data + - name: shared-token + mountPath: {{ .Values.monitoring.prometheus.config.tokenFileDir }} + readOnly: false + livenessProbe: + tcpSocket: + port: {{ .Values.monitoring.prometheus.port }} + initialDelaySeconds: {{ .Values.initialDelaySeconds }} + periodSeconds: {{ .Values.periodSeconds }} + failureThreshold: {{ .Values.failureThreshold }} + readinessProbe: + tcpSocket: + port: {{ .Values.monitoring.prometheus.port }} + initialDelaySeconds: {{ .Values.initialDelaySeconds }} + periodSeconds: {{ .Values.periodSeconds }} + failureThreshold: {{ .Values.failureThreshold }} + startupProbe: + tcpSocket: + port: {{ .Values.monitoring.prometheus.port }} + initialDelaySeconds: {{ .Values.initialDelaySeconds }} + periodSeconds: {{ .Values.periodSeconds }} + failureThreshold: {{ .Values.failureThreshold }} +{{- end }} \ No newline at end of file diff --git a/installer/k8s/templates/monitor/prometheus/prometheus-pv.yml b/installer/k8s/templates/monitor/prometheus/prometheus-pv.yml new file mode 100644 index 0000000000..4ded896c27 --- /dev/null +++ b/installer/k8s/templates/monitor/prometheus/prometheus-pv.yml @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if eq .Values.monitoringSystem true }} +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ .Values.monitoring.prometheus.persistence.pvName }} +spec: + storageClassName: {{ .Values.monitoring.prometheus.persistence.storageClassName }} + capacity: + storage: {{ .Values.monitoring.prometheus.persistence.storageSize }} + accessModes: + - {{ .Values.persistentVolumeAccessModes }} + persistentVolumeReclaimPolicy: {{ .Values.persistentVolumeReclaimPolicy }} + hostPath: + path: {{ .Values.hostPath }}/prometheus +{{- end }} \ No newline at end of file diff --git a/installer/k8s/templates/monitor/prometheus/prometheus-pvc.yml b/installer/k8s/templates/monitor/prometheus/prometheus-pvc.yml new file mode 100644 index 0000000000..11920e6d45 --- /dev/null +++ b/installer/k8s/templates/monitor/prometheus/prometheus-pvc.yml @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if eq .Values.monitoringSystem true }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + app: {{ .Values.monitoring.prometheus.appName }} + name: {{ .Values.monitoring.prometheus.persistence.claimName }} +spec: + storageClassName: {{ .Values.monitoring.prometheus.persistence.storageClassName }} + accessModes: + - {{ .Values.persistentVolumeAccessModes }} + resources: + requests: + storage: {{ .Values.monitoring.prometheus.persistence.storageSize }} +{{- end }} \ No newline at end of file diff --git a/installer/k8s/templates/monitor/prometheus/prometheus-service.yml b/installer/k8s/templates/monitor/prometheus/prometheus-service.yml new file mode 100644 index 0000000000..ec0177d4ec --- /dev/null +++ b/installer/k8s/templates/monitor/prometheus/prometheus-service.yml @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +{{- if eq .Values.monitoringSystem true }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.monitoring.prometheus.service.name }} +spec: + selector: + app: {{ .Values.monitoring.prometheus.appName }} + ports: + - name: main + protocol: TCP + port: {{ .Values.monitoring.prometheus.port }} + targetPort: {{ .Values.monitoring.prometheus.port }} +{{- end }} \ No newline at end of file diff --git a/installer/k8s/templates/monitor/prometheus/token-pvc.yml b/installer/k8s/templates/monitor/prometheus/token-pvc.yml new file mode 100644 index 0000000000..5cd00885f4 --- /dev/null +++ b/installer/k8s/templates/monitor/prometheus/token-pvc.yml @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if eq .Values.monitoringSystem true }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: token +spec: + storageClassName: {{ .Values.monitoring.prometheus.persistence.storageClassName }} + accessModes: + - {{ .Values.persistentVolumeAccessModes }} + resources: + requests: + storage: {{ .Values.monitoring.prometheus.persistence.tokenStorageSize }} +{{- end }} \ No newline at end of file diff --git a/installer/k8s/values.yaml b/installer/k8s/values.yaml index 63abf6cc8d..145141f407 100644 --- a/installer/k8s/values.yaml +++ b/installer/k8s/values.yaml @@ -16,6 +16,7 @@ # lite or full (default: lite) deployment: lite preferredBroker: "nats" +monitoringSystem: false pullPolicy: "Always" restartPolicy: Always persistentVolumeReclaimPolicy: "Delete" @@ -104,7 +105,7 @@ external: appName: "couchdb" version: 3.3.1 user: "admin" - password: + password: "admin" port: 5984 service: name: "couchdb" @@ -187,4 +188,39 @@ external: pvName: "pulsar-pv" +monitoring: + # monitoring - prometheus + prometheus: + appName: "prometheus" + version: 2.45.0 + port: 9090 + service: + name: "prometheus" + port: 9090 + persistence: + storageClassName: "hostpath" + storageSize: "2Gi" + claimName: "prometheus-pvc" + pvName: "prometheus-pv" + tokenStorageSize: "16Ki" + config: + scrapeInterval: 10s + evaluationInterval: 15s + backendJobName: backend + extensionsName: extensions-all-iiot + tokenFileName: token + tokenFileDir: /opt/data/ + # monitoring - grafana + grafana: + appName: "grafana" + version: 10.1.2 + port: 3000 + service: + name: "grafana" + port: 3000 + persistence: + storageClassName: "hostpath" + storageSize: "1Gi" + claimName: "grafana-pvc" + pvName: "grafana-pv"