Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deployment of Prometheus and Grafana to K8s #1978

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion installer/k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" |
Expand Down Expand Up @@ -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" |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leave the CouchDB default as auto-generated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already modified

| 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 |
Expand Down Expand Up @@ -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).
Expand Down
2 changes: 2 additions & 0 deletions installer/k8s/templates/core/backend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
69 changes: 69 additions & 0 deletions installer/k8s/templates/monitor/grafana/grafana-deployment.yml
Original file line number Diff line number Diff line change
@@ -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 }}
30 changes: 30 additions & 0 deletions installer/k8s/templates/monitor/grafana/grafana-pv.yml
Original file line number Diff line number Diff line change
@@ -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 }}
30 changes: 30 additions & 0 deletions installer/k8s/templates/monitor/grafana/grafana-pvc.yml
Original file line number Diff line number Diff line change
@@ -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 }}
29 changes: 29 additions & 0 deletions installer/k8s/templates/monitor/grafana/grafana-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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.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 }}
Original file line number Diff line number Diff line change
@@ -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 }}
Loading
Loading