-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create monitoring Prometheus with operator (#79)
* feat: Create monitoring Prometheus with operator * Remove all yaml file, replace by generating script * Remove commentary in the template and write readme Co-authored-by: Grumbleur <remi.gaiffe@googlemail.com> Co-authored-by: 42Atomys <contact@atomys.fr>
- Loading branch information
1 parent
583ed72
commit 558b9a0
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Monitoring | ||
|
||
[Official documentation](https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/customizing.md) | ||
|
||
For deploy monitoring we need to generate json files with `jb` command. | ||
|
||
Run the script `build.sh` for json files and apply in the cluster. | ||
|
||
The script init workdir with `jb`, download some components mandatory, edit json files for scale down replicas and apply on the cluster. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -x | ||
# only exit with zero if all commands of the pipeline exit successfully | ||
set -o pipefail | ||
# Make sure to use project tooling | ||
PATH="$(pwd)/tmp/bin:${PATH}" | ||
|
||
jb init | ||
jb install github.com/prometheus-operator/kube-prometheus/jsonnet/kube-prometheus@main | ||
|
||
mkdir -p manifests/setup | ||
|
||
jsonnet -J vendor -m manifests "template.jsonnet" | xargs -I{} sh -c 'mv {} {}.json' -- {} | ||
find manifests -type f ! -name '*.json' -delete | ||
rm -f kustomization | ||
|
||
sed -i -e 's/"replicas": 3/"replicas": 1/g' manifests/alertmanager-alertmanager.json | ||
sed -i -e 's/"replicas": 2/"replicas": 1/g' manifests/prometheus-prometheus.json | ||
|
||
kubectl apply --server-side -f manifests/setup | ||
kubectl apply --server-side -f manifests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local kp = | ||
(import 'kube-prometheus/main.libsonnet') + | ||
{ | ||
values+:: { | ||
common+: { | ||
namespace: 'monitoring', | ||
}, | ||
}, | ||
}; | ||
|
||
{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } + | ||
{ | ||
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name] | ||
for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator)) | ||
} + | ||
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } + | ||
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } + | ||
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } + | ||
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } + | ||
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } |