Install the Prometheus Helm Charts locally.
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
Deploy Prometheus without mounting root volume.
- Root Host volume will be disabled
- This will only detect PodMonitor objects in namespaces labeled with "istio-injection"="enabled"
- You will have to label your application namespaces with "istio-injection":"enabled"
helm install prometheus prometheus-community/kube-prometheus-stack --namespace prometheus --create-namespace --set prometheus-node-exporter.hostRootFsMount.enabled=false --set prometheus.prometheusSpec.podMonitorNamespaceSelector.matchLabels.istio-injection=enabled --set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false
If you want to expose the Prometheus UI through Istio, deploy a VirtualService pointing to the Prometheus service.
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: prometheus
namespace: prometheus
spec:
gateways:
- gateway/istio-ingressgateway
hosts:
- localhost
- host.docker.internal
http:
- match:
- uri:
prefix: /prometheus/
name: http
rewrite:
uri: /
route:
- destination:
host: prometheus-kube-prometheus-prometheus.prometheus.svc.cluster.local
port:
number: 9090
subset: http
weight: 100
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: prometheus
namespace: prometheus
spec:
host: prometheus-kube-prometheus-prometheus.prometheus.svc.cluster.local
subsets:
- labels:
app.kubernetes.io/instance: prometheus-kube-prometheus-prometheus
app.kubernetes.io/managed-by: prometheus-operator
app.kubernetes.io/name: prometheus
app.kubernetes.io/version: 2.40.5
name: http
trafficPolicy:
tls:
mode: DISABLE
Deploy a PodMonitor for your pods. https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/user-guides/getting-started.md
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: ...
namespace: ...
spec:
podMetricsEndpoints:
- interval: 15s
path: /stats/prometheus
port: http-envoy-prom
scheme: http
selector:
matchLabels:
...
Enter to your prometheus URL: https:///prometheus/graph and run a query:
rate(istio_requests_total[30s])