---
apiVersion: v1
kind: ConfigMap
metadata:
name: connectivity-test
namespace: default
labels:
app: connectivity-test
data:
ANNOTATIONS: "env:TEST"
HTTPS_PROXY: "ip:port"
HTTP_PROXY: ""
FTP_PROXY: ""
NO_PROXY: ""
# should proxy be set to reach the notification endpoint
PROXY_ON_NOTIFICATION: "false"
# use proxy at startup
PROXY_ON_STARTUP: "false"
# set proxy before running the test
PROXY_DURING_TEST: "false"
# should notification be send if all tests were successful?
NOTIFY_ON_SUCCESS: "false"
# should notification be send if at least 1 test failed?
NOTIFY_ON_FAILURE: "true"
#status summary for each successful single test
SUCCESS_STATUS: "SUCCESS"
#status summary for each failed single test
FAILURE_STATUS: "FAILURE"
#internal filename to write test results
RESULTS_FILE_NAME: "connectivity-test.txt"
# If not using a cron job for example, you can set the restart interval(seconds) between runs here
SLEEP_INTERVAL: "60"
# If not using a cron job, and there is a failed connectivity test, this is amount of times the rety interval will increase
# retry interval's value starts from SLEEP_INTERVAL
RETRY_EXPONENT: "2"
# If not using a cron job, and there is a failed connectivity test, this is the maximum retry interval
MAX_RETRY_INTERVAL: "3600"
#teams webhook url to send notification to
WEBHOOK_URL: "XXX"
SCRIPT_URL: "https://raw.githubusercontent.com/hayone1/InterestingJobs/main/monitoring/connectivity-monitor-msteams/check-connectivity-msteams.sh"
#Destination hosts/ports to test connection to
HOSTS: |
[
{
"name" : "XXX",
"host" : "XXX",
"port" : "XXX"
},
{
"name" : "XXX",
"host" : "XXX",
"port" : "XXX"
}
]
#Team members to mention in the alert. see: https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cconnector-html#example
TEAM: |
[
{
"type": "mention",
"text": "name",
"mentioned": {
"id": "name.name@domain.com",
"name": "name name"
}
},
{
"type": "mention",
"text": "name",
"mentioned": {
"id": "name.name@domain.com",
"name": "name name"
}
}
]
# Note: Need to ensure that the eventual message size doesn't exceed 28 KB for Incoming Webhooks
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: connectivity-test
namespace: default
labels:
app: connectivity-test
spec:
replicas: 1
selector:
matchLabels:
app: connectivity-test
template:
metadata:
labels:
app: connectivity-test
spec:
containers:
# preferenced https://github.com/digitalocean/doks-debug
# but any image with GNU bash, ncat, jq should work
- name: doks
image: docker.io/digitalocean/doks-debug:latest
envFrom:
- configMapRef:
name: connectivity-test
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
# ports:
# - containerPort: 80
command:
- /bin/bash
- -c
- |
# if true
[ "$PROXY_ON_STARTUP" == "true" ] && export http_proxy="$HTTP_PROXY" https_proxy="$HTTPS_PROXY" ftp_proxy="$FTP_PROXY" no_proxy="$NO_PROXY";
# if false
[ "$PROXY_ON_STARTUP" == "true" ] || unset http_proxy https_proxy ftp_proxy no_proxy;
echo "PROXY_ON_STARTUP: $PROXY_ON_STARTUP"
echo "Downloading script from: $SCRIPT_URL"
curl "$SCRIPT_URL" > check-connectivity-msteams.sh
echo "Executing script"
chmod +x check-connectivity-msteams.sh
./check-connectivity-msteams.sh