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. ...@@ -20,7 +20,11 @@ Contains scrips and files to create a fielded ros kubernetes cluster.
* [Links With More Information](#links-with-more-information) * [Links With More Information](#links-with-more-information)
<!-- remote desktop tutorial: <!-- 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 ## Image building
......
#!/bin/bash #!/bin/bash
IP=$(ip route get 8.8.8.8 | awk -F"src " '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]}') # INTERFACE=$(ip route get 8.8.8.8 | awk -F"dev " 'NR==1{split($2,a," ");print a[1]}')
OLDIFS=$IFS # OLDIFS=$IFS
IFS="." # IFS="."
read ip1 ip2 ip3 ip4 <<< "$IP" # read ip1 ip2 ip3 ip4 <<< "$IP"
VIP="$ip1.$ip2.$ip3.25" # virtual ip addr # VIP="$ip1.$ip2.$ip3.25" # virtual ip addr
IFS=$OLDIFS # 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 sudo swapoff -a # turn off swap memory
# put load balancer pod spec in the manifests directory # put load balancer pod spec in the manifests directory
...@@ -63,13 +70,9 @@ IFS=$OLDIFS ...@@ -63,13 +70,9 @@ IFS=$OLDIFS
echo "------------------------------------------" echo "------------------------------------------"
newKey=$(sudo kubeadm init phase upload-certs --upload-certs | sed -n '3~0p') 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 # was working here
echo "$vipCMD && sudo $(kubeadm token create --print-join-command) --control-plane --certificate-key $newKey" | xclip -sel clip echo "$vipCMD && sudo $(kubeadm token create --print-join-command) --control-plane --certificate-key $newKey" | xclip -sel clip
echo "..." 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 exit 0
#!/usr/local/bin/bash #!/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 if test -f "$filename"; then
echo "file $filename already exists." echo "file $filename already exists."
...@@ -9,20 +12,18 @@ else ...@@ -9,20 +12,18 @@ else
echo "{}" > "$filename" echo "{}" > "$filename"
fi fi
if [[ -n "$nfsFilename" ]]; then # if [[ -n "$nfsFilename" ]]; then
if test -f "$nfsFilename"; then # if test -f "$nfsFilename"; then
echo "NFS file $nfsFilename already exists." # echo "NFS file $nfsFilename already exists."
else # else
touch "$nfsFilename" # touch "$nfsFilename"
echo "{}" > "$nfsFilename" # echo "{}" > "$nfsFilename"
fi # fi
fi # fi
echo ping "${endpoints} every ${downtime:=3} sec, saving to ${filename}" echo ping "${endpoints} every ${downtime:=3} sec, saving to ${filename}"
# for endpoints in "${endpoints[@]}"; do # for endpoints in "${endpoints[@]}"; do
# done # done
# --------------------------------------
while true; do while true; do
# for endpoints in "${endpoints[@]}"; do # for endpoints in "${endpoints[@]}"; do
...@@ -53,12 +54,6 @@ while true; do ...@@ -53,12 +54,6 @@ while true; do
echo "{}" > "$filename" echo "{}" > "$filename"
fi fi
echo "debugging:"
echo $num1
echo $num2
echo $num3
echo $num4
# keep a diary # keep a diary
if [[ -n "$num4" ]]; then 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" 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 ...@@ -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" 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 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} sleep ${downtime:=3}
done done
...@@ -84,6 +68,6 @@ if test -f "$filename.tmp"; then ...@@ -84,6 +68,6 @@ if test -f "$filename.tmp"; then
rm "$filename.tmp" rm "$filename.tmp"
fi fi
if test -f "$nfsFilename.tmp"; then # if test -f "$nfsFilename.tmp"; then
rm "$nfsFilename.tmp" # rm "$nfsFilename.tmp"
fi # fi
...@@ -17,7 +17,7 @@ spec: ...@@ -17,7 +17,7 @@ spec:
node: ping node: ping
app: cluster app: cluster
spec: spec:
hostname: service-ping hostname: pinger
tolerations: tolerations:
- key: "node-role.kubernetes.io/master" - key: "node-role.kubernetes.io/master"
effect: "NoSchedule" effect: "NoSchedule"
...@@ -40,18 +40,16 @@ spec: ...@@ -40,18 +40,16 @@ spec:
mountPath: /tmp/pingStats mountPath: /tmp/pingStats
image: localhost:5000/doorbell:latest image: localhost:5000/doorbell:latest
imagePullPolicy: Always imagePullPolicy: Always
command: ["/usr/local/bin/bash"] # You need to run some task inside a command: ["/usr/local/bin/bash"]
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;"]
# 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
env: env:
- name: endpoints - name: endpoints
value: "localhost" value: "192.168.1.230"
- name: filename - name: filename
value: "/tmp/pingStats/pingStats.json" value: "/tmp/pingStats/pingStats.json"
ports: ports:
- containerPort: 11311 - containerPort: 11311
name: pingport name: pingport
nodeSelector: nodeSelector:
kubernetes.io/hostname: pop-os # to run on control plane kubernetes.io/hostname: neruda # to run on control plane
# kubernetes.io/hostname: sentinel # 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