mirror of
https://github.com/outbackdingo/home-ops.git
synced 2026-01-27 10:19:11 +00:00
fix: uptimerobot heartbeat
This commit is contained in:
4
.github/yamllint.config.yaml
vendored
4
.github/yamllint.config.yaml
vendored
@@ -14,6 +14,4 @@ rules:
|
||||
brackets:
|
||||
min-spaces-inside: 0
|
||||
max-spaces-inside: 0
|
||||
indentation:
|
||||
spaces: 2
|
||||
indent-sequences: consistent
|
||||
indentation: enable
|
||||
|
||||
@@ -6,35 +6,37 @@ metadata:
|
||||
name: uptimerobot-heartbeat
|
||||
spec:
|
||||
schedule: "*/5 * * * *"
|
||||
concurrencyPolicy: Forbid
|
||||
concurrencyPolicy: "Forbid"
|
||||
successfulJobsHistoryLimit: 3
|
||||
failedJobsHistoryLimit: 5
|
||||
jobTemplate:
|
||||
spec:
|
||||
backoffLimit: 3
|
||||
ttlSecondsAfterFinished: 300
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
botkube.io/disable: "true"
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: uptimerobot-heartbeat
|
||||
image: ghcr.io/k8s-at-home/kubectl:v1.22.2
|
||||
imagePullPolicy: IfNotPresent
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: uptimerobot-heartbeat-url
|
||||
command:
|
||||
- "/bin/sh"
|
||||
- "-ec"
|
||||
- |
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
if [ -z "$UPTIMEROBOT_HEARTBEAT_URL" ]; then
|
||||
printf "%s - Yikes - Missing UPTIMEROBOT_HEARTBEAT_URL environment variable" "$(date -u)"
|
||||
exit 0
|
||||
fi
|
||||
status_code=$(curl --connect-timeout 10 --max-time 30 -I -s -o /dev/null -w '%{http_code}' "$UPTIMEROBOT_HEARTBEAT_URL")
|
||||
if [ "${status_code}" != "200" ]; then
|
||||
printf "%s - Yikes - Heartbeat request failed, http code: %s" "$(date -u)" "$status_code"
|
||||
exit 0
|
||||
fi
|
||||
printf "%s - Success - Heartbeat request received and processed successfully" "$(date -u)"
|
||||
- name: uptimerobot-heartbeat
|
||||
image: ghcr.io/k8s-at-home/kubectl:v1.22.3
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: uptimerobot-heartbeat-url
|
||||
command:
|
||||
- "/bin/sh"
|
||||
- "/app/uptimerobot-heartbeat.sh"
|
||||
volumeMounts:
|
||||
- name: uptimerobot-heartbeat
|
||||
mountPath: /app/uptimerobot-heartbeat.sh
|
||||
subPath: uptimerobot-heartbeat.sh
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: uptimerobot-heartbeat
|
||||
projected:
|
||||
defaultMode: 0775
|
||||
sources:
|
||||
- configMap:
|
||||
name: uptimerobot-heartbeat
|
||||
items:
|
||||
- key: uptimerobot-heartbeat.sh
|
||||
path: uptimerobot-heartbeat.sh
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- cron-job.yaml
|
||||
- secret.enc.yaml
|
||||
- cron-job.yaml
|
||||
- secret.enc.yaml
|
||||
namespace: monitoring
|
||||
configMapGenerator:
|
||||
- name: uptimerobot-heartbeat
|
||||
files:
|
||||
- uptimerobot-heartbeat.sh
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
annotations:
|
||||
kustomize.toolkit.fluxcd.io/substitute: disabled
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
if [ -z "$UPTIMEROBOT_HEARTBEAT_URL" ]; then
|
||||
printf "%s - Yikes - Missing UPTIMEROBOT_HEARTBEAT_URL environment variable" "$(date -u)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
status_code=$(curl --connect-timeout 10 --max-time 30 -I -s -o /dev/null -w '%{http_code}' "$UPTIMEROBOT_HEARTBEAT_URL")
|
||||
if [ "${status_code}" != "200" ]; then
|
||||
printf "%s - Yikes - Heartbeat request failed, http code: %s" "$(date -u)" "$status_code"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "%s - Success - Heartbeat request received and processed successfully" "$(date -u)"
|
||||
Reference in New Issue
Block a user