Browse Source

add prometheus-bot chart

This PS adds prometheus-bot chart to send prometheus alerts to telegram
messenger

Change-Id: If832945d126572d821ae631d10d39d6671f46101
Story: 2005155
Robert Choi 1 month ago
parent
commit
013ea578d8

+ 21
- 0
prometheus-bot/Chart.yaml View File

@@ -0,0 +1,21 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License");
2
+# you may not use this file except in compliance with the License.
3
+# You may obtain a copy of the License at
4
+#
5
+#     http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS,
9
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+# See the License for the specific language governing permissions and
11
+# limitations under the License.
12
+
13
+apiVersion: v1
14
+description: A helm chart to deploy prometheus-bot that sends prometheus alerts to telegram.
15
+name: prometheus-bot
16
+version: 0.1.0
17
+sources:
18
+  - https://github.com/inCaller/prometheus_bot
19
+  - https://git.openstack.org/openstack/openstack-helm-addons
20
+maintainers:
21
+  - name: Openstack-Helm Authors

+ 18
- 0
prometheus-bot/requirements.yaml View File

@@ -0,0 +1,18 @@
1
+# Copyright 2017 The Openstack-Helm Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+dependencies:
16
+  - name: helm-toolkit
17
+    repository: http://localhost:8879/charts
18
+    version: 0.1.0

+ 75
- 0
prometheus-bot/templates/deployment.yaml View File

@@ -0,0 +1,75 @@
1
+{{/*
2
+Copyright 2017 The Openstack-Helm Authors.
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+   http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+*/}}
16
+
17
+{{- $envAll := . }}
18
+---
19
+apiVersion: apps/v1
20
+kind: Deployment
21
+metadata:
22
+  name: prometheus-bot
23
+  annotations:
24
+  labels:
25
+{{ tuple $envAll "prometheus-bot" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
26
+spec:
27
+  replicas: {{ .Values.pod.replicas.server }}
28
+  selector:
29
+    matchLabels:
30
+{{ tuple $envAll "prometheus-bot" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }}
31
+  template:
32
+    metadata:
33
+      labels:
34
+{{ tuple $envAll "prometheus-bot" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
35
+    spec:
36
+      hostNetwork: true
37
+      affinity:
38
+{{ tuple $envAll "prometheus-bot" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
39
+      nodeSelector:
40
+        {{ .Values.labels.server.node_selector_key }}: {{ .Values.labels.server.node_selector_value }}
41
+      terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.prometheus_bot.timeout | default "30" }}
42
+      containers:
43
+        - name: prometheus-bot
44
+{{ tuple $envAll "prometheus_bot" | include "helm-toolkit.snippets.image" | indent 10 }}
45
+{{ tuple $envAll $envAll.Values.pod.resources.server | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
46
+          securityContext:
47
+            runAsUser: 0
48
+          command:
49
+            - /prometheus_bot
50
+            - -c
51
+            - config.yaml
52
+          ports:
53
+            - name: web
54
+              containerPort: {{ tuple "server" "internal" "webhook" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
55
+          readinessProbe:
56
+            tcpSocket:
57
+              port: {{ tuple "server" "internal" "webhook" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
58
+            initialDelaySeconds: 15
59
+            periodSeconds: 10
60
+          livenessProbe:
61
+            tcpSocket:
62
+              port: {{ tuple "server" "internal" "webhook" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
63
+            initialDelaySeconds: 180
64
+            periodSeconds: 60
65
+            timeoutSeconds: 5
66
+          volumeMounts:
67
+            - name: secret-telegram-token
68
+              mountPath: /config.yaml
69
+              subPath: config.yaml
70
+              readOnly: true
71
+      volumes:
72
+        - name: secret-telegram-token
73
+          secret:
74
+            secretName: telegram-token
75
+            defaultMode: 0444

+ 24
- 0
prometheus-bot/templates/secret-telegram-token.yaml View File

@@ -0,0 +1,24 @@
1
+{{/*
2
+Copyright 2017-2018 The Openstack-Helm Authors.
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+   http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+*/}}
16
+
17
+apiVersion: v1
18
+kind: Secret
19
+metadata:
20
+  name: telegram-token
21
+stringData:
22
+  config.yaml: |
23
+    telegram_token: {{ .Values.telegram_token }}
24
+type: Opaque

+ 44
- 0
prometheus-bot/templates/service.yaml View File

@@ -0,0 +1,44 @@
1
+{{/*
2
+Copyright 2017 The Openstack-Helm Authors.
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+   http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+*/}}
16
+
17
+{{- $envAll := . }}
18
+---
19
+apiVersion: v1
20
+kind: Service
21
+metadata:
22
+  name: {{ tuple "server" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
23
+spec:
24
+  ports:
25
+    {{ if .Values.network.node_port.enabled }}
26
+    - name: web
27
+      protocol: TCP
28
+      nodePort: {{ .Values.network.node_port.port }}
29
+      port: {{ tuple "server" "internal" "webhook" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
30
+      targetPort: {{ tuple "server" "internal" "webhook" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
31
+    {{ else }}
32
+    - name: web
33
+      protocol: TCP
34
+      port: {{ tuple "server" "internal" "webhook" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
35
+      targetPort: {{ tuple "server" "internal" "webhook" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
36
+    {{ end }}
37
+  selector:
38
+{{ tuple $envAll "prometheus-bot" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
39
+  {{ if .Values.network.node_port.enabled }}
40
+  type: NodePort
41
+  {{ if .Values.network.external_policy_local }}
42
+  externalTrafficPolicy: Local
43
+  {{ end }}
44
+  {{ end }}

+ 90
- 0
prometheus-bot/values.yaml View File

@@ -0,0 +1,90 @@
1
+# Copyright 2017 The Openstack-Helm Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+# Default values for horizon.
16
+# This is a YAML-formatted file.
17
+# Declare name/value pairs to be passed into your templates.
18
+# name: value
19
+
20
+images:
21
+  tags:
22
+    prometheus_bot: docker.io/sktdev/prometheus-bot:latest
23
+    dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1
24
+    image_repo_sync: docker.io/docker:17.07.0
25
+  pull_policy: "IfNotPresent"
26
+  local_registry:
27
+    active: false
28
+    exclude:
29
+      - dep_check
30
+      - image_repo_sync
31
+
32
+labels:
33
+  server:
34
+    node_selector_key: openstack-control-plane
35
+    node_selector_value: enabled
36
+
37
+network:
38
+  external_policy_local: false
39
+  node_port:
40
+    enabled: false
41
+    port: 33000
42
+
43
+pod:
44
+  affinity:
45
+    anti:
46
+      type:
47
+        default: preferredDuringSchedulingIgnoredDuringExecution
48
+      topologyKey:
49
+        default: kubernetes.io/hostname
50
+  mounts:
51
+  replicas:
52
+    server: 1
53
+  lifecycle:
54
+    upgrades:
55
+      deployments:
56
+        revision_history: 3
57
+        pod_replacement_strategy: RollingUpdate
58
+        rolling_update:
59
+          max_unavailable: 1
60
+          max_surge: 3
61
+    disruption_budget:
62
+      prometheus_bot:
63
+        min_available: 0
64
+    termination_grace_period:
65
+      prometheus_bot:
66
+        timeout: 30
67
+  resources:
68
+    enabled: false
69
+    server:
70
+      requests:
71
+        memory: "256Mi"
72
+        cpu: "200m"
73
+      limits:
74
+        memory: "1024Mi"
75
+        cpu: "2000m"
76
+
77
+# typically overridden by environmental
78
+# values, but should include all endpoints
79
+# required by this chart
80
+endpoints:
81
+  cluster_domain_suffix: cluster.local
82
+  server:
83
+    name: prometheus-bot
84
+    hosts:
85
+      default: prometheus-bot
86
+    port:
87
+      webhook:
88
+        default: 9087
89
+
90
+telegram_token: ''

Loading…
Cancel
Save