k8s Prometheus

Installing Prometheus
2023-09-20

phomlish@a6:~/kubernetes/prometheus/homlish-monitoring
k apply -f k apply -f homlish-monitor-ns.yaml

kubectl create -f clusterRole.yaml

using helm?

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm search repo prometheus-community/prometheus –versions
prometheus-community/prometheus 19.3.1 v2.41.0 Prometheus is a monitoring system and time seri…

helm install 19.3.1 prometheus-community/prometheus

helm -n homlish-monitor delete prometheus

phomlish@a6:~/kubernetes/prometheus$ helm upgrade –install -n homlish-monitor –version 19.3.1 -f values.yaml prometheus prometheus-community/prometheus
NAME: prometheus
LAST DEPLOYED: Wed Oct 11 07:53:06 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
The Prometheus server can be accessed via port 80 on the following DNS name from within your cluster:
prometheus-server.default.svc.cluster.local

Get the Prometheus server URL by running these commands in the same shell:
export POD_NAME=$(kubectl get pods –namespace default -l “app=prometheus,component=server” -o jsonpath=”{.items[0].metadata.name}”)
kubectl –namespace default port-forward $POD_NAME 9090

The Prometheus alertmanager can be accessed via port on the following DNS name from within your cluster:
prometheus-%!s().default.svc.cluster.local

Get the Alertmanager URL by running these commands in the same shell:
export POD_NAME=$(kubectl get pods –namespace default -l “app=prometheus,component=” -o jsonpath=”{.items[0].metadata.name}”)
kubectl –namespace default port-forward $POD_NAME 9093
#################################################################################
###### WARNING: Pod Security Policy has been disabled by default since #####
###### it deprecated after k8s 1.25+. use #####
###### (index .Values “prometheus-node-exporter” “rbac” #####
###### . “pspEnabled”) with (index .Values #####
###### “prometheus-node-exporter” “rbac” “pspAnnotations”) #####
###### in case you still need it. #####
#################################################################################

The Prometheus PushGateway can be accessed via port 9091 on the following DNS name from within your cluster:
prometheus-prometheus-pushgateway.default.svc.cluster.local

Get the PushGateway URL by running these commands in the same shell:
export POD_NAME=$(kubectl get pods –namespace default -l “app=prometheus-pushgateway,component=pushgateway” -o jsonpath=”{.items[0].metadata.name}”)
kubectl –namespace default port-forward $POD_NAME 9091

For more information on running Prometheus, visit:
https://prometheus.io/

https://dev.to/kaitoii11/deploy-prometheus-monitoring-stack-to-kubernetes-with-a-single-helm-chart-2fbd
https://devopscube.com/setup-prometheus-monitoring-on-kubernetes/

todo: review prometheus.io/scrape to scape other namespaces

#did this as phomlish@a6
k create namespace prometheus

# create persistent volume
k apply -f pv-alert.yaml
k apply -f pv-operator.yaml
k apply -f pv-grafana.yaml

helm upgrade –install prometheus . -n prometheus -f values.yaml
helm -n prometheus delete prometheus


the process below installed all with no configuration
did this as phomlish@a6
k create namespace prometheus

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm search repo prometheus-community
helm repo update

helm -n prometheus delete prometheus
helm upgrade –install prometheus . -n prometheus -f values.yaml
k -n prometheus logs -f prometheus-prometheus-kube-prometheus-prometheus-0

phomlish@a6:~/kubernetes/prometheus/helm-charts/charts/kube-prometheus-stack$ helm install prometheus prometheus-community/kube-prometheus-stack -n prometheus
NAME: prometheus
LAST DEPLOYED: Wed Jun 30 04:27:49 2021
NAMESPACE: prometheus
STATUS: deployed
REVISION: 1
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
kubectl –namespace prometheus get pods -l “release=prometheus”

Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.

k port-forward -n prometheus prometheus-prometheus-kube-prometheus-prometheus-0 9090
k port-forward -n prometheus pod/prometheus-grafana-5679f49d88-kxndt 3000

k get secret -n prometheus prometheus-grafana -o go-template='{{range $k,$v := .data}}{{“### “}}{{$k}}{{“\n”}}{{$v|base64decode}}{{“\n\n”}}{{end}}’

To edit grafana
don’t know how other than redploy the whole thing

Leave a Reply

Your email address will not be published. Required fields are marked *