mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-23 00:57:44 +01:00
Enhance monitor script for HA
Add keepalived real server check script
This commit is contained in:
parent
bf14cf4436
commit
ffa69bb256
44
make/ha/sample/active_active/check.sh
Normal file
44
make/ha/sample/active_active/check.sh
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
#get protocol
|
||||||
|
|
||||||
|
#LOG=/var/log/keepalived_check.log
|
||||||
|
nodeip=$1
|
||||||
|
nodeaddress="http://${nodeip}"
|
||||||
|
http_code=`curl -s -o /dev/null -w "%{http_code}" ${nodeaddress}`
|
||||||
|
|
||||||
|
if [ $http_code == 200 ] ; then
|
||||||
|
protocol="http"
|
||||||
|
elif [ $http_code == 301 ]
|
||||||
|
then
|
||||||
|
protocol="https"
|
||||||
|
else
|
||||||
|
# echo "`date +"%Y-%m-%d %H:%M:%S"` $1, CHECK_CODE=$http_code" >> $LOG
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
systeminfo=`curl -k -o - -s ${protocol}://${nodeip}/api/systeminfo`
|
||||||
|
|
||||||
|
echo $systeminfo | grep "registry_url"
|
||||||
|
if [ $? != 0 ] ; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
#TODO need to check Clair, but currently Clair status api is unreachable from LB.
|
||||||
|
# echo $systeminfo | grep "with_clair" | grep "true"
|
||||||
|
# if [ $? == 0 ] ; then
|
||||||
|
# clair is enabled
|
||||||
|
# do some clair check
|
||||||
|
# else
|
||||||
|
# clair is disabled
|
||||||
|
# fi
|
||||||
|
|
||||||
|
#check top api
|
||||||
|
|
||||||
|
http_code=`curl -k -s -o /dev/null -w "%{http_code}\n" ${protocol}://${nodeip}/api/repositories/top`
|
||||||
|
set +e
|
||||||
|
if [ $http_code == 200 ] ; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
@ -28,7 +28,9 @@ vrrp_instance VI_1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
########## Section for Harbor use HTTP protocol ######################
|
||||||
#Please change VIP, harbor_node1_ip, harbor_node2_ip to real ip address
|
#Please change VIP, harbor_node1_ip, harbor_node2_ip to real ip address
|
||||||
|
#Please comment this secion out when use https
|
||||||
virtual_server VIP 80 {
|
virtual_server VIP 80 {
|
||||||
delay_loop 15
|
delay_loop 15
|
||||||
lb_algo rr
|
lb_algo rr
|
||||||
@ -39,20 +41,24 @@ virtual_server VIP 80 {
|
|||||||
|
|
||||||
real_server harbor_node1_ip 80 {
|
real_server harbor_node1_ip 80 {
|
||||||
weight 10
|
weight 10
|
||||||
TCP_CHECK {
|
MISC_CHECK {
|
||||||
connect_timeout 3
|
misc_path “/usr/local/bin/check.sh harbor_node1_ip”
|
||||||
connect_port 80
|
misc_timeout 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
real_server harbor_node2_ip 80 {
|
real_server harbor_node2_ip 80 {
|
||||||
weight 10
|
weight 10
|
||||||
TCP_CHECK {
|
MISC_CHECK {
|
||||||
connect_timeout 3
|
misc_path “/usr/local/bin/check.sh harbor_node2_ip”
|
||||||
connect_port 80
|
misc_timeout 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#########################End of HTTP############################
|
||||||
|
|
||||||
|
##########################HTTPS#################################
|
||||||
#Please uncomment the follow when harbor running under https
|
#Please uncomment the follow when harbor running under https
|
||||||
#virtual_server VIP 443 {
|
#virtual_server VIP 443 {
|
||||||
# delay_loop 15
|
# delay_loop 15
|
||||||
@ -64,17 +70,18 @@ virtual_server VIP 80 {
|
|||||||
#
|
#
|
||||||
# real_server harbor_node1_ip 443 {
|
# real_server harbor_node1_ip 443 {
|
||||||
# weight 10
|
# weight 10
|
||||||
# TCP_CHECK {
|
# MISC_CHECK {
|
||||||
# connect_timeout 3
|
# misc_path “/usr/local/bin/check.sh harbor_node1_ip”
|
||||||
# connect_port 443
|
# misc_timeout 5
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# real_server harbor_node2_ip 443 {
|
# real_server harbor_node2_ip 443 {
|
||||||
# weight 10
|
# weight 10
|
||||||
# TCP_CHECK {
|
# MISC_CHECK {
|
||||||
# connect_timeout 3
|
# misc_path “/usr/local/bin/check.sh harbor_node2_ip”
|
||||||
# connect_port 443
|
# misc_timeout 5
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
#}
|
#}
|
||||||
|
#########################End of HTTPS Section#################
|
||||||
|
Loading…
Reference in New Issue
Block a user