Commit e6e03d6f authored by Larkin Heintzman's avatar Larkin Heintzman

ping tweaks

parent 05e6e7df
......@@ -20,7 +20,11 @@ Contains scrips and files to create a fielded ros kubernetes cluster.
* [Links With More Information](#links-with-more-information)
<!-- remote desktop tutorial:
https://www.e2enetworks.com/help/knowledge-base/how-to-install-remote-desktop-xrdp-on-ubuntu-18-04/ -->
https://www.e2enetworks.com/help/knowledge-base/how-to-install-remote-desktop-xrdp-on-ubuntu-18-04/
start docker registry: "docker run -d -p 5000:5000 --name registry registry:2.7"
then build and tag images "docker tag <orig>:latest localhost:5000/<orig>:latest" and follow with "docker push localhost:5000/<orig>:latest" then kubernetes should be able to find the image
-->
## Image building
......
#!/bin/bash
IP=$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}')
INTERFACE=$(ip route get 8.8.8.8 | awk -F"dev " 'NR==1{split($2,a," ");print a[1]}')
# IP=$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}')
# INTERFACE=$(ip route get 8.8.8.8 | awk -F"dev " 'NR==1{split($2,a," ");print a[1]}')
OLDIFS=$IFS
IFS="."
read ip1 ip2 ip3 ip4 <<< "$IP"
VIP="$ip1.$ip2.$ip3.25" # virtual ip addr
IFS=$OLDIFS
# OLDIFS=$IFS
# IFS="."
# read ip1 ip2 ip3 ip4 <<< "$IP"
# VIP="$ip1.$ip2.$ip3.25" # virtual ip addr
# IFS=$OLDIFS
VIP="192.168.1.25" # vip for load balancer
INTERFACE="wlp0s20f3" # laptop interface
JINTERFACE="wlan0" # jetson interface
echo "Using interface: $INTERFACE"
echo "Using jetson interface: $JINTERFACE"
echo "And load-balancer IP: $VIP"
sudo swapoff -a # turn off swap memory
# put load balancer pod spec in the manifests directory
......@@ -63,13 +70,9 @@ IFS=$OLDIFS
echo "------------------------------------------"
newKey=$(sudo kubeadm init phase upload-certs --upload-certs | sed -n '3~0p')
# create vip.yaml in manifests of new control plane
# echo "$(ip route get 8.8.8.8 | awk -F"dev " 'NR==1{split($2,a," ");print a[1]}')"
# was working here
echo "$vipCMD && sudo $(kubeadm token create --print-join-command) --control-plane --certificate-key $newKey" | xclip -sel clip
echo "..."
echo "Done starting cluster, control-plane join command is copied, don't forget to move load-balancer virtual ip yaml over to new nodes"
echo "Done starting cluster, control-plane join command is copied to clipboard."
exit 0
#!/usr/local/bin/bash
# endpoints="localhost" filename="/home/llh/pingstats.json"
echo "pinging: $endpoints"
echo "through: $interface"
echo "save to: $filename"
echo " "
if test -f "$filename"; then
echo "file $filename already exists."
......@@ -9,20 +12,18 @@ else
echo "{}" > "$filename"
fi
if [[ -n "$nfsFilename" ]]; then
if test -f "$nfsFilename"; then
echo "NFS file $nfsFilename already exists."
else
touch "$nfsFilename"
echo "{}" > "$nfsFilename"
fi
fi
# if [[ -n "$nfsFilename" ]]; then
# if test -f "$nfsFilename"; then
# echo "NFS file $nfsFilename already exists."
# else
# touch "$nfsFilename"
# echo "{}" > "$nfsFilename"
# fi
# fi
echo ping "${endpoints} every ${downtime:=3} sec, saving to ${filename}"
# for endpoints in "${endpoints[@]}"; do
# done
# --------------------------------------
while true; do
# for endpoints in "${endpoints[@]}"; do
......@@ -53,12 +54,6 @@ while true; do
echo "{}" > "$filename"
fi
echo "debugging:"
echo $num1
echo $num2
echo $num3
echo $num4
# keep a diary
if [[ -n "$num4" ]]; then
jq --arg timedate $(date +"%H:%M_%F") --arg target $endpoints --argjson rttMin $num1 --argjson rttAvg $num2 --argjson rttMax $num3 --argjson stdDev $num4 '.[$target][$timedate] += [{"min":$rttMin,"avg":$rttAvg,"max":$rttMax,"std":$stdDev}]' "$filename" > "$filename.tmp" && mv "$filename.tmp" "$filename"
......@@ -66,17 +61,6 @@ while true; do
jq --arg timedate $(date +"%H:%M_%F") --arg target $endpoints --argjson rttMin $num1 --argjson rttAvg $num2 --argjson rttMax $num3 '.[$target][$timedate] += [{"min":$rttMin,"avg":$rttAvg,"max":$rttMax}]' "$filename" > "$filename.tmp" && mv "$filename.tmp" "$filename"
fi
# write home about it (if connected)
if [[ -n "$nfsFilename" ]]; then
if [[ -n "$num4" ]]; then
jq --arg timedate $(date +"%H:%M_%F") --arg hostname $HOSTNAME --arg target $endpoints --argjson rttMin $num1 --argjson rttAvg $num2 --argjson rttMax $num3 --argjson stdDev $num4 '.[$hostname][$target][$timedate] += [{"min":$rttMin,"avg":$rttAvg,"max":$rttMax,"std":$stdDev}]' "$nfsFilename" > "$nfsFilename.tmp" && mv "$nfsFilename.tmp" "$nfsFilename"
else
jq --arg timedate $(date +"%H:%M_%F") --arg hostname $HOSTNAME --arg target $endpoints --argjson rttMin $num1 --argjson rttAvg $num2 --argjson rttMax $num3 '.[$hostname][$target][$timedate] += [{"min":$rttMin,"avg":$rttAvg,"max":$rttMax}]' "$nfsFilename" > "$nfsFilename.tmp" && mv "$nfsFilename.tmp" "$nfsFilename"
fi
fi
# done
sleep ${downtime:=3}
done
......@@ -84,6 +68,6 @@ if test -f "$filename.tmp"; then
rm "$filename.tmp"
fi
if test -f "$nfsFilename.tmp"; then
rm "$nfsFilename.tmp"
fi
# if test -f "$nfsFilename.tmp"; then
# rm "$nfsFilename.tmp"
# fi
......@@ -17,7 +17,7 @@ spec:
node: ping
app: cluster
spec:
hostname: service-ping
hostname: pinger
tolerations:
- key: "node-role.kubernetes.io/master"
effect: "NoSchedule"
......@@ -40,18 +40,16 @@ spec:
mountPath: /tmp/pingStats
image: localhost:5000/doorbell:latest
imagePullPolicy: Always
command: ["/usr/local/bin/bash"] # You need to run some task inside a
args: ["-c", "/ping.sh & while true; do sleep 10; done;"] # Our simple program just sleeps inside
# args: ["-c", "/ping.sh" & while true; do sleep 10; done;"] # Our simple program just sleeps inside
# args: ["-c", "./ping.sh"] # Our simple program just sleeps inside
command: ["/usr/local/bin/bash"]
args: ["-c", "/ping.sh & while true; do sleep 10; done;"]
env:
- name: endpoints
value: "localhost"
value: "192.168.1.230"
- name: filename
value: "/tmp/pingStats/pingStats.json"
ports:
- containerPort: 11311
name: pingport
nodeSelector:
kubernetes.io/hostname: pop-os # to run on control plane
kubernetes.io/hostname: neruda # to run on control plane
# kubernetes.io/hostname: sentinel
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment