mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
5ae7a028d9
* feat(cluster): initial commit for scale-out cluster Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> * feat(cluster): support shared storage scale out This change introduces support for shared storage backed zot cluster scale out. New feature Multiple stateless zot instances can run using the same shared storage backend where each instance looks at a specific set of repositories based on a siphash of the repository name to improve scale as the load is distributed across multiple instances. For a given config, there will only be one instance that can perform dist-spec read/write on a given repository. What's changed? - introduced a transparent request proxy for dist-spec endpoints based on siphash of repository name. - new config for scale out cluster that specifies list of cluster members. Signed-off-by: Vishwas Rajashekar <vrajashe@cisco.com> --------- Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> Signed-off-by: Vishwas Rajashekar <vrajashe@cisco.com> Co-authored-by: Ramkumar Chinchani <rchincha@cisco.com>
71 lines
1.6 KiB
Bash
71 lines
1.6 KiB
Bash
HAPROXY_CFG_FILE="${BATS_FILE_TMPDIR}/haproxy/haproxy-test.cfg"
|
|
|
|
function generate_haproxy_server_list() {
|
|
local num_instances=${1}
|
|
for ((i=0;i<${num_instances};i++)) do
|
|
local port=$(( 10000 + $i ))
|
|
echo " server zot${i} 127.0.0.1:${port}"
|
|
done
|
|
}
|
|
|
|
# stops all haproxy instances started by the test
|
|
function haproxy_stop_all() {
|
|
pkill haproxy
|
|
}
|
|
|
|
# starts one haproxy instance with the given config file
|
|
# expects the haproxy config to specify daemon mode
|
|
function haproxy_start() {
|
|
local haproxy_cfg_file=${1}
|
|
|
|
# Check the config file
|
|
haproxy -f ${haproxy_cfg_file} -c >&3
|
|
|
|
# Start haproxy
|
|
haproxy -f ${haproxy_cfg_file}
|
|
}
|
|
|
|
# generates HAproxy config for use in the test
|
|
function generate_haproxy_config() {
|
|
local haproxy_cfg_file="${1}"
|
|
local haproxy_root_dir="$(dirname ${haproxy_cfg_file})"
|
|
# can be either http or https
|
|
local protocol="${2}"
|
|
|
|
mkdir -p ${haproxy_root_dir}
|
|
|
|
local haproxy_mode='http'
|
|
if [ "$protocol" == 'https' ]; then
|
|
haproxy_mode='tcp'
|
|
fi
|
|
|
|
cat > ${haproxy_cfg_file}<<EOF
|
|
global
|
|
log ${haproxy_root_dir}/log local0
|
|
log ${haproxy_root_dir}/log local1 notice
|
|
maxconn 20000
|
|
stats timeout 30s
|
|
daemon
|
|
|
|
defaults
|
|
log global
|
|
mode ${haproxy_mode}
|
|
option ${haproxy_mode}log
|
|
option dontlognull
|
|
timeout connect 5000
|
|
timeout client 50000
|
|
timeout server 50000
|
|
|
|
frontend zot
|
|
bind *:8000
|
|
default_backend zot-cluster
|
|
|
|
backend zot-cluster
|
|
balance roundrobin
|
|
EOF
|
|
|
|
# Populate server list
|
|
generate_haproxy_server_list ${NUM_ZOT_INSTANCES} >> ${haproxy_cfg_file}
|
|
|
|
cat ${haproxy_cfg_file} >&3
|
|
}
|