Prometheus conf reloader
For those who do not appreciate auto-magic components like the Prometheus operator and deployed Prometheus vanilla all by yourselves like grown-ups, provided that prometheus is launched with --web.enable-lifecycle, conf reloading can be acheived like this.
- name: conf-reloader-sidecar
image: alpine/curl:8.22.0
command:
- /bin/ash
args:
- "-c"
- |
H=$(sha1sum /etc/prometheus/prometheus.yml)
while sleep 2; do
N=$(sha1sum /etc/prometheus/prometheus.yml)
if [ "${N}" != "${H}" ]; then
echo "[$(date -Iseconds)] Conf change detected, query prometheus for conf reloading"
curl -X POST http://127.0.0.1:9090/-/reload 2>/dev/null
H="${N}"
fi
done
volumeMounts: # or however you named your volume
- name: prometheus-config
mountPath: /etc/prometheus
Debian based CA updater
Who wan’t to import private authority certificates into their application while most http client libraries inherit from the system’s trust store? Just use update-ca-certificates to populate a common certs volume with anything you mount on /usr/local/share/ca-certificates
apiVersion: batch/v1
kind: Job
spec:
template:
spec:
initContainers:
- name: update-certs
securityContext:
runAsUser: 0 # only need root to update certs
image: some_debian_based_image:0.6.4
command: ['/bin/sh', '-c']
args:
[
'update-ca-certificates; cp -r /etc/ssl/certs/* /etc/ssl/certs_pod/',
]
volumeMounts:
- name: certs
mountPath: /etc/ssl/certs_pod
- name: elastic-http-certs-public
readOnly: true
mountPath: /usr/local/share/ca-certificates/some.crt
subPath: ca.pem
containers:
- name: eteel-job
image: some_debian_based_image:0.6.4
volumeMounts:
- name: certs
mountPath: '/etc/ssl/certs'