Skip to content

Instantly share code, notes, and snippets.

@damnever
Created July 11, 2022 03:41
Show Gist options
  • Save damnever/a4648665737b2d0366cce6a9b255d1bc to your computer and use it in GitHub Desktop.
Save damnever/a4648665737b2d0366cce6a9b255d1bc to your computer and use it in GitHub Desktop.
# https://github.com/prometheus/prometheus/pull/10973
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: prometheus
name: prometheus-wal-test
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: prometheus
serviceName: prometheus-wal-test
template:
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: prometheus
spec:
containers:
initContainers:
- args:
- |
# Prepare data
rm -rf /data/battlefield
mkdir -p /data/battlefield/wal
cp -r /data/load-wal-test/* /data/battlefield/wal/
# Config
cat > /etc/config/prometheus.yml <<EOF
global:
evaluation_interval: 1m
EOF
cat > /etc/config/selfmonitor-prometheus.yml <<EOF
scrape_configs:
- job_name: "prometheus"
scrape_interval: 3s
static_configs:
- targets: ["localhost:9090"]
metric_relabel_configs:
- target_label: "pod_ip"
replacement: "${MY_POD_IP}"
EOF
command:
- /bin/sh
- -c
env:
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
image: busybox:1.34.1
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /data
name: storage-volume
- mountPath: /etc/config
name: config-volume
- args:
- --storage.tsdb.path=/data/battlefield
- --storage.tsdb.retention.time=30d
- --config.file=/etc/config/prometheus.yml
- --enable-feature=auto-gomaxprocs
# prom/prometheus:main
image: prom/prometheus:main
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 30
httpGet:
path: /-/healthy
port: 9090
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 30
name: prometheus-server
ports:
readinessProbe:
failureThreshold: 3
httpGet:
path: /-/ready
port: 9090
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 30
resources:
limits:
cpu: "16"
memory: 16Gi
requests:
cpu: "16"
memory: 16Gi
volumeMounts:
- mountPath: /data
name: storage-volume
- mountPath: /etc/config
name: config-volume
- name: self-monitor
args:
- --storage.tsdb.path=/data/self-monitor
- --storage.tsdb.retention.time=30d
- --config.file=/etc/config/selfmonitor-prometheus.yml
- --web.listen-address=:9999
image: prom/prometheus:main
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: "1"
memory: 2Gi
requests:
cpu: "1"
memory: 2Gi
volumeMounts:
- mountPath: /data
name: storage-volume
- mountPath: /etc/config
name: config-volume
restartPolicy: Always
securityContext:
fsGroup: 65534
runAsGroup: 65534
runAsNonRoot: true
runAsUser: 65534
volumes:
- emptyDir: {}
name: config-volume
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: storage-volume
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
volumeMode: Filesystem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment