apiVersion: apps/v1 kind: StatefulSet metadata: name: prometheus namespace: observability labels: app: prometheus spec: serviceName: prometheus replicas: 1 selector: matchLabels: app: prometheus template: metadata: labels: app: prometheus annotations: prometheus.io/scrape: "true" prometheus.io/port: "9090" spec: serviceAccountName: prometheus nodeSelector: kubernetes.io/hostname: hetzner-2 containers: - name: prometheus image: prom/prometheus:v2.54.1 args: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--storage.tsdb.retention.time=7d' - '--web.console.libraries=/usr/share/prometheus/console_libraries' - '--web.console.templates=/usr/share/prometheus/consoles' - '--web.enable-lifecycle' - '--web.enable-admin-api' ports: - name: http containerPort: 9090 protocol: TCP livenessProbe: httpGet: path: /-/healthy port: http initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 readinessProbe: httpGet: path: /-/ready port: http initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 resources: requests: cpu: 500m memory: 2Gi limits: cpu: 2000m memory: 4Gi volumeMounts: - name: prometheus-config mountPath: /etc/prometheus - name: prometheus-data mountPath: /prometheus volumes: - name: prometheus-config configMap: name: prometheus-config - name: prometheus-data persistentVolumeClaim: claimName: prometheus-data --- apiVersion: v1 kind: Service metadata: name: prometheus namespace: observability labels: app: prometheus spec: type: ClusterIP ports: - port: 9090 targetPort: http protocol: TCP name: http selector: app: prometheus