Prometheus on Kubernetes with NFS
📈 Prometheus on Kubernetes with NFS
This guide provides Kubernetes manifests to deploy Prometheus on a cluster using:
NFS server for persistent storage (192.168.88.61:/nfs/prometheus)
📌 Requirements
- Kubernetes cluster (v1.24+)
- NFS path
/nfs/prometheusexists and is writable
🗂 Files Included
📄 prometheus-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
data:
prometheus.yml: |
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
📄 prometheus-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: prometheus-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
nfs:
server: 192.168.88.61
path: /nfs/prometheus
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: prometheus-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
📄 prometheus-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus
spec:
replicas: 1
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus:v2.52.0
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
ports:
- containerPort: 9090
volumeMounts:
- name: config-volume
mountPath: /etc/prometheus
- name: data-volume
mountPath: /prometheus
volumes:
- name: config-volume
configMap:
name: prometheus-config
- name: data-volume
persistentVolumeClaim:
claimName: prometheus-pvc
📄 prometheus-service.yaml
apiVersion: v1
kind: Service
metadata:
name: prometheus
spec:
type: NodePort
selector:
app: prometheus
ports:
- port: 80
targetPort: 9090
nodePort: 30084
🚀 Deployment Steps
kubectl apply -f prometheus-configmap.yaml
kubectl apply -f prometheus-pv.yaml
kubectl apply -f prometheus-deployment.yaml
kubectl apply -f prometheus-service.yaml
🌐 Access Prometheus
Visit in browser:
http://<NodeIP>:30084
⚠️ Notes
- Ensure
/nfs/prometheusexists on the NFS server:
mkdir -p /nfs/prometheus
chmod -R 777 /nfs/prometheus
- For shared access or HA setup, consider
ReadWriteManyif supported by your CSI.
📄 License
MIT
0
Uncategorized