File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -374,9 +374,8 @@ log_debug "Installing Helm chart from artifact [$chart2install]"
374
374
log_verbose " Creating Grafana alert rules ConfigMap"
375
375
CUSTOM_ALERT_CONFIG_DIR=" $USER_DIR /monitoring/alerting/"
376
376
377
- # Add optional custom directory if it exists
378
- if [ -d " $CUSTOM_ALERT_CONFIG_DIR " ]; then
379
- log_debug " Including notifiers and additional alert rules from '$CUSTOM_ALERT_CONFIG_DIR '"
377
+ if [ -d " $CUSTOM_ALERT_CONFIG_DIR " ] && [ " $( ls -A " $CUSTOM_ALERT_CONFIG_DIR " 2> /dev/null) " ]; then
378
+ log_debug " Creating configmap for alert rules/notifiers/contact points defined in '$CUSTOM_ALERT_CONFIG_DIR '"
380
379
CM_ARGS=(--from-file=" $CUSTOM_ALERT_CONFIG_DIR " )
381
380
382
381
# Run the kubectl command with all arguments
@@ -385,7 +384,12 @@ if [ -d "$CUSTOM_ALERT_CONFIG_DIR" ]; then
385
384
-n " $MON_NS " \
386
385
--dry-run=client -o yaml | kubectl apply -f -
387
386
else
388
- log_debug " No custom alert config directory found at '$CUSTOM_ALERT_CONFIG_DIR '. Skipping."
387
+ log_debug " No custom alert files found at '$CUSTOM_ALERT_CONFIG_DIR '. Creating empty ConfigMap."
388
+ # Create an empty ConfigMap to satisfy the volume mount
389
+ kubectl create configmap grafana-alert-rules \
390
+ -n " $MON_NS " \
391
+ --from-literal=_README.txt=" Copy alert rules from samples/alerts to $USER_DIR /monitoring/alerting/ to enable them." \
392
+ --dry-run=client -o yaml | kubectl apply -f -
389
393
fi
390
394
391
395
# shellcheck disable=SC2086
You can’t perform that action at this time.
0 commit comments